Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
[6.8] [jest] disallow invalid describe calls (elastic#41378) (elastic…
Browse files Browse the repository at this point in the history
…#41490)

* [jest] disallow invalid describe calls (elastic#41378)

* [jest] disallow invalid describe calls

* correct other describe calls

* remove unnecessary glob

* cast decribe names to strings

* remove new async describe function

# Conflicts:
#	.eslintrc.js
#	src/legacy/core_plugins/data/public/filter/filter_manager/filter_manager.test.ts
#	src/legacy/ui/public/courier/fetch/request/serialize_fetch_params/serialize_fetch_params.test.js
#	src/legacy/ui/public/kfetch/kfetch.test.ts
#	test/api_integration/apis/management/saved_objects/relationships.js
#	test/functional/apps/dashboard/create_and_add_embeddables.js
#	test/functional/apps/dashboard/dashboard_filter_bar.js
#	test/functional/apps/dashboard/dashboard_filtering.js
#	test/functional/apps/dashboard/dashboard_listing.js
#	test/functional/apps/dashboard/dashboard_options.js
#	test/functional/apps/dashboard/dashboard_query_bar.js
#	test/functional/apps/dashboard/dashboard_time.js
#	test/functional/apps/dashboard/embed_mode.js
#	test/functional/apps/dashboard/empty_dashboard.js
#	test/functional/apps/dashboard/full_screen_mode.js
#	test/functional/apps/dashboard/view_edit.js
#	test/functional/apps/discover/_discover.js
#	test/functional/apps/visualize/_point_series_options.js
#	test/functional/apps/visualize/_visualize_listing.js
#	x-pack/legacy/plugins/canvas/migrations.test.js
#	x-pack/legacy/plugins/canvas/server/routes/workpad.test.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/grokdebugger/server/lib/license_pre_routing_factory/__tests__/license_pre_routing_factory.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/monitoring/server/lib/elasticsearch_settings/__tests__/find_reason.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/routes/jobs.test.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/api_integration/apis/management/index_lifecycle_management/nodes.js
#	x-pack/test/api_integration/apis/security/roles.js
#	x-pack/test/functional/apps/canvas/smoke_test.js
#	x-pack/test/functional/apps/discover/feature_controls/discover_spaces.ts
#	x-pack/test/functional/apps/maps/documents_source/top_hits.js
#	x-pack/test/functional/apps/maps/es_geo_grid_source.js
#	x-pack/test/functional/apps/rollup_job/rollup_jobs.js
#	x-pack/test/functional/apps/spaces/spaces_selection.ts
#	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 authored Jul 19, 2019
1 parent a65faaf commit ec50f86
Show file tree
Hide file tree
Showing 26 changed files with 51 additions and 41 deletions.
10 changes: 10 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,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 @@ -195,7 +195,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
2 changes: 1 addition & 1 deletion src/legacy/core_plugins/elasticsearch/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ describe('plugins/elasticsearch', function () {
return compact([basePath, path]).join('.');
};

describe(getKey('ssl.verificationMode'), function () {
describe(`${getKey('ssl.verificationMode')}`, function () {
let settings;
let sslSettings;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,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
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function ({ getService }) {
indexPatterns: GENERIC_RESPONSE_SCHEMA,
});

describe('searches', async () => {
describe('searches', () => {
it('should validate search response schema', async () => {
await supertest
.get(`/api/kibana/management/saved_objects/relationships/search/960372e0-3224-11e8-a572-ffca06da1357`)
Expand Down Expand Up @@ -83,7 +83,7 @@ export default function ({ getService }) {
});
});

describe('dashboards', async () => {
describe('dashboards', () => {
const DASHBOARD_RESPONSE_SCHEMA = Joi.object().keys({
visualizations: GENERIC_RESPONSE_SCHEMA,
});
Expand Down Expand Up @@ -126,7 +126,7 @@ export default function ({ getService }) {
});
});

describe('visualizations', async () => {
describe('visualizations', () => {
const VISUALIZATIONS_RESPONSE_SCHEMA = Joi.object().keys({
dashboards: GENERIC_RESPONSE_SCHEMA,
});
Expand Down Expand Up @@ -164,7 +164,7 @@ export default function ({ getService }) {
});
});

describe('index patterns', async () => {
describe('index patterns', () => {
const INDEX_PATTERN_RESPONSE_SCHEMA = Joi.object().keys({
searches: GENERIC_RESPONSE_SCHEMA,
visualizations: GENERIC_RESPONSE_SCHEMA,
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/_tile_map.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,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
2 changes: 1 addition & 1 deletion x-pack/plugins/reporting/server/routes/jobs.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ describe(`when job is completed`, () => {
expect(headers['content-type']).toBe('application/pdf');
});

describe(`when non-whitelisted contentType specified in job output`, async () => {
describe(`when non-whitelisted contentType specified in job output`, () => {
test(`sets statusCode to 500`, async () => {
const { statusCode } = await getCompletedResponse({ outputContentType: 'application/html' });
expect(statusCode).toBe(500);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ test('sets enabled to false when reporting is turned off', async () => {
expect(usageStats.enabled).toBe(false);
});

describe('with a basic license', async () => {
describe('with a basic license', () => {
let usageStats;
beforeAll(async () => {
const serverWithBasicLicenseMock = getServerMock();
Expand All @@ -93,7 +93,7 @@ describe('with a basic license', async () => {
});
});

describe('with no license', async () => {
describe('with no license', () => {
let usageStats;
beforeAll(async () => {
const serverWithNoLicenseMock = getServerMock();
Expand All @@ -116,7 +116,7 @@ describe('with no license', async () => {
});
});

describe('with platinum license', async () => {
describe('with platinum license', () => {
let usageStats;
beforeAll(async () => {
const serverWithPlatinumLicenseMock = getServerMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('getDeprecationLoggingStatus', () => {
});

describe('setDeprecationLogging', () => {
describe('isEnabled = true', async () => {
describe('isEnabled = true', () => {
it('calls cluster.putSettings with logger.deprecation = WARN', async () => {
const callWithRequest = jest.fn();
await setDeprecationLogging(callWithRequest, {} as any, true);
Expand All @@ -31,7 +31,7 @@ describe('setDeprecationLogging', () => {
});
});

describe('isEnabled = false', async () => {
describe('isEnabled = false', () => {
it('calls cluster.putSettings with logger.deprecation = ERROR', async () => {
const callWithRequest = jest.fn();
await setDeprecationLogging(callWithRequest, {} as any, false);
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/api_integration/apis/security/roles.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default function ({ getService }) {
});
});

it(`should ${basic ? 'not' : ''} create a role with kibana and FLS/DLS elasticsearch
it(`should ${basic ? 'not' : ''} create a role with kibana and FLS/DLS elasticsearch
privileges on ${basic ? 'basic' : 'trial'} licenses`, async () => {
await supertest.put('/api/security/role/role_with_privileges_dls_fls')
.set('kbn-xsrf', 'xxx')
Expand Down Expand Up @@ -191,7 +191,7 @@ export default function ({ getService }) {
});
});

it(`should ${basic ? 'not' : ''} update a role adding DLS and TLS priviledges
it(`should ${basic ? 'not' : ''} update a role adding DLS and TLS priviledges
when using ${basic ? 'basic' : 'trial'} license`, async () => {

await es.shield.putRole({
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/canvas/smoke_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function canvasSmokeTest({ getService, getPageObjects }) {
const log = getService('log');
const PageObjects = getPageObjects(['common']);

describe('smoke test', async () => {
describe('smoke test', () => {
const workpadListSelector = 'canvasWorkpadLoaderTable canvasWorkpadLoaderWorkpad';
const testWorkpadId = 'workpad-1705f884-6224-47de-ba49-ca224fe6ec31';

Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/apps/maps/es_geo_grid_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default function ({ getPageObjects, getService }) {

function makeRequestTestsForGeoPrecision(LAYER_ID) {

describe('geoprecision - requests', async () => {
describe('geoprecision - requests', () => {
let beforeTimestamp;
beforeEach(async () => {
await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1);
Expand All @@ -48,7 +48,7 @@ export default function ({ getPageObjects, getService }) {
});
});

describe('geoprecision - data', async ()=> {
describe('geoprecision - data', ()=> {

beforeEach(async () => {
await PageObjects.maps.setView(DATA_CENTER_LAT, DATA_CENTER_LON, 1);
Expand Down
14 changes: 7 additions & 7 deletions x-pack/test/functional/apps/maps/layer_errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function ({ getPageObjects }) {
await PageObjects.maps.loadSavedMap('layer with errors');
});

describe('ESSearchSource with missing index pattern id', async () => {
describe('ESSearchSource with missing index pattern id', () => {
const MISSING_INDEX_ID = 'idThatDoesNotExitForESSearchSource';
const LAYER_NAME = MISSING_INDEX_ID;

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

describe('ESGeoGridSource with missing index pattern id', async () => {
describe('ESGeoGridSource with missing index pattern id', () => {
const MISSING_INDEX_ID = 'idThatDoesNotExitForESGeoGridSource';
const LAYER_NAME = MISSING_INDEX_ID;

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

describe('ESJoinSource with missing index pattern id', async () => {
describe('ESJoinSource with missing index pattern id', () => {
const MISSING_INDEX_ID = 'idThatDoesNotExitForESJoinSource';
const LAYER_NAME = 'geo_shapes*';

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

describe('EMSFileSource with missing EMS id', async () => {
describe('EMSFileSource with missing EMS id', () => {
const MISSING_EMS_ID = 'idThatDoesNotExitForEMSFileSource';
const LAYER_NAME = 'EMS_vector_shapes';

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

describe('EMSTMSSource with missing EMS id', async () => {
describe('EMSTMSSource with missing EMS id', () => {
const MISSING_EMS_ID = 'idThatDoesNotExitForEMSTile';
const LAYER_NAME = 'EMS_tiles';

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

describe('KibanaRegionmapSource with missing region map configuration', async () => {
describe('KibanaRegionmapSource with missing region map configuration', () => {
const MISSING_REGION_NAME = 'nameThatDoesNotExitForKibanaRegionmapSource';
const LAYER_NAME = 'Custom_vector_shapes';

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

describe('KibanaTilemapSource with missing map.tilemap.url configuration', async () => {
describe('KibanaTilemapSource with missing map.tilemap.url configuration', () => {
const LAYER_NAME = 'Custom_TMS';

it('should diplay error message in layer panel', async () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/monitoring/cluster/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export default function ({ getService, getPageObjects }) {
});
});

describe('alert actions take you to the elasticsearch indices listing', async () => {
describe('alert actions take you to the elasticsearch indices listing', () => {
const { setup, tearDown } = getLifecycleMethods(getService, getPageObjects);

before(async () => {
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/rollup_job/rollup_jobs.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export default function ({ getService, getPageObjects }) {
const log = getService('log');
const PageObjects = getPageObjects(['security', 'rollup', 'common', 'header']);

describe('rollup job', async () => {
describe('rollup job', () => {
before(async () => {
// init data
await Promise.all([
Expand Down
4 changes: 2 additions & 2 deletions x-pack/test/functional/apps/security/management.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export default function ({ getService, getPageObjects }) {
await PageObjects.settings.navigateTo();
});

describe('Security', async () => {
describe('navigation', async () => {
describe('Security', () => {
describe('navigation', () => {
it('Can navigate to create user section', async () => {
await PageObjects.security.clickElasticsearchUsers();
await PageObjects.security.clickCreateNewUser();
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/functional/apps/security/rbac_phase1.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function ({ getService, getPageObjects }) {
const browser = getService('browser');
const kibanaServer = getService('kibanaServer');

describe('rbac ', async function () {
describe('rbac ', function () {
before(async () => {
await browser.setWindowSize(1600, 1000);
log.debug('users');
Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/reporting/api/bwc_existing_indexes.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default function ({ getService }) {
const reportingAPI = getService('reportingAPI');
const usageAPI = getService('usageAPI');

describe('BWC report generation into existing indexes', async () => {
describe('BWC report generation into existing indexes', () => {
let expectedCompletedReportCount;
let cleanupIndexAlias;

Expand Down
2 changes: 1 addition & 1 deletion x-pack/test/spaces_api_integration/common/suites/delete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export function deleteTestSuiteFactory(es: any, esArchiver: any, supertest: Supe
.then(tests.exists.response);
});

describe(`when the space is reserved`, async () => {
describe(`when the space is reserved`, () => {
it(`should return ${tests.reservedSpace.statusCode}`, async () => {
return supertest
.delete(`${getUrlPrefix(spaceId)}/api/spaces/space/default`)
Expand Down

0 comments on commit ec50f86

Please sign in to comment.