Skip to content

Commit

Permalink
[7.2] [jest] disallow invalid describe calls (#41378) (#41487)
Browse files Browse the repository at this point in the history
* [jest] disallow invalid describe calls (#41378)

* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts
#	test/functional/apps/dashboard/dashboard_filtering.js
#	test/functional/apps/visualize/_point_series_options.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/auto_follow_pattern_list.test.js
#	x-pack/legacy/plugins/cross_cluster_replication/__jest__/client_integration/follower_indices_list.test.js
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_properties.test.js
#	x-pack/legacy/plugins/maps/public/connected_components/map/feature_tooltip.test.js
#	x-pack/legacy/plugins/remote_clusters/__jest__/client_integration/remote_clusters_list.test.js
#	x-pack/legacy/plugins/reporting/export_types/csv/server/__tests__/execute_job.js
#	x-pack/legacy/plugins/reporting/server/usage/get_reporting_usage_collector.test.js
#	x-pack/legacy/plugins/security/server/lib/authorization/privileges/privileges.test.ts
#	x-pack/legacy/plugins/siem/public/components/last_event_time/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/add_to_kql/index.test.tsx
#	x-pack/legacy/plugins/siem/public/components/page/hosts/first_last_seen_host/index.test.tsx
#	x-pack/test/functional/apps/canvas/smoke_test.js
#	x-pack/test/functional/apps/maps/documents_source/top_hits.js
#	x-pack/test/functional/apps/rollup_job/rollup_jobs.js
#	x-pack/test/functional/apps/uptime/monitor.ts
#	x-pack/test_utils/jest/integration_tests/example_integration.test.ts

* fix eslint violations
  • Loading branch information
Spencer committed Jul 19, 2019
1 parent e05b9d6 commit cd19911
Show file tree
Hide file tree
Showing 59 changed files with 106 additions and 96 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Expand Up @@ -355,6 +355,16 @@ module.exports = {
},
},

/**
* Jest specific rules
*/
{
files: ['**/*.test.{js,ts,tsx}'],
rules: {
'jest/valid-describe': 'error',
},
},

/**
* APM overrides
*/
Expand Down
2 changes: 1 addition & 1 deletion packages/kbn-pm/src/utils/projects.test.ts
Expand Up @@ -224,7 +224,7 @@ describe('#topologicallyBatchProjects', () => {
expect(expectedBatches).toMatchSnapshot();
});

describe('batchByWorkspace = true', async () => {
describe('batchByWorkspace = true', () => {
test('batches projects topologically based on their project dependencies and workspaces', async () => {
const batches = topologicallyBatchProjects(projects, graph, { batchByWorkspace: true });

Expand Down
Expand Up @@ -56,7 +56,7 @@ describe('KuiButton', () => {
describe('Props', () => {
describe('buttonType', () => {
BUTTON_TYPES.forEach(buttonType => {
describe(buttonType, () => {
describe(`${buttonType}`, () => {
test(`renders the ${buttonType} class`, () => {
const $button = render(
<KuiButton
Expand Down
Expand Up @@ -42,7 +42,7 @@ describe('KuiButtonIcon', () => {
describe('Props', () => {
describe('type', () => {
ICON_TYPES.forEach(type => {
describe(type, () => {
describe(`${type}`, () => {
test(`renders the ${type} class`, () => {
const $buttonIcon = render(<KuiButtonIcon type={type} />);
expect($buttonIcon).toMatchSnapshot();
Expand Down
Expand Up @@ -57,7 +57,7 @@ describe('KuiLinkButton', () => {
describe('Props', () => {
describe('buttonType', () => {
BUTTON_TYPES.forEach(buttonType => {
describe(buttonType, () => {
describe(`${buttonType}`, () => {
test(`renders the ${buttonType} class`, () => {
const $button = render(
<KuiLinkButton
Expand Down
Expand Up @@ -55,7 +55,7 @@ describe('KuiSubmitButton', () => {
describe('Props', () => {
describe('buttonType', () => {
BUTTON_TYPES.forEach(buttonType => {
describe(buttonType, () => {
describe(`${buttonType}`, () => {
test(`renders the ${buttonType} class`, () => {
const $button = render(<KuiSubmitButton buttonType={buttonType} />);
expect($button).toMatchSnapshot();
Expand Down
Expand Up @@ -31,7 +31,7 @@ describe('KuiCollapseButton', () => {
describe('Props', () => {
describe('direction', () => {
DIRECTIONS.forEach(direction => {
describe(direction, () => {
describe(`${direction}`, () => {
test(`renders the ${direction} class`, () => {
const component = <KuiCollapseButton direction={direction} {...requiredProps}/>;
expect(render(component)).toMatchSnapshot();
Expand Down
6 changes: 3 additions & 3 deletions src/core/public/http/http_service.test.ts
Expand Up @@ -42,7 +42,7 @@ function setupService() {
return { httpService, fatalErrors, http };
}

describe('http requests', async () => {
describe('http requests', () => {
afterEach(() => {
fetchMock.restore();
});
Expand Down Expand Up @@ -250,7 +250,7 @@ describe('http requests', async () => {
});
});

describe('addLoadingCount()', async () => {
describe('addLoadingCount()', () => {
it('subscribes to passed in sources, unsubscribes on stop', () => {
const { httpService, http } = setupService();

Expand Down Expand Up @@ -289,7 +289,7 @@ describe('addLoadingCount()', async () => {
});
});

describe('getLoadingCount$()', async () => {
describe('getLoadingCount$()', () => {
it('emits 0 initially, the right count when sources emit their own count, and ends with zero', async () => {
const { httpService, http } = setupService();

Expand Down
Expand Up @@ -81,7 +81,7 @@ describe('headers', () => {
return JSON.parse(requestParts[0]);
};

describe('search request preference', async () => {
describe('search request preference', () => {
test('should be set to sessionId when courier:setRequestPreference is "sessionId"', async () => {
const config = {
get: () => {
Expand Down
6 changes: 3 additions & 3 deletions src/legacy/ui/public/kfetch/kfetch.test.ts
Expand Up @@ -137,7 +137,7 @@ describe('kfetch', () => {
}
});

describe('when throwing response error (KFetchError)', async () => {
describe('when throwing response error (KFetchError)', () => {
let error: KFetchError;
beforeEach(async () => {
fetchMock.get('*', { status: 404, body: { foo: 'bar' } });
Expand Down Expand Up @@ -352,7 +352,7 @@ describe('kfetch', () => {
});
});

describe('when interceptors return synchronously', async () => {
describe('when interceptors return synchronously', () => {
let resp: any;
beforeEach(async () => {
fetchMock.get('*', { foo: 'bar' });
Expand Down Expand Up @@ -385,7 +385,7 @@ describe('kfetch', () => {
});
});

describe('when interceptors return promise', async () => {
describe('when interceptors return promise', () => {
let resp: any;
beforeEach(async () => {
fetchMock.get('*', { foo: 'bar' });
Expand Down
Expand Up @@ -52,7 +52,7 @@ export default function ({ getService }) {
const getSavedObjectTypesQuery = types => coerceToArray(types).map(type => `savedObjectTypes=${type}`).join('&');
const defaultQuery = getSavedObjectTypesQuery(['visualization', 'index-pattern', 'search', 'dashboard']);

describe('searches', async () => {
describe('searches', () => {
it('should validate search response schema', async () => {
await supertest
.get(`${baseApiUrl}/search/960372e0-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down Expand Up @@ -145,7 +145,7 @@ export default function ({ getService }) {
});
});

describe('dashboards', async () => {
describe('dashboards', () => {
it('should validate dashboard response schema', async () => {
await supertest
.get(`${baseApiUrl}/dashboard/b70c7ae0-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down Expand Up @@ -240,7 +240,7 @@ export default function ({ getService }) {
});
});

describe('visualizations', async () => {
describe('visualizations', () => {
it('should validate visualization response schema', async () => {
await supertest
.get(`${baseApiUrl}/visualization/a42c0580-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down Expand Up @@ -320,7 +320,7 @@ export default function ({ getService }) {
});
});

describe('index patterns', async () => {
describe('index patterns', () => {
it('should validate visualization response schema', async () => {
await supertest
.get(`${baseApiUrl}/index-pattern/8963ca30-3224-11e8-a572-ffca06da1357?${defaultQuery}`)
Expand Down
Expand Up @@ -29,7 +29,7 @@ export default function ({ getService, getPageObjects }) {
const browser = getService('browser');
const dashboardAddPanel = getService('dashboardAddPanel');

describe('create and add embeddables', async () => {
describe('create and add embeddables', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});
Expand Down
8 changes: 4 additions & 4 deletions test/functional/apps/dashboard/dashboard_filter_bar.js
Expand Up @@ -27,12 +27,12 @@ export default function ({ getService, getPageObjects }) {
const pieChart = getService('pieChart');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize']);

describe('dashboard filter bar', async () => {
describe('dashboard filter bar', () => {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});

describe('Add a filter bar', async function () {
describe('Add a filter bar', function () {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});
Expand All @@ -50,7 +50,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('filter editor field list', async function () {
describe('filter editor field list', function () {
this.tags(['skipFirefox']);

before(async () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('filter pills', async function () {
describe('filter pills', function () {
before(async () => {
await filterBar.ensureFieldEditorModalIsClosed();
await PageObjects.dashboard.gotoDashboardLandingPage();
Expand Down
10 changes: 5 additions & 5 deletions test/functional/apps/dashboard/dashboard_filtering.js
Expand Up @@ -34,12 +34,12 @@ export default function ({ getService, getPageObjects }) {
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize']);

describe('dashboard filtering', async () => {
describe('dashboard filtering', () => {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});

describe('adding a filter that excludes all data', async () => {
describe('adding a filter that excludes all data', () => {
before(async () => {
await PageObjects.dashboard.clickNewDashboard();
await PageObjects.dashboard.setTimepickerInDataRange();
Expand Down Expand Up @@ -105,7 +105,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('using a pinned filter that excludes all data', async () => {
describe('using a pinned filter that excludes all data', () => {
before(async () => {
await filterBar.toggleFilterPinned('bytes');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -167,7 +167,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('disabling a filter unfilters the data on', async () => {
describe('disabling a filter unfilters the data on', () => {
before(async () => {
await filterBar.toggleFilterEnabled('bytes');
await PageObjects.header.waitUntilLoadingHasFinished();
Expand Down Expand Up @@ -224,7 +224,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('nested filtering', async () => {
describe('nested filtering', () => {
before(async () => {
await PageObjects.dashboard.gotoDashboardLandingPage();
});
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/dashboard_listing.js
Expand Up @@ -30,7 +30,7 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.dashboard.initTests();
});

describe('create prompt', async () => {
describe('create prompt', () => {
it('appears when there are no dashboards', async function () {
const promptExists = await PageObjects.dashboard.getCreateDashboardPromptExists();
expect(promptExists).to.be(true);
Expand Down Expand Up @@ -59,7 +59,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('delete', async function () {
describe('delete', function () {
it('default confirm action is cancel', async function () {
await PageObjects.dashboard.searchForDashboardWithName(dashboardName);
await PageObjects.dashboard.checkDashboardListingSelectAllCheckbox();
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/dashboard_options.js
Expand Up @@ -23,7 +23,7 @@ export default function ({ getService, getPageObjects }) {
const retry = getService('retry');
const PageObjects = getPageObjects(['dashboard']);

describe('dashboard data-shared attributes', async () => {
describe('dashboard data-shared attributes', () => {
let originalTitles = [];

before(async () => {
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/dashboard_query_bar.js
Expand Up @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }) {
const queryBar = getService('queryBar');
const PageObjects = getPageObjects(['dashboard', 'discover']);

describe('dashboard query bar', async () => {
describe('dashboard query bar', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('dashboard with filter');
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/dashboard_time.js
Expand Up @@ -56,7 +56,7 @@ export default function ({ getPageObjects, getService }) {
});
});

describe('dashboard with stored timed', async function () {
describe('dashboard with stored timed', function () {
it('is saved with time', async function () {
await PageObjects.dashboard.switchToEditMode();
await PageObjects.timePicker.setAbsoluteRange(fromTime, toTime);
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/embed_mode.js
Expand Up @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
const PageObjects = getPageObjects(['dashboard', 'common']);
const browser = getService('browser');

describe('embed mode', async () => {
describe('embed mode', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/empty_dashboard.js
Expand Up @@ -24,7 +24,7 @@ export default function ({ getService, getPageObjects }) {
const dashboardAddPanel = getService('dashboardAddPanel');
const PageObjects = getPageObjects(['dashboard']);

describe('empty dashboard', async () => {
describe('empty dashboard', () => {
before(async () => {
await PageObjects.dashboard.clickNewDashboard();
});
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/dashboard/full_screen_mode.js
Expand Up @@ -25,7 +25,7 @@ export default function ({ getService, getPageObjects }) {
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard', 'common']);

describe('full screen mode', async () => {
describe('full screen mode', () => {
before(async () => {
await PageObjects.dashboard.loadSavedDashboard('few panels');
});
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/dashboard/view_edit.js
Expand Up @@ -53,7 +53,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('shows lose changes warning', async function () {
describe('shows lose changes warning', function () {
describe('and loses changes on confirmation', function () {
beforeEach(async function () {
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
Expand Down Expand Up @@ -193,7 +193,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('Does not show lose changes warning', async function () {
describe('Does not show lose changes warning', function () {
it('when time changed is not stored with dashboard', async function () {
await PageObjects.dashboard.gotoDashboardEditMode(dashboardName);
await PageObjects.dashboard.saveDashboard(dashboardName, { storeTimeWithDashboard: false });
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/discover/_discover.js
Expand Up @@ -380,7 +380,7 @@ export default function ({ getService, getPageObjects }) {
}
});

describe('query #2, which has an empty time range', async () => {
describe('query #2, which has an empty time range', () => {
const fromTime = '1999-06-11 09:22:11.000';
const toTime = '1999-06-12 11:21:04.000';

Expand All @@ -401,7 +401,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('filter editor', async function () {
describe('filter editor', function () {
it('should add a phrases filter', async function () {
await filterBar.addFilter('extension.raw', 'is one of', 'jpg');
expect(await filterBar.hasFilter('extension.raw', 'jpg')).to.be(true);
Expand Down
4 changes: 2 additions & 2 deletions test/functional/apps/visualize/_markdown_vis.js
Expand Up @@ -29,15 +29,15 @@ export default function ({ getPageObjects, getService }) {
<h3>Inline HTML that should not be rendered as html</h3>
`;

describe('visualize app', async () => {
describe('visualize app', () => {
before(async function () {
await PageObjects.visualize.navigateToNewVisualization();
await PageObjects.visualize.clickMarkdownWidget();
await PageObjects.visualize.setMarkdownTxt(markdown);
await PageObjects.visualize.clickGo();
});

describe('markdown vis', async () => {
describe('markdown vis', () => {

it('should not have inspector enabled', async function () {
await inspector.expectIsNotEnabled();
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_pie_chart.js
Expand Up @@ -28,7 +28,7 @@ export default function ({ getService, getPageObjects }) {
const fromTime = '2015-09-19 06:31:44.000';
const toTime = '2015-09-23 18:31:44.000';

describe('pie chart', async function () {
describe('pie chart', function () {
const vizName1 = 'Visualization PieChart';
before(async function () {
log.debug('navigateToApp visualize');
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_point_series_options.js
Expand Up @@ -185,7 +185,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('x axis labels', async function () {
describe('x axis labels', function () {
const expectedLabels = [
'2015-09-20 00:00',
'2015-09-21 00:00',
Expand Down

0 comments on commit cd19911

Please sign in to comment.