Skip to content

Commit

Permalink
[Tests] A few easy fixes for unit tests
Browse files Browse the repository at this point in the history
~25 failures still. I need to update the project to just ignore the
maps directory completely for tests instead of just ignoring one test.

Signed-off-by: Kawika Avilla <[email protected]>
  • Loading branch information
kavilla committed Mar 24, 2021
1 parent b16b428 commit 2a5aebe
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/osd-pm/src/utils/project.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ describe('#getExecutables()', () => {
});

expect(project.getExecutables()).toEqual({
opensearchDashboards: resolve(rootPath, 'bin/script.js'),
'opensearch-dashboards': resolve(rootPath, 'bin/script.js'),
});
});

Expand Down
16 changes: 5 additions & 11 deletions packages/osd-test/src/failed_tests_reporter/issue_metadata.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,23 +26,23 @@ const HAS_METADATA = dedent`
some text
<!-- opensearchDashboardsCiData = {"failed-test": {"foo": "bar"}} -->
<!-- OpenSearchDashboardsCiData = {"failed-test": {"foo": "bar"}} -->
`;

const HAS_SOME_OTHER_METADATA = dedent`
# my issue
some text
<!-- opensearchDashboardsCiData = {"some-other": {"foo": "bar"}} -->
<!-- OpenSearchDashboardsCiData = {"some-other": {"foo": "bar"}} -->
`;

const INVALID_METADATA = dedent`
# my issue
some text
<!-- opensearchDashboardsCiData = {"failed-test" -->
<!-- OpenSearchDashboardsCiData = {"failed-test" -->
`;

const MISSING_METADATA = dedent`
Expand Down Expand Up @@ -88,9 +88,7 @@ describe('updateIssueMetadata', () => {
some text
<!-- opensearchDashboardsCiData = {\\"failed-test\\": {\\"foo\\": \\"bar\\"}} -->
<!-- OpenSearchDashboardsCiData = {\\"failed-test\\":{\\"box\\":\\"baz\\"}} -->"
<!-- OpenSearchDashboardsCiData = {\\"failed-test\\":{\\"foo\\":\\"bar\\",\\"box\\":\\"baz\\"}} -->"
`);
});

Expand All @@ -116,9 +114,7 @@ describe('updateIssueMetadata', () => {
some text
<!-- opensearchDashboardsCiData = {\\"some-other\\": {\\"foo\\": \\"bar\\"}} -->
<!-- OpenSearchDashboardsCiData = {\\"failed-test\\":{\\"box\\":\\"baz\\"}} -->"
<!-- OpenSearchDashboardsCiData = {\\"some-other\\":{\\"foo\\":\\"bar\\"},\\"failed-test\\":{\\"box\\":\\"baz\\"}} -->"
`);
});

Expand All @@ -132,8 +128,6 @@ describe('updateIssueMetadata', () => {
some text
<!-- opensearchDashboardsCiData = {\\"failed-test\\" -->
<!-- OpenSearchDashboardsCiData = {\\"failed-test\\":{\\"box\\":\\"baz\\"}} -->"
`);
});
Expand Down
2 changes: 1 addition & 1 deletion src/core/public/doc_links/doc_links_service.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('DocLinksService#start()', () => {
const api = service.start({ injectedMetadata });
expect(api.DOC_LINK_VERSION).toEqual('test-branch');
expect(api.links.opensearchDashboards).toEqual(
'https://www.opensearch.co/guide/en/kibana/test-branch/index.html'
'https://www.opensearch.com/guide/en/kibana/test-branch/index.html'
);
});
});
2 changes: 0 additions & 2 deletions src/core/server/plugins/discovery/plugins_discovery.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,9 @@ describe('plugins discovery system', () => {
.toPromise();

const srcPluginsPath = resolve(OPENSEARCH_DASHBOARDS_ROOT, 'src', 'plugins');
const xpackPluginsPath = resolve(OPENSEARCH_DASHBOARDS_ROOT, 'x-pack', 'plugins');
expect(errors).toEqual(
expect.arrayContaining([
`Error: EACCES, permission denied '${srcPluginsPath}' (invalid-search-path, ${srcPluginsPath})`,
`Error: ENOENT, no such file or directory '${xpackPluginsPath}' (invalid-search-path, ${xpackPluginsPath})`,
])
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ 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,
}));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('Settings', function () {
describe('Advanced', function () {
describe('getCategoryName(category)', function () {
it('should capitalize unknown category', function () {
expect(getCategoryName('opensearch')).to.be('OpenSearch');
expect(getCategoryName('unknown')).to.be('Unknown');
});

it('should return empty string for no category', function () {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@

import { defaultAlertText } from './default_alert';

describe('defaultAlertText', () => {
// TODO: Ignoring because the defaultAlertText was commented out because it upsells a hosted solution.
xdescribe('defaultAlertText', () => {
it('creates a valid MountPoint that can cleanup correctly', () => {
const mountPoint = defaultAlertText(jest.fn());

Expand Down

0 comments on commit 2a5aebe

Please sign in to comment.