Skip to content

Commit

Permalink
proper undefined route state handling
Browse files Browse the repository at this point in the history
  • Loading branch information
szwarckonrad committed Apr 23, 2024
1 parent 4828655 commit fd68892
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ const getRoleWithoutArtifactPrivilege = (privilegePrefix: string) => {

const visitArtifactTab = (tabId: string) => {
visitPolicyDetailsPage();
clickArtifactTab(tabId);
};

const clickArtifactTab = (tabId: string) => {
cy.get(`#${tabId}`).click();
};

Expand Down Expand Up @@ -135,6 +139,8 @@ describe('Artifact tabs in Policy Details page', { tags: ['@ess', '@serverless']

cy.getByTestSubj('backToOrigin').click();
cy.getByTestSubj('policyDetailsPage').should('exist');
clickArtifactTab(testData.nextTabId); // Make sure the next tab is accessible and backLink doesn't throw errors
cy.getByTestSubj('policyDetailsPage');
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface ArtifactsFixtureType {
title: string;
pagePrefix: string;
tabId: string;
nextTabId: string;
artifactName: string;
privilegePrefix: string;
urlPath: string;
Expand All @@ -46,6 +47,7 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
title: 'Trusted applications',
pagePrefix: 'trustedAppsListPage',
tabId: 'trustedApps',
nextTabId: 'eventFilters',
artifactName: 'Trusted application name',
privilegePrefix: 'trusted_applications_',
create: {
Expand Down Expand Up @@ -142,7 +144,6 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
},
urlPath: 'trusted_apps',
emptyState: 'trustedAppsListPage-emptyState',

createRequestBody: {
list_id: ENDPOINT_ARTIFACT_LISTS.trustedApps.id,
entries: [
Expand Down Expand Up @@ -172,6 +173,7 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
title: 'Event Filters',
pagePrefix: 'EventFiltersListPage',
tabId: 'eventFilters',
nextTabId: 'blocklists',
artifactName: 'Event filter name',
privilegePrefix: 'event_filters_',
create: {
Expand Down Expand Up @@ -274,7 +276,6 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
},
urlPath: 'event_filters',
emptyState: 'EventFiltersListPage-emptyState',

createRequestBody: {
list_id: ENDPOINT_ARTIFACT_LISTS.eventFilters.id,
entries: [
Expand All @@ -292,6 +293,7 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
title: 'Blocklist',
pagePrefix: 'blocklistPage',
tabId: 'blocklists',
nextTabId: 'hostIsolationExceptions',
artifactName: 'Blocklist name',
privilegePrefix: 'blocklist_',
create: {
Expand Down Expand Up @@ -397,7 +399,6 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
},
urlPath: 'blocklist',
emptyState: 'blocklistPage-emptyState',

createRequestBody: {
list_id: ENDPOINT_ARTIFACT_LISTS.blocklists.id,
entries: [
Expand All @@ -421,6 +422,7 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
title: 'Host isolation exceptions',
pagePrefix: 'hostIsolationExceptionsListPage',
tabId: 'hostIsolationExceptions',
nextTabId: 'trustedApps',
artifactName: 'Host Isolation exception name',
privilegePrefix: 'host_isolation_exceptions_',
create: {
Expand Down Expand Up @@ -499,7 +501,6 @@ export const getArtifactsListTestsData = (): ArtifactsFixtureType[] => [
},
urlPath: 'host_isolation_exceptions',
emptyState: 'hostIsolationExceptionsListPage-emptyState',

createRequestBody: {
list_id: ENDPOINT_ARTIFACT_LISTS.hostIsolationExceptions.id,
entries: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ export const PolicyTabs = React.memo(() => {
cancelUnsavedChangesModal,
history,
policyId,
routeState.backLink,
routeState?.backLink,
unsavedChangesModal.showModal,
]
);
Expand Down

0 comments on commit fd68892

Please sign in to comment.