kibana/x-pack/test_serverless/shared/lib/cases/helpers.ts
Sergi Massaneda c40c2e6f59
[Security Solution] Enable shared-ux nav (#169499)
## Summary

Makes the shared-ux navigation the default side navigation component for
Security projects.

The old Security navigation component and the experimental flag will be
removed altogether in a separate PR.

There is no visual difference from the previous navigation:


![snapshot](2896e8de-45eb-412f-b319-e919e65a0ae7)

---------

Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
2023-10-25 09:20:04 -07:00

80 lines
2.4 KiB
TypeScript

/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/
import { SECURITY_SOLUTION_OWNER } from '@kbn/cases-plugin/common';
import { AppDeepLinkId } from '@kbn/core-chrome-browser';
import { FtrProviderContext } from '../../../functional/ftr_provider_context';
export const createOneCaseBeforeDeleteAllAfter = (
getPageObject: FtrProviderContext['getPageObject'],
getService: FtrProviderContext['getService'],
owner: string
) => {
const svlCases = getService('svlCases');
before(async () => {
await createAndNavigateToCase(getPageObject, getService, owner);
});
after(async () => {
await svlCases.api.deleteAllCaseItems();
});
};
export const createOneCaseBeforeEachDeleteAllAfterEach = (
getPageObject: FtrProviderContext['getPageObject'],
getService: FtrProviderContext['getService'],
owner: string
) => {
const svlCases = getService('svlCases');
beforeEach(async () => {
await createAndNavigateToCase(getPageObject, getService, owner);
});
afterEach(async () => {
await svlCases.api.deleteAllCaseItems();
});
};
export const createAndNavigateToCase = async (
getPageObject: FtrProviderContext['getPageObject'],
getService: FtrProviderContext['getService'],
owner: string
) => {
const cases = getService('cases');
const header = getPageObject('header');
await navigateToCasesApp(getPageObject, getService, owner);
const theCase = await cases.api.createCase({ owner });
await cases.casesTable.waitForCasesToBeListed();
await cases.casesTable.goToFirstListedCase();
await header.waitUntilLoadingHasFinished();
return theCase;
};
export const navigateToCasesApp = async (
getPageObject: FtrProviderContext['getPageObject'],
getService: FtrProviderContext['getService'],
owner: string
) => {
const common = getPageObject('common');
const svlCommonNavigation = getPageObject('svlCommonNavigation');
await common.navigateToApp('landingPage');
if (owner === SECURITY_SOLUTION_OWNER) {
await svlCommonNavigation.sidenav.clickLink({
deepLinkId: 'securitySolutionUI:cases' as AppDeepLinkId,
});
} else {
await svlCommonNavigation.sidenav.clickLink({ deepLinkId: 'observability-overview:cases' });
}
};