Skip to content

Commit

Permalink
[7.x] [jest] disallow invalid describe calls (#41378) (#41483)
Browse files Browse the repository at this point in the history
* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	x-pack/legacy/plugins/index_management/__jest__/client_integration/home.test.ts
#	x-pack/test/functional/apps/uptime/monitor.ts
  • Loading branch information
Spencer authored Jul 18, 2019
1 parent 7995d77 commit 68f1441
Show file tree
Hide file tree
Showing 60 changed files with 103 additions and 93 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ describe('filter_manager', () => {
});
});

describe('add filters', async () => {
describe('add filters', () => {
test('app state should accept a single filter', async function() {
updateSubscription = filterManager.getUpdates$().subscribe(updateListener);
const f1 = getFilter(FilterStateStore.APP_STATE, false, false, 'age', 34);
Expand Down Expand Up @@ -535,7 +535,7 @@ describe('filter_manager', () => {
});
});

describe('remove filters', async () => {
describe('remove filters', () => {
test('remove on empty should do nothing and not fire events', async () => {
updateSubscription = filterManager.getUpdates$().subscribe(updateListener);
await filterManager.removeAll();
Expand Down
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,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 @@ -348,7 +348,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 @@ -381,7 +381,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@ export default function ({ getService, getPageObjects }) {
const dashboardPanelActions = getService('dashboardPanelActions');
const PageObjects = getPageObjects(['dashboard', 'header', 'visualize']);

describe('dashboard filtering', async function () {
describe('dashboard filtering', function () {
this.tags('smoke');
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 @@ -107,7 +107,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 @@ -169,7 +169,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 @@ -227,7 +227,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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('timezones', async function () {
describe('timezones', function () {
const expectedLabels = [
'2015-09-20 00:00',
'2015-09-21 00:00',
Expand Down
2 changes: 1 addition & 1 deletion test/functional/apps/visualize/_tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ export default function ({ getService, getPageObjects }) {

});

describe('Only request data around extent of map option', async () => {
describe('Only request data around extent of map option', () => {

it('when checked adds filters to aggregation', async () => {
const vizName1 = 'Visualization TileMap';
Expand Down
Loading

0 comments on commit 68f1441

Please sign in to comment.