Skip to content

Commit

Permalink
Run pagination regressions tests against a system with server-side pa…
Browse files Browse the repository at this point in the history
…gination enabled (rancher#11358)

* Add tests for setting up vai env in rancher

* workflow hack

* testing

* add user tag to @vai tests

* more shippable trigger, in the hope it fixes the looong test run due to tests with no tests in...

* test - rely on filename sort order for priority

* test - rely on spec order for priority

* test - rely on spec order for priority - take 2

* add setup for vai...

* Apply tags to new tests

* fix global roles - cluster different if run directly
- there was a more complex solution here (hence abstract) but it ended up needing to go to a cluster page anyway, so might as well just nav to desired page

* fix users - cluster different if run directly

* Fix other revisions (probably more TODO...)

* Fixes for event and crd tables

* Tweaks

* Revert temp changes

---------

Co-authored-by: Richard <[email protected]>
  • Loading branch information
richard-cox and Richard authored Jul 18, 2024
1 parent ba39a4a commit ddd2dee
Show file tree
Hide file tree
Showing 44 changed files with 219 additions and 109 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ jobs:
{ username: 'standard_user', tag: '@standardUser' }
]
features: [
['@navigation', '@extensions'],
['@charts'],
['@explorer'],
['@fleet'],
['@generic', '@globalSettings'],
['@manager'],
['@userMenu', '@usersAndAuths'],
['@components'],
['@navigation', '@extensions'],
['@charts'],
['@explorer'],
['@fleet'],
['@generic', '@globalSettings'],
['@manager'],
['@userMenu', '@usersAndAuths'],
['@components'],
['@vai']
]
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -119,7 +120,6 @@ jobs:
GREP_TAGS: ${{ matrix.role.tag }}Setup+${{ matrix.features[0] }} --@jenkins ${{ matrix.role.tag }}Setup+${{ matrix.features[1] || matrix.features[0] }} --@jenkins
TEST_USERNAME: admin
TEST_ONLY: setup

- name: Run user tests
run: |
yarn e2e:prod
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ require('dotenv').config();
* VARIABLES
*/
const hasCoverage = (process.env.TEST_INSTRUMENT === 'true') || false; // Add coverage if instrumented
const testDirs = ['components', 'setup', 'pages', 'navigation', 'global-ui'];
const testDirs = ['priority', 'components', 'setup', 'pages', 'navigation', 'global-ui', 'features'];
const skipSetup = process.env.TEST_SKIP?.includes('setup');
const baseUrl = (process.env.TEST_BASE_URL || 'https://localhost:8005').replace(/\/$/, '');
const DEFAULT_USERNAME = 'admin';
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/blueprints/explorer/cluster/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const eventsGetEmptyEventsSet = {
createTypes: { event: `${ Cypress.env('api') }/v1/events` },
actions: {},
resourceType: 'event',
revision: '95942',
revision: Number.MAX_VALUE, // The UI will use this point in history to start watching for changes from. If it's too low (than the global system revision) we will spam with requests
data: []
};

