Skip to content

Commit

Permalink
Merge pull request rancher#9360 from richard-cox/fix-tests-for-standa…
Browse files Browse the repository at this point in the history
…rd-user

Re-enable standard user page not found tests
  • Loading branch information
richard-cox authored Jul 21, 2023
2 parents 6eb7d60 + ff065e5 commit f6b2491
Show file tree
Hide file tree
Showing 21 changed files with 549 additions and 281 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ jobs:
- name: Run standard user tests
if: ${{ success() || failure() }}
run: |
yarn e2e:prod && yarn docker:local:stop
yarn e2e:prod
yarn docker:local:stop
mkdir -p coverage-artifacts/coverage
cp coverage/e2e/coverage-final.json coverage-artifacts/coverage/coverage-e2e.json
env:
Expand Down
17 changes: 14 additions & 3 deletions cypress/e2e/po/components/sortable-table.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ export default class SortableTablePo extends ComponentPo {
return new ListRowPo(this.rowElementWithName(name));
}

rowNames() {
return this.rowElements().find('.cluster-link').then(($els: any) => {
/**
* Get rows names. To avoid the 'no rows' on first load use `noRowsShouldNotExist`
*/
rowNames(rowNameSelector = 'td:nth-of-type(3)') {
return this.rowElements().find(rowNameSelector).then(($els: any) => {
return (
Cypress.$.makeArray($els).map((el: any) => el.innerText)
Cypress.$.makeArray<string>($els).map((el: any) => el.innerText as string)
);
});
}
Expand All @@ -103,6 +106,14 @@ export default class SortableTablePo extends ComponentPo {
return new ActionMenuPo();
}

noRowsShouldNotExist() {
return this.noRowsText().should('not.exist');
}

noRowsText() {
return this.self().find('tbody').find('.no-rows');
}

/**
* Check row element count on sortable table
* @param isEmpty true if empty state expected (empty state message should display on row 1)
Expand Down
20 changes: 17 additions & 3 deletions cypress/e2e/po/pages/extensions.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ import ActionMenuPo from '@/cypress/e2e/po/components/action-menu.po';
import NameNsDescriptionPo from '@/cypress/e2e/po/components/name-ns-description.po';
import ReposListPagePo from '@/cypress/e2e/po/pages/repositories.po';
import AppClusterRepoEditPo from '@/cypress/e2e/po/edit/catalog.cattle.io.clusterrepo.po';
import BannersPo from '~/cypress/e2e/po/components/banners.po';

export default class ExtensionsPo extends PagePo {
export default class ExtensionsPagePo extends PagePo {
static url = '/c/local/uiplugins'
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(ExtensionsPo.url);
return super.goTo(ExtensionsPagePo.url);
}

extensionTabs: TabbedPo;

constructor() {
super(ExtensionsPo.url);
super(ExtensionsPagePo.url);

this.extensionTabs = new TabbedPo('[data-testid="extension-tabs"]');
}
Expand All @@ -28,6 +29,14 @@ export default class ExtensionsPo extends PagePo {
return this.self().getId('extensions-page-title').invoke('text');
}

waitForTitle() {
return this.title().should('contain', 'Extensions');
}

loading() {
return this.self().get('.data-loading');
}

/**
* install extensions operator
*/
Expand Down Expand Up @@ -204,6 +213,11 @@ export default class ExtensionsPo extends PagePo {
return this.extensionReloadBanner().getId('extension-reload-banner-reload-btn').click();
}

// ------------------ new repos banner ------------------
repoBanner() {
return new BannersPo('[data-testid="extensions-new-repos-banner"]', this.self());
}

// ------------------ extension menu ------------------
private extensionMenu() {
return this.self().getId('extensions-page-menu');
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/po/pages/extensions/kubewarden.po.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import ExtensionsPo from '@/cypress/e2e/po/pages/extensions.po';
import ExtensionsPagePo from '@/cypress/e2e/po/pages/extensions.po';

export default class KubewardenExtensionPo extends PagePo {
private static createPath(clusterId: string) {
Expand All @@ -16,7 +16,7 @@ export default class KubewardenExtensionPo extends PagePo {

/** add ui-plugin-charts repository */
addChartsRepoIfNeeded(): void {
const extensionsPo: ExtensionsPo = new ExtensionsPo();
const extensionsPo: ExtensionsPagePo = new ExtensionsPagePo();

extensionsPo.waitForPage();

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/po/pages/home.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default class HomePagePo extends PagePo {
return new HomeClusterListPo('[data-testid="cluster-list-container"]');
}

manangeButton() {
manageButton() {
return cy.getId('cluster-management-manage-button');
}

Expand Down
19 changes: 12 additions & 7 deletions cypress/e2e/po/side-bars/user-menu.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,16 @@ export default class UserMenuPo extends ComponentPo {
}

/**
* Toggle user menu
* @returns
* Open the user menu
*
* Multiple clicks because sometimes just one ... isn't enough
*
*/
toggle(): Cypress.Chainable {
return this.self().click();
open(): Cypress.Chainable {
this.self().click();
this.self().click();
this.self().click();
this.self().click();
}

/**
Expand All @@ -56,12 +61,12 @@ export default class UserMenuPo extends ComponentPo {
if ($el.attr('style')?.includes('visibility: hidden')) {
cy.log('User Avatar open but hidden, giving it a nudge');

return this.toggle();
return this.open();
}
} else {
cy.log('User Avatar not open, opening');

return this.toggle();
return this.open();
}
})
.then(() => this.isOpen());
Expand All @@ -87,7 +92,7 @@ export default class UserMenuPo extends ComponentPo {
* @param label
* @returns
*/
clickMenuItem(label: string) {
clickMenuItem(label: 'Preferences' | 'Account & API Keys' | 'Log Out') {
this.ensureOpen().then(() => {
return this.getMenuItems().contains(label).click();
});
Expand Down
28 changes: 14 additions & 14 deletions cypress/e2e/tests/navigation/not-found-page.spec.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import NotFoundPagePo from '@/cypress/e2e/po/pages/not-found-page.po';
import ClusterManagerListPagePo from '~/cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po';
import { WorkloadsPodsListPagePo } from '~/cypress/e2e/po/pages/explorer/workloads-pods.po';
import WorkloadListPagePo from '~/cypress/e2e/po/pages/explorer/workloads.po';
import HomePagePo from '~/cypress/e2e/po/pages/home.po';
import PagePo from '~/cypress/e2e/po/pages/page.po';
import ClusterManagerListPagePo from '@/cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po';
import { WorkloadsPodsListPagePo } from '@/cypress/e2e/po/pages/explorer/workloads-pods.po';
import WorkloadListPagePo from '@/cypress/e2e/po/pages/explorer/workloads.po';
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import PagePo from '@/cypress/e2e/po/pages/page.po';

describe('Not found page display', () => {
describe('Not found page display', { tags: ['@adminUser', '@standardUser'] }, () => {
beforeEach(() => {
cy.login();
});

it('Will show a 404 if we do not have a valid Product id on the route path', { tags: ['@adminUser', '@standardUser'] }, () => {
it('Will show a 404 if we do not have a valid Product id on the route path', () => {
const notFound = new NotFoundPagePo('/c/_/bogus-product-id');

notFound.goTo();
Expand All @@ -20,7 +20,7 @@ describe('Not found page display', () => {
notFound.errorMessage().contains('Product bogus-product-id not found');
});

it('Will show a 404 if we do not have a valid Resource type on the route path', { tags: ['@adminUser', '@standardUser'] }, () => {
it('Will show a 404 if we do not have a valid Resource type on the route path', () => {
const notFound = new NotFoundPagePo('/c/_/manager/bogus-resource-type');

notFound.goTo();
Expand All @@ -30,7 +30,7 @@ describe('Not found page display', () => {
notFound.errorMessage().contains('Resource type bogus-resource-type not found');
});

it('Will show a 404 if we do not have a valid Resource id on the route path', { tags: ['@adminUser', '@standardUser'] }, () => {
it('Will show a 404 if we do not have a valid Resource id on the route path', () => {
const notFound = new NotFoundPagePo('/c/_/manager/provisioning.cattle.io.cluster/fleet-default/bogus-resource-id');

notFound.goTo();
Expand All @@ -40,7 +40,7 @@ describe('Not found page display', () => {
notFound.errorMessage().contains('Resource provisioning.cattle.io.cluster with id fleet-default/bogus-resource-id not found, unable to display resource details');
});

it('Will show a 404 if we do not have a valid product + resource + resource id', { tags: ['@adminUser', '@standardUser'] }, () => {
it('Will show a 404 if we do not have a valid product + resource + resource id', () => {
const notFound = new NotFoundPagePo('/c/_/bogus-product-id/bogus-resource/bogus-resource-id');

notFound.goTo();
Expand All @@ -50,31 +50,31 @@ describe('Not found page display', () => {
notFound.errorMessage().contains('Product bogus-product-id not found');
});

it('Will not show a 404 if we have a valid product + resource', { tags: ['@adminUser', '@standardUser'] }, () => {
it('Will not show a 404 if we have a valid product + resource', () => {
const clusterManager = new NotFoundPagePo('/c/_/manager/provisioning.cattle.io.cluster');

clusterManager.goTo();
clusterManager.waitForPage();
clusterManager.errorTitle().should('not.exist');
});

it('Will not show a 404 for a valid type from the Norman API', { tags: ['@adminUser', '@standardUser'] }, () => {
it('Will not show a 404 for a valid type from the Norman API', () => {
const cloudCredCreatePage = new NotFoundPagePo('/c/_/manager/cloudCredential/create');

cloudCredCreatePage.goTo();
cloudCredCreatePage.waitForPage();
cloudCredCreatePage.errorTitle().should('not.exist');
});

it('Will not show a 404 for a valid type that does not have a real schema', { tags: '@adminUser' }, () => {
it('Will not show a 404 for a valid type that does not have a real schema', () => {
const workloadPage = new NotFoundPagePo('/c/local/explorer/workload');

workloadPage.goTo();
workloadPage.waitForPage();
workloadPage.errorTitle().should('not.exist');
});

it('Will not show a 404 if we have a valid product + resource and we nav to page', { tags: '@adminUser' }, () => {
it('Will not show a 404 if we have a valid product + resource and we nav to page', () => {
const page = new PagePo('');
const homePage = new HomePagePo();
const notFoundPage = new NotFoundPagePo('');
Expand Down
8 changes: 4 additions & 4 deletions cypress/e2e/tests/pages/cluster-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,15 +120,15 @@ describe('Cluster Manager', { tags: '@adminUser' }, () => {
clusterList.sortableTable().rowElementWithName(rke2CustomName).should('exist', { timeout: 15000 });
clusterList.list().actionMenu(rke2CustomName).getMenuItem('Delete').click();

clusterList.sortableTable().rowNames().then((rows: any) => {
clusterList.sortableTable().rowNames('.cluster-link').then((rows: any) => {
const promptRemove = new PromptRemove();

promptRemove.confirm(rke2CustomName);
promptRemove.remove();

clusterList.waitForPage();
clusterList.sortableTable().checkRowCount(false, rows.length - 1);
clusterList.sortableTable().rowNames().should('not.contain', rke2CustomName);
clusterList.sortableTable().rowNames('.cluster-link').should('not.contain', rke2CustomName);
});
});
});
Expand Down Expand Up @@ -257,15 +257,15 @@ describe('Cluster Manager', { tags: '@adminUser' }, () => {
clusterList.sortableTable().bulkActionDropDownOpen();
clusterList.sortableTable().bulkActionDropDownButton('Delete').click();

clusterList.sortableTable().rowNames().then((rows: any) => {
clusterList.sortableTable().rowNames('.cluster-link').then((rows: any) => {
const promptRemove = new PromptRemove();

promptRemove.confirm(importGenericName);
promptRemove.remove();

clusterList.waitForPage();
clusterList.sortableTable().checkRowCount(false, rows.length - 1);
clusterList.sortableTable().rowNames().should('not.contain', importGenericName);
clusterList.sortableTable().rowNames('.cluster-link').should('not.contain', importGenericName);
});
});
});
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/tests/pages/explorer/api/api-services.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ describe('Cluster Explorer', { tags: ['@adminUser'] }, () => {
apiServicesPage.waitForRequests();
});

it('Should be able to use shift+j to select corre', () => {
it('Should be able to use shift+j to select rows and the count of selected is correct', () => {
apiServicesPage.title().should('contain', 'APIServices');

const sortableTable = apiServicesPage.sortableTable();
Expand Down
Loading

0 comments on commit f6b2491

Please sign in to comment.