Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions ui/apps/platform/cypress/helpers/title.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/*
* Return regular expression to assert page title independent of product branding in testing environment.
*/
export function getRegExpForTitleWithBranding(title) {
return new RegExp(`^${title} | (Red Hat Advanced Cluster Security|StackRox)$`);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '../../constants/apiEndpoints';

import withAuth from '../../helpers/basicAuth';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

const h1 = 'Access Control';
const h2 = 'Access scopes';
Expand Down Expand Up @@ -41,6 +42,9 @@ describe('Access Control Access scopes', () => {
it('list has headings, link, button, and table head cells, and no breadcrumbs', () => {
visitAccessScopes();

// Table has plural noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - ${h2}`));

cy.get(selectors.breadcrumbNav).should('not.exist');

cy.get(selectors.h1).should('have.text', h1);
Expand Down Expand Up @@ -68,6 +72,9 @@ describe('Access Control Access scopes', () => {
const name = 'Deny All';
cy.get(`${selectors.list.tdNameLink}:contains("${name}")`).click();

// Form has singular noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - Access scope`));

cy.get(`${selectors.breadcrumbItem}:nth-child(1):contains("${h2}")`);
cy.get(`${selectors.breadcrumbItem}:nth-child(2):contains("${name}")`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
import * as api from '../../constants/apiEndpoints';
import sampleCert from '../../helpers/sampleCert';
import { generateNameWithDate, getInputByLabel } from '../../helpers/formHelpers';
import { getRegExpForTitleWithBranding } from '../../helpers/title';
import { visit, visitWithStaticResponseForPermissions } from '../../helpers/visit';
import updateMinimumAccessRoleRequest from '../../fixtures/auth/updateMinimumAccessRole.json';

Expand Down Expand Up @@ -70,6 +71,9 @@ describe('Access Control Auth providers', () => {
};
visitAuthProviders(staticResponseMap);

// Table has plural noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - ${h2}`));

cy.get(`${selectors.list.th}:contains("Name")`);
cy.get(`${selectors.list.th}:contains("Type")`);
cy.get(`${selectors.list.th}:contains("Minimum access role")`);
Expand All @@ -84,6 +88,9 @@ describe('Access Control Auth providers', () => {
cy.get(selectors.list.createButton).click();
cy.get(`${selectors.list.authProviders.createDropdownItem}:contains("${type}")`).click();

// Form has singular noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - Auth provider`));

cy.get(`${selectors.breadcrumbItem}:nth-child(1):contains("${h2}")`);
cy.get(`${selectors.breadcrumbItem}:nth-child(2):contains("Create ${type} provider")`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
} from '../../constants/apiEndpoints';

import withAuth from '../../helpers/basicAuth';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

const h1 = 'Access Control';
const h2 = 'Permission sets';
Expand Down Expand Up @@ -47,6 +48,9 @@ describe('Access Control Permission sets', () => {
it('list has headings, link, button, and table head cells, and no breadcrumbs', () => {
visitPermissionSets();

// Table has plural noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - ${h2}`));

cy.get(selectors.breadcrumbNav).should('not.exist');

cy.get(selectors.h1).should('have.text', h1);
Expand Down Expand Up @@ -74,6 +78,9 @@ describe('Access Control Permission sets', () => {
const name = 'Admin';
cy.get(`${selectors.list.tdNameLink}:contains("${name}")`).click();

// Form has singular noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - Permission set`));

cy.get(`${selectors.breadcrumbItem}:nth-child(1):contains("${h2}")`);
cy.get(`${selectors.breadcrumbItem}:nth-child(2):contains("${name}")`);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { rolesUrl, selectors } from '../../constants/AccessControlPage';
import { permissions as permissionsApi } from '../../constants/apiEndpoints';

import withAuth from '../../helpers/basicAuth';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

// Migration from cy.server and cy.route to cy.intercept fails for /v1/roles/* imported from apiEndpoints.
const rolesApi = {
Expand Down Expand Up @@ -49,6 +50,9 @@ describe('Access Control Roles', () => {
it('list has headings, link, button, and table head cells, and no breadcrumbs', () => {
visitRoles();

// Table has plural noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - ${h2}`));

cy.get(selectors.breadcrumbNav).should('not.exist');

cy.get(selectors.h1).should('have.text', h1);
Expand Down Expand Up @@ -85,6 +89,9 @@ describe('Access Control Roles', () => {
const name = 'Admin';
cy.get(`${selectors.list.tdNameLink}:contains("${name}")`).click();

// Form has singular noun in title.
cy.title().should('match', getRegExpForTitleWithBranding(`${h1} - Role`));

cy.get(selectors.h1).should('not.exist');
cy.get(selectors.navLinkCurrent).should('not.exist');

Expand Down
4 changes: 4 additions & 0 deletions ui/apps/platform/cypress/integration/apiReference.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import withAuth from '../helpers/basicAuth';
import { visitMainDashboard } from '../helpers/main';
import { interactAndWaitForResponses } from '../helpers/request';
import { getRegExpForTitleWithBranding } from '../helpers/title';
import { visit } from '../helpers/visit';

const apiReferencePath = '/main/apidocs';
Expand Down Expand Up @@ -34,5 +35,8 @@ describe('API Reference', () => {
visit(apiReferencePath, requestConfig);

cy.get(`h1:contains("${title}")`);

// Exception to pattern of separate test for title, because API Reference loads so slowly.
cy.title().should('match', getRegExpForTitleWithBranding(title));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {
visitClusterByNameWithFixtureMetadataDatetime,
} from '../../helpers/clusters';
import { hasFeatureFlag } from '../../helpers/features';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

describe('Clusters page', () => {
withAuth();
Expand All @@ -26,9 +27,11 @@ describe('Clusters page', () => {
cy.get(selectors.autoUpgradeInput);
});

it('should display all the columns expected in clusters list page', () => {
it('should display title and columns expected in clusters list page', () => {
visitClusters();

cy.title().should('match', getRegExpForTitleWithBranding('Clusters'));

[
'Name',
'Cloud Provider',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
visitCollectionsFromLeftNav,
} from '../../helpers/collections';
import { hasFeatureFlag } from '../../helpers/features';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

// Mock responses until endpoints are implemented.

Expand Down Expand Up @@ -38,9 +39,11 @@ describe('Collections table', () => {
visitCollections(staticResponseMap);
});

it('should have table column headings', () => {
it('should have plural title and table column headings', () => {
visitCollections(staticResponseMap);

cy.title().should('match', getRegExpForTitleWithBranding('Collections'));

cy.get('th:contains("Collection")');
cy.get('th:contains("Description")');
cy.get('th:contains("In use")');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
visitComplianceDashboard,
visitComplianceEntities,
} from '../../helpers/compliance';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

describe('Compliance dashboard page', () => {
withAuth();
Expand All @@ -14,6 +15,12 @@ describe('Compliance dashboard page', () => {
scanCompliance(); // prerequisite for the following tests
});

it('should have title', () => {
visitComplianceDashboard();

cy.title().should('match', getRegExpForTitleWithBranding('Compliance'));
});

it('should show the same amount of clusters between the Dashboard and List Page', () => {
visitComplianceDashboard();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
interactAndWaitForConfigurationManagementScan,
visitConfigurationManagementDashboard,
} from '../../helpers/configWorkflowUtils';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

// This function is more generic than its name implies.
const policyViolationsBySeverityLinkShouldMatchList = (linkSelector, linkRegExp, keyPlural) => {
Expand All @@ -25,6 +26,12 @@ const policyViolationsBySeverityLinkShouldMatchList = (linkSelector, linkRegExp,
describe('Configuration Management Dashboard', () => {
withAuth();

it('should have title', () => {
visitConfigurationManagementDashboard();

cy.title().should('match', getRegExpForTitleWithBranding('Configuration Management'));
});

it('should show same number of policies between the tile and the policies list', () => {
const entitiesKey = 'policies';

Expand Down
57 changes: 0 additions & 57 deletions ui/apps/platform/cypress/integration/general.test.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import * as api from '../../constants/apiEndpoints';
import { url as dashboardUrl } from '../../constants/DashboardPage';
import { labels, selectors, url } from '../../constants/IntegrationsPage';
import withAuth from '../../helpers/basicAuth';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

function getIntegrationTypeUrl(integrationSource, integrationType) {
return `${url}/${integrationSource}/${integrationType}`;
Expand Down Expand Up @@ -33,6 +34,12 @@ function visitIntegrations() {
describe('Integrations page', () => {
withAuth();

it('should have title', () => {
visitIntegrations();

cy.title().should('match', getRegExpForTitleWithBranding('Integrations'));
});

it('Plugin tiles should all be the same height', () => {
visitIntegrations();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
visitNetworkGraphWithMockedData,
visitNetworkGraphWithNamespaceFilter,
} from '../../helpers/networkGraph';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

function uploadYAMLFile(fileName, selector) {
cy.intercept('POST', api.network.simulate).as('postNetworkPolicySimulate');
Expand All @@ -31,7 +32,6 @@ describe('Network page', () => {

it('should visit using the left nav', () => {
visitNetworkGraphFromLeftNav();
cy.get('h1:contains("Network Graph")');
});

it('should have selected item in nav bar', () => {
Expand All @@ -42,6 +42,12 @@ describe('Network page', () => {
);
});

it('should have title', () => {
visitNetworkGraph();

cy.title().should('match', getRegExpForTitleWithBranding('Network Graph'));
});

it('should display a legend', () => {
visitNetworkGraphWithMockedData();

Expand Down
5 changes: 4 additions & 1 deletion ui/apps/platform/cypress/integration/risk/risk.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import {
callbackForPairOfAscendingNumberValuesFromElements,
callbackForPairOfDescendingNumberValuesFromElements,
} from '../../helpers/sort';
import { getRegExpForTitleWithBranding } from '../../helpers/title';

describe('Risk page', () => {
withAuth();
Expand All @@ -25,9 +26,11 @@ describe('Risk page', () => {
cy.get(RiskPageSelectors.risk).should('have.class', 'pf-m-current');
});

it('should have table columns', () => {
it('should have title and table column headings', () => {
visitRiskDeployments();

cy.title().should('match', getRegExpForTitleWithBranding('Risk'));

cy.get('.rt-th:contains("Name")');
cy.get('.rt-th:contains("Created")');
cy.get('.rt-th:contains("Cluster")');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import withAuth from '../../helpers/basicAuth';
import { visitSystemHealth, visitSystemHealthFromLeftNav } from '../../helpers/systemHealth';
import { getRegExpForTitleWithBranding } from '../../helpers/title';
import navSelectors from '../../selectors/navigation';

describe('System Health general', () => {
describe('System Health', () => {
withAuth();

it('should visit from left nav', () => {
Expand All @@ -18,4 +19,10 @@ describe('System Health general', () => {
'pf-m-current'
);
});

it('should have title', () => {
visitSystemHealth();

cy.title().should('match', getRegExpForTitleWithBranding('System Health'));
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,13 @@ describe('System Health general', () => {
'pf-m-current'
);
});

// TODO Component needs to render PageTitle element.
/*
it('should have title', () => {
visitSystemHealth();

cy.title().should('match', getRegExpForTitleWithBranding('System Health'));
});
*/
});
Loading