Skip to content

Commit

Permalink
Removed html_id_generator mocks.
Browse files Browse the repository at this point in the history
Current mock was failing due to missing useGeneratedHtmlId export. This is safe to remove because EUI contains a .testenv that contains an mock for html_id_generator. More info at https://github.com/elastic/eui/blob/master/src/services/accessibility/html_id_generator.testenv.ts
  • Loading branch information
breehall committed Oct 4, 2021
1 parent d44b789 commit 8a29a96
Show file tree
Hide file tree
Showing 19 changed files with 12 additions and 98 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ import { mountWithI18nProvider } from '@kbn/test/jest';
import { Frequency } from './types';
import { CronEditor } from './cron_editor';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('CronEditor', () => {
['MINUTE', 'HOUR', 'DAY', 'WEEK', 'MONTH', 'YEAR'].forEach((unit) => {
test(`is rendered with a ${unit} frequency`, () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ import React from 'react';

const EDITOR_ID = 'testEditor';

jest.mock('@elastic/eui/lib/services/accessibility', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

jest.mock('@elastic/eui', () => {
const original = jest.requireActual('@elastic/eui');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import { createKibanaReactContext } from '../../../../../../kibana_react/public'
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';

jest.mock('@elastic/eui/lib/services/accessibility', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

const fieldType = 'string';
const format = {
getConverterFor: jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ import props from './__fixtures__/props.json';
import { MemoryRouter } from 'react-router-dom';
import { EuiThemeProvider } from '../../../../../../../../src/plugins/kibana_react/common';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('ErrorGroupOverview -> List', () => {
beforeAll(() => {
mockMoment();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,6 @@ import { mountWithTheme } from '../../../utils/testHelpers';
import { Stackframe as StackframeComponent } from './Stackframe';
import stacktracesMock from './__fixtures__/stacktraces.json';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('Stackframe', () => {
describe('when stackframe has source lines', () => {
let wrapper: ReactWrapper;
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import { Settings } from './settings';

jest.mock('../../../supported_renderers');
jest.mock(`@elastic/eui/lib/components/form/form_row/make_id`, () => () => `generated-id`);
jest.mock('@elastic/eui/lib/services/accessibility', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

jest.mock('@elastic/eui/lib/components/portal/portal', () => {
// eslint-disable-next-line @typescript-eslint/no-shadow
const React = jest.requireActual('react');
Expand Down
7 changes: 0 additions & 7 deletions x-pack/plugins/canvas/storybook/storyshots.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,6 @@ jest.mock('@elastic/eui/packages/react-datepicker', () => {
// @ts-expect-error Portal mocks are notoriously difficult to type
ReactDOM.createPortal = jest.fn((element) => element);

// Mock the EUI HTML ID Generator so elements have a predictable ID in snapshots
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

// To be resolved by EUI team.
// https://github.com/elastic/eui/issues/3712
jest.mock('@elastic/eui/lib/components/overlay_mask/overlay_mask', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

import { AddLicense } from '../public/application/sections/license_dashboard/add_license';
import { createMockLicense, getComponent } from './util';
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('AddLicense component when license is active', () => {
test('should display correct verbiage', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

import { RequestTrialExtension } from '../public/application/sections/license_dashboard/request_trial_extension';
import { createMockLicense, getComponent } from './util';
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('RequestTrialExtension component', () => {
test('should not display when license is active and trial has not been used', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@

import { RevertToBasic } from '../public/application/sections/license_dashboard/revert_to_basic';
import { createMockLicense, getComponent } from './util';
jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('RevertToBasic component', () => {
test('should display when trial is active', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,6 @@
import { StartTrial } from '../public/application/sections/license_dashboard/start_trial';
import { createMockLicense, getComponent } from './util';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('StartTrial component when trial is allowed', () => {
test('display for basic license', () => {
const rendered = getComponent(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,6 @@ import { Job } from '../lib/job';
import { InternalApiClientProvider, ReportingAPIClient } from '../lib/reporting_api_client';
import { KibanaContextProvider } from '../shared_imports';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

interface PayloadMock {
payload: Omit<ReportApiJSON['payload'], 'browserTimezone' | 'version' | 'layout'>;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,6 @@ import { renderWithIntl, shallowWithIntl } from '@kbn/test/jest';
import { AvailabilityReporting } from './availability_reporting';
import { StatusTag } from './location_status_tags';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('AvailabilityReporting component', () => {
let allLocations: StatusTag[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,6 @@ import { mockMoment } from '../../../../lib/helper/test_helpers';

mockMoment();

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

describe('LocationStatusTags component', () => {
let monitorLocations: MonitorLocation[];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,6 @@ import { mockMoment } from '../../../lib/helper/test_helpers';
import { render } from '../../../lib/helper/rtl_helpers';
import { EuiThemeProvider } from '../../../../../../../src/plugins/kibana_react/common';

jest.mock('@elastic/eui/lib/services/accessibility/html_id_generator', () => {
return {
htmlIdGenerator: () => () => `generated-id`,
};
});

const testFooPings: Ping[] = [
makePing({
docId: 'foo1',
Expand Down

0 comments on commit 8a29a96

Please sign in to comment.