Expand All @@ -16,7 +16,7 @@ const eventsGetResponseSmallSet = {
createTypes: { event: `${ Cypress.env('api') }/v1/events` },
actions: {},
resourceType: 'event',
revision: '95942',
revision: Number.MAX_VALUE, // The UI will use this point in history to start watching for changes from. If it's too low (than the global system revision) we will spam with requests
count: 3,
data: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const crdsGetResponseSmallSet = {
createTypes: { 'apiextensions.k8s.io.customresourcedefinition': 'https://yonasb29head.qa.rancher.space/v1/apiextensions.k8s.io.customresourcedefinitions' },
actions: {},
resourceType: 'apiextensions.k8s.io.customresourcedefinition',
revision: '123',
revision: Number.MAX_VALUE, // The UI will use this point in history to start watching for changes from. If it's too low (than the global system revision) we will spam with requests
count: 2,
data: [
{
Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/blueprints/roles/global-roles-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const globalRolesGetResponseSmallSet = {
createTypes: { 'management.cattle.io.globalrole': 'https://yonasb29head.qa.rancher.space/v1/management.cattle.io.globalroles' },
actions: {},
resourceType: 'management.cattle.io.globalrole',
revision: '123',
revision: Number.MAX_VALUE, // The UI will use this point in history to start watching for changes from. If it's too low (than the global system revision) we will spam with requests
count: 2,
data: [
{
Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/blueprints/users/users-get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ const usersGetResponseSmallSet = {
uuid: null
},
resourceType: 'user',
revision: Number.MAX_VALUE, // The UI will use this point in history to start watching for changes from. If it's too low (than the global system revision) we will spam with requests
data: [
{
actions: {
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/po/components/component.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default class ComponentPo {
return this.self().should('exist');
}

checkNotExists(): Cypress.Chainable<boolean> {
return this.self().should('not.exist');
checkNotExists(options?: GetOptions): Cypress.Chainable<boolean> {
return this.self(options).should('not.exist');
}
}
4 changes: 4 additions & 0 deletions cypress/e2e/po/components/sortable-table.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ export default class SortableTablePo extends ComponentPo {
cy.get('tbody', { timeout: 10000 }).find('.data-loading').should('not.exist');
}

checkNoRowsNotVisible() {
cy.get('tbody', { timeout: 10000 }).find('.no-rows').should('not.exist');
}

// pagination
pagination() {
return new PaginationPo();
Expand Down
18 changes: 18 additions & 0 deletions cypress/e2e/po/pages/cluster-page.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';

export default abstract class ClusterPage extends PagePo {
private static createPath(clusterId: string, pathAfterCluster: string) {
return `/c/${ clusterId }/${ pathAfterCluster }`;
}

/**
* Fetch the cluster id from the url... (note - you need to be on a cluster page for this to work)
*/
static clusterId() {
return cy.url().then((url: string) => /\/c\/([a-z\-_]*)\/\S*/.exec(url)?.[1]);
}

constructor(clusterId = '_', pathAfterCluster = '') {
super(ClusterPage.createPath(clusterId, pathAfterCluster));
}
}
44 changes: 33 additions & 11 deletions cypress/e2e/po/pages/global-settings/feature-flags.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,19 @@ import CardPo from '@/cypress/e2e/po/components/card.po';
import { CypressChainable } from '@/cypress/e2e/po/po.types';
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
import { EXTRA_LONG_TIMEOUT_OPT } from '@/cypress/support/utils/timeouts';

export class FeatureFlagsPagePo extends RootClusterPage {
static url = '/c/_/settings/management.cattle.io.feature';
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(FeatureFlagsPagePo.url);
private static createPath(clusterId: string) {
return `/c/${ clusterId }/settings/management.cattle.io.feature`;
}

constructor() {
super(FeatureFlagsPagePo.url);
static goTo(clusterId: string): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(FeatureFlagsPagePo.createPath(clusterId));
}

constructor(clusterId = '_') {
super(FeatureFlagsPagePo.createPath(clusterId));
}

static navTo() {
Expand Down Expand Up @@ -57,15 +61,33 @@ export class FeatureFlagsPagePo extends RootClusterPage {
* @param value
* @returns
*/
clickCardActionButtonAndWait(label: 'Activate' | 'Deactivate', endpoint: string, value: boolean): Cypress.Chainable {
clickCardActionButtonAndWait(
label: 'Activate' | 'Deactivate',
endpoint: string,
value: boolean,
config: {
waitForModal: boolean
waitForRequest: boolean
} = {
waitForModal: false,
waitForRequest: true,
}) {
cy.intercept('PUT', `/v1/management.cattle.io.features/${ endpoint }`).as(endpoint);
this.cardActionButton(label).click();

return cy.wait(`@${ endpoint }`).then(({ request, response }) => {
expect(response?.statusCode).to.eq(200);
expect(request.body.spec).to.have.property('value', value);
expect(response?.body.spec).to.have.property('value', value);
});
if (config.waitForRequest) {
cy.wait(`@${ endpoint }`).then(({ request, response }) => {
expect(response?.statusCode).to.eq(200);
expect(request.body.spec).to.have.property('value', value);
expect(response?.body.spec).to.have.property('value', value);
});
}

if (config.waitForModal) {
const card = new CardPo();

card.checkNotExists(EXTRA_LONG_TIMEOUT_OPT);
}
}

getFeatureFlag(featureFlag: string): Cypress.Chainable<Object> {
Expand Down
24 changes: 18 additions & 6 deletions cypress/e2e/po/pages/global-settings/performance.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,20 @@ import ModalWithCardPo from '@/cypress/e2e/po/components/modal-with-card.po';
import RootClusterPage from '@/cypress/e2e/po/pages/root-cluster-page';
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
import GenericPrompt from '@/cypress/e2e/po/prompts/genericPrompt.po';

export class PerformancePagePo extends RootClusterPage {
static url = '/c/_/settings/performance'
private static createPath(clusterId: string) {
return `/c/${ clusterId }/settings/performance`;
}

static modal = new ModalWithCardPo();
static goTo(): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(PerformancePagePo.url);
static goTo(clusterId: string): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(PerformancePagePo.createPath(clusterId));
}

constructor() {
super(PerformancePagePo.url);
constructor(clusterId = '_') {
super(PerformancePagePo.createPath(clusterId));
}

static navTo() {
Expand All @@ -24,6 +28,10 @@ export class PerformancePagePo extends RootClusterPage {
sideNav.navToSideMenuEntryByLabel('Performance');
}

incompatibleModal(): GenericPrompt {
return new GenericPrompt('.prompt-restore');
}

inactivityCheckbox(): CheckboxInputPo {
return CheckboxInputPo.byLabel(this.self(), 'Enable inactivity session expiration ');
}
Expand Down Expand Up @@ -60,11 +68,15 @@ export class PerformancePagePo extends RootClusterPage {
return CheckboxInputPo.byLabel(this.self(), 'Enable Advanced Websocket Web Worker ');
}

serverSidePaginationCheckbox(): CheckboxInputPo {
return CheckboxInputPo.byLabel(this.self(), 'Enable Server-side Pagination ');
}

applyButton() {
return new AsyncButtonPo('[data-testid="performance__save-btn"]', this.self());
}

applyAndWait(context, endpoint = 'ui-performance', statusCode?: number): Cypress.Chainable {
applyAndWait(context: string, endpoint = 'ui-performance', statusCode?: number): Cypress.Chainable {
cy.intercept('PUT', endpoint).as(context);
this.applyButton().click();

Expand Down
10 changes: 3 additions & 7 deletions cypress/e2e/po/pages/users-and-auth/roles.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,17 @@ import GlobalRoleEditPo from '@/cypress/e2e/po/edit/management.cattle.io.globalr
import RoleTemplateEditPo from '@/cypress/e2e/po/edit/management.cattle.io.roletemplate.po';
import BaseResourceList from '@/cypress/e2e/po/lists/base-resource-list.po';
import RoleListPo from '@/cypress/e2e/po/lists/role-list.po';
import PagePo from '@/cypress/e2e/po/pages/page.po';
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
import ClusterPage from '@/cypress/e2e/po/pages/cluster-page.po';

export default class RolesPo extends PagePo {
private static createPath(clusterId: string) {
return `/c/${ clusterId }/auth/roles`;
}

export default class RolesPo extends ClusterPage {
static goTo(path: string): Cypress.Chainable<Cypress.AUTWindow> {
throw new Error('invalid');
}

constructor(private clusterId = '_') {
super(RolesPo.createPath(clusterId));
super(clusterId, 'auth/roles');
}

static navTo() {
Expand Down
10 changes: 3 additions & 7 deletions cypress/e2e/po/pages/users-and-auth/users.po.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import MgmtUsersListPo from '@/cypress/e2e/po/lists/management.cattle.io.user.po';
import MgmtUserEditPo from '@/cypress/e2e/po/edit/management.cattle.io.user.po';
import MgmtUserResourceDetailPo from '@/cypress/e2e/po/detail/management.cattle.io.user.po';
import BurgerMenuPo from '@/cypress/e2e/po/side-bars/burger-side-menu.po';
import ProductNavPo from '@/cypress/e2e/po/side-bars/product-side-nav.po';
import LinkPo from '@/cypress/e2e/po/components/link.po';
import ClusterPage from '@/cypress/e2e/po/pages/cluster-page.po';

export default class UsersPo extends PagePo {
private static createPath(clusterId: string) {
return `/c/${ clusterId }/auth/management.cattle.io.user`;
}

export default class UsersPo extends ClusterPage {
static goTo(path: string): Cypress.Chainable<Cypress.AUTWindow> {
throw new Error('invalid');
}
Expand All @@ -24,7 +20,7 @@ export default class UsersPo extends PagePo {
}

constructor(private clusterId = '_') {
super(UsersPo.createPath(clusterId));
super(clusterId, 'auth/management.cattle.io.user');
}

waitForRequests() {
Expand Down
22 changes: 22 additions & 0 deletions cypress/e2e/po/prompts/genericPrompt.po.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import ComponentPo from '@/cypress/e2e/po/components/component.po';
import CardPo from '@/cypress/e2e/po/components/card.po';

export default class GenericPrompt extends ComponentPo {
card = new CardPo();

getTitle() {
return this.card.getTitle();
}

getBody() {
return this.card.getBody();
}

cancel() {
return this.self().find('.btn role-secondary');
}

submit(text: string) {
return this.card.getActionButton().contains(text).click();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ describe('Cluster Dashboard', { testIsolation: 'off', tags: ['@explorer', '@admi
events.sortableTable().rowElements().should('have.length.gte', 2);
});

it('can view events table empty if no events', { tags: ['@vai'] }, () => {
it('can view events table empty if no events', { tags: ['@vai', '@adminUser'] }, () => {
const events = new EventsPagePo('local');

HomePagePo.goTo();
Expand Down
8 changes: 2 additions & 6 deletions cypress/e2e/tests/pages/explorer/dashboard/events.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('Events', { testIsolation: 'off', tags: ['@explorer', '@adminUser'] },
cy.login();
});

describe('List', { tags: ['@vai'] }, () => {
describe('List', { tags: ['@vai', '@adminUser'] }, () => {
const uniquePod = 'aaa-e2e-test-pod-name';
const podNamesList = [];
let nsName1: string;
Expand Down Expand Up @@ -146,8 +146,6 @@ describe('Events', { testIsolation: 'off', tags: ['@explorer', '@adminUser'] },
});

it('sorting changes the order of paginated events data', () => {
ClusterDashboardPagePo.navTo();
clusterDashboard.waitForPage(undefined, 'cluster-events');
EventsPagePo.navTo();
events.waitForPage();

Expand Down Expand Up @@ -178,9 +176,7 @@ describe('Events', { testIsolation: 'off', tags: ['@explorer', '@adminUser'] },
it('pagination is hidden', () => {
// generate small set of events data
generateEventsDataSmall();
ClusterDashboardPagePo.navTo();
clusterDashboard.waitForPage(undefined, 'cluster-events');
EventsPagePo.navTo();
events.goTo();
events.waitForPage();
cy.wait('@eventsDataSmall');

Expand Down
Loading

0 comments on commit ddd2dee

Please sign in to comment.