Skip to content

Commit

Permalink
[Tests] Updates for integration tests (#208) (#239)
Browse files Browse the repository at this point in the history
* [Tests] update integration snapshots (#208)

Updated automated snapshots by running yarn test:jest_integration -u
However there is a snapshot being updated to an old logo so I'm trying
to find out where that is being generated.

Fixed some broken test cases due to incorrect imports or newlines.

* [Build] renamed scripts in dev/build/tasks

Noticed these scripts were unchanged so I updated them.

* [Tests] rename comments

Missed references to elastic.

* [Tests] ignore tests that download snapshots

These tests try to download snapshots that are no longer valid.
Ignoring and adding the [RENAMEME] when we have a valid URL
to download snapshots from.

* [Tests] update stats test to expected value

Key for a response body was incorrect.

* [Tests] update spinner to remove logo

Update to use a more generic spinner for app routing
because the previous spinner would use logoElastic.
Therefore when updating the snapshot would have logoElastic.

Signed-off-by: Kawika Avilla <kavilla414@gmail.com>
  • Loading branch information
kavilla authored Apr 2, 2021
1 parent e250009 commit 76f4035
Show file tree
Hide file tree
Showing 20 changed files with 63 additions and 62 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ import { CoreStart } from '<%= importFromRoot('src/core/public') %>';
};

// Render the application DOM.
// Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation`
plugin's start contract.
// Note that `navigation.ui.TopNavMenu` is a stateful component exported on the `navigation` plugin's start contract.
return (
<Router basename={basename}>
<I18nProvider>
Expand Down
16 changes: 8 additions & 8 deletions src/core/public/application/integration_tests/router.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ describe('AppRouter', () => {

expect(app1.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app1
html: <span>App 1</span>
</div></div>"
Expand All @@ -119,7 +119,7 @@ describe('AppRouter', () => {
expect(app1Unmount).toHaveBeenCalled();
expect(app2.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app2
html: <div>App 2</div>
</div></div>"
Expand All @@ -133,7 +133,7 @@ describe('AppRouter', () => {

expect(standardApp.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app1
html: <span>App 1</span>
</div></div>"
Expand All @@ -145,7 +145,7 @@ describe('AppRouter', () => {
expect(standardAppUnmount).toHaveBeenCalled();
expect(chromelessApp.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-a/path
html: <div>Chromeless A</div>
</div></div>"
Expand All @@ -157,7 +157,7 @@ describe('AppRouter', () => {
expect(chromelessAppUnmount).toHaveBeenCalled();
expect(standardApp.mounter.mount).toHaveBeenCalledTimes(2);
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /app/app1
html: <span>App 1</span>
</div></div>"
Expand All @@ -171,7 +171,7 @@ describe('AppRouter', () => {

expect(chromelessAppA.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-a/path
html: <div>Chromeless A</div>
</div></div>"
Expand All @@ -183,7 +183,7 @@ describe('AppRouter', () => {
expect(chromelessAppAUnmount).toHaveBeenCalled();
expect(chromelessAppB.mounter.mount).toHaveBeenCalled();
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-b/path
html: <div>Chromeless B</div>
</div></div>"
Expand All @@ -195,7 +195,7 @@ describe('AppRouter', () => {
expect(chromelessAppBUnmount).toHaveBeenCalled();
expect(chromelessAppA.mounter.mount).toHaveBeenCalledTimes(2);
expect(dom?.html()).toMatchInlineSnapshot(`
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingElastic euiLoadingElastic--xxLarge\\" aria-label=\\"Loading application\\"><div data-euiicon-type=\\"heatmap\\"></div></span></div><div><div>
"<div class=\\"appContainer__loading\\"><span class=\\"euiLoadingSpinner euiLoadingSpinner--xLarge\\" aria-label=\\"Loading application\\"></span></div><div><div>
basename: /chromeless-a/path
html: <div>Chromeless A</div>
</div></div>"
Expand Down
4 changes: 2 additions & 2 deletions src/core/public/application/ui/app_container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import React, {
useState,
MutableRefObject,
} from 'react';
import { EuiLoadingElastic } from '@elastic/eui';
import { EuiLoadingSpinner } from '@elastic/eui';

import type { MountPoint } from '../../types';
import { AppLeaveHandler, AppStatus, AppUnmount, Mounter } from '../types';
Expand Down Expand Up @@ -120,7 +120,7 @@ export const AppContainer: FunctionComponent<Props> = ({
{appNotFound && <AppNotFound />}
{showSpinner && (
<div className="appContainer__loading">
<EuiLoadingElastic aria-label="Loading application" size="xxl" />
<EuiLoadingSpinner aria-label="Loading application" size="xl" />
</div>
)}
<div key={appId} ref={elementRef} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ jest.doMock('../../opensearch/legacy/scoped_cluster_client', () => ({
),
}));

jest.doMock('opensearch', () => {
const realOpenSearch = jest.requireActual('opensearch');
jest.doMock('elasticsearch', () => {
const realOpenSearch = jest.requireActual('elasticsearch');
return {
...realOpenSearch,
// eslint-disable-next-line object-shorthand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@ export const migratorInstanceMock = mockOpenSearchDashboardsMigrator.create();
export const OpenSearchDashboardsMigratorMock = jest
.fn()
.mockImplementation(() => migratorInstanceMock);
jest.doMock('../../migrations/opensearch-dashboards/opensearch_dashboards_migrator', () => ({
jest.doMock('../../migrations/opensearch_dashboards/opensearch_dashboards_migrator', () => ({
OpenSearchDashboardsMigrator: OpenSearchDashboardsMigratorMock,
}));
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ const createRegistryMock = (): jest.Mocked<
mock.getVisibleTypes.mockReturnValue([]);
mock.getAllTypes.mockReturnValue([]);
mock.getImportableAndExportableTypes.mockReturnValue([]);
mock.getIndex.mockReturnValue('.opensearch_dashboards-test');
mock.getIndex.mockReturnValue('.opensearch_dashboards-test');
mock.getIndex.mockReturnValue('.opensearch_dashboards_test');
mock.getIndex.mockReturnValue('.opensearch_dashboards_test');
mock.isHidden.mockReturnValue(false);
mock.isNamespaceAgnostic.mockImplementation((type: string) => type === 'global');
mock.isSingleNamespace.mockImplementation(
Expand Down
12 changes: 6 additions & 6 deletions src/core/server/saved_objects/service/lib/repository.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ describe('SavedObjectsRepository', () => {
const allowedTypes = [...new Set(allTypes.filter((type) => !registry.isHidden(type)))];

savedObjectsRepository = new SavedObjectsRepository({
index: '.opensearch_dashboards-test',
index: '.opensearch_dashboards_test',
mappings,
client,
migrator,
Expand Down Expand Up @@ -689,7 +689,7 @@ describe('SavedObjectsRepository', () => {
await bulkCreateSuccess([obj1, obj2]);
expectClientCallArgsAction([obj1, obj2], {
method: 'create',
_index: '.opensearch_dashboards-test',
_index: '.opensearch_dashboards_test',
});
});

Expand Down Expand Up @@ -1937,7 +1937,7 @@ describe('SavedObjectsRepository', () => {
it(`should use default index`, async () => {
await createSuccess(type, attributes, { id });
expect(client.create).toHaveBeenCalledWith(
expect.objectContaining({ index: '.opensearch_dashboards-test' }),
expect.objectContaining({ index: '.opensearch_dashboards_test' }),
expect.anything()
);
});
Expand Down Expand Up @@ -2416,7 +2416,7 @@ describe('SavedObjectsRepository', () => {
it(`should use all indices for types that are not namespace-agnostic`, async () => {
await deleteByNamespaceSuccess(namespace);
expect(client.updateByQuery).toHaveBeenCalledWith(
expect.objectContaining({ index: ['.opensearch_dashboards-test', 'custom'] }),
expect.objectContaining({ index: ['.opensearch_dashboards_test', 'custom'] }),
expect.anything()
);
});
Expand Down Expand Up @@ -3450,7 +3450,7 @@ describe('SavedObjectsRepository', () => {
it(`should use default index`, async () => {
const expectFn = () =>
expect(client.delete).toHaveBeenCalledWith(
expect.objectContaining({ index: '.opensearch_dashboards-test' }),
expect.objectContaining({ index: '.opensearch_dashboards_test' }),
expect.anything()
);
await deleteFromNamespacesSuccessDelete(expectFn);
Expand Down Expand Up @@ -3527,7 +3527,7 @@ describe('SavedObjectsRepository', () => {
it(`should use default index`, async () => {
const expectFn = () =>
expect(client.update).toHaveBeenCalledWith(
expect.objectContaining({ index: '.opensearch_dashboards-test' }),
expect.objectContaining({ index: '.opensearch_dashboards_test' }),
expect.anything()
);
await deleteFromNamespacesSuccessUpdate(expectFn);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('SavedObjectsRepository#createRepository', () => {
originalRepository.createRepository(
(migrator as unknown) as OpenSearchDashboardsMigrator,
typeRegistry,
'.opensearch_dashboards-test',
'.opensearch_dashboards_test',
callAdminCluster,
['unMappedType1', 'unmappedType2']
);
Expand All @@ -94,7 +94,7 @@ describe('SavedObjectsRepository#createRepository', () => {
const repository = originalRepository.createRepository(
(migrator as unknown) as OpenSearchDashboardsMigrator,
typeRegistry,
'.opensearch_dashboards-test',
'.opensearch_dashboards_test',
callAdminCluster,
[],
SavedObjectsRepository
Expand All @@ -112,7 +112,7 @@ describe('SavedObjectsRepository#createRepository', () => {
const repository = originalRepository.createRepository(
(migrator as unknown) as OpenSearchDashboardsMigrator,
typeRegistry,
'.opensearch_dashboards-test',
'.opensearch_dashboards_test',
callAdminCluster,
['hiddenType', 'hiddenType', 'hiddenType'],
SavedObjectsRepository
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ describe('createOrUpgradeSavedConfig()', () => {
await osd.stop();
}, 30000);

it('upgrades the previous version on each increment', async function () {
// TODO: [RENAMEME] Test can be enabled once there is a valid snapshot URL
xit('upgrades the previous version on each increment', async function () {
// ------------------------------------
// upgrade to 5.4.0
await createOrUpgradeSavedConfig({
Expand Down
3 changes: 2 additions & 1 deletion src/core/server/ui_settings/integration_tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ import { docExistsSuite } from './doc_exists';
import { docMissingSuite } from './doc_missing';
import { docMissingAndIndexReadOnlySuite } from './doc_missing_and_index_read_only';

describe('uiSettings/routes', function () {
// TODO: [RENAMEME] Test can be enabled once there is a valid snapshot URL
xdescribe('uiSettings/routes', function () {
jest.setTimeout(10000);

beforeAll(startServers);
Expand Down
8 changes: 4 additions & 4 deletions src/core/test_helpers/osd_server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export const request: Record<
put: (root, path) => getSupertest(root, 'put', path),
};

export interface TestOpenSearchhServer {
export interface TestOpenSearchServer {
getStartTimeout: () => number;
start: (opensearchArgs: string[], opensearchEnvVars: Record<string, string>) => Promise<void>;
stop: () => Promise<void>;
Expand All @@ -161,7 +161,7 @@ export interface TestOpenSearchhServer {

export interface TestOpenSearchUtils {
stop: () => Promise<void>;
opensearch: TestOpenSearchhServer;
opensearch: TestOpenSearchServer;
hosts: string[];
username: string;
password: string;
Expand Down Expand Up @@ -262,14 +262,14 @@ export function createTestServers({
opensearchPort: opensearchTestConfig.getUrlParts().port,
updates: [
...usersToBeAdded,
// user elastic
// user opensearch
opensearchTestConfig.getUrlParts(),
// user opensearchDashboards
osdTestConfig.getUrlParts(),
],
});

// Override provided configs, we know what the elastic user is now
// Override provided configs, we know what the opensearch user is now
osdSettings.opensearch = {
hosts: [opensearchTestConfig.getUrl()],
username: opensearchDashboardsServerTestUser.username,
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe('/api/stats', () => {
}),
config: {
allowAnonymous: true,
opensearchDashboardsIndex: '.opensearch_dashboards-test',
opensearchDashboardsIndex: '.opensearch_dashboards_test',
opensearchDashboardsVersion: '8.8.8-SNAPSHOT',
server: {
name: 'myopensearchDashboards',
Expand All @@ -86,10 +86,10 @@ describe('/api/stats', () => {
it('successfully returns data', async () => {
const response = await supertest(httpSetup.server.listener).get('/api/stats').expect(200);
expect(response.body).toMatchObject({
opensearchDashboards: {
opensearch_dashboards: {
uuid: 'xxx-xxxxx',
name: 'myopensearchDashboards',
index: '.opensearch_dashboards-test',
index: '.opensearch_dashboards_test',
host: 'myopensearchDashboards.com',
locale: 'en',
transport_address: `myopensearchDashboards.com:1234`,
Expand Down

0 comments on commit 76f4035

Please sign in to comment.