Skip to content

Commit

Permalink
Merge branch 'master' into 13427-fix-radio-btns-color-input-space
Browse files Browse the repository at this point in the history
  • Loading branch information
aalves08 authored Feb 26, 2025
2 parents fd520eb + 46f565b commit 38009b2
Show file tree
Hide file tree
Showing 89 changed files with 2,190 additions and 729 deletions.
58 changes: 58 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,65 @@ jobs:
name: ${{github.run_number}}-${{github.run_attempt}}-screenshots-${{ matrix.role.tag }}+${{ matrix.features[0] }}
path: cypress/screenshots

a11y-test:
if: "!contains( github.event.pull_request.labels.*.name, 'ci/skip-e2e')"
needs: e2e-ui-build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Setup env
uses: ./.github/actions/setup

# Installing fixed version of Chrome since latest version does not work (128 didn't work)
# Leaving this here again in case we need to pin to a specific Chrome version in the future
- name: Install Chrome 127
run: |
sudo apt-get install -y wget libu2f-udev
cd /tmp
wget -q http://dl.google.com/linux/chrome/deb/pool/main/g/google-chrome-stable/google-chrome-stable_127.0.6533.72-1_amd64.deb
sudo dpkg -i google-chrome-stable_127.0.6533.72-1_amd64.deb
sudo apt-get install -y --allow-downgrades ./google-chrome-stable_127.0.6533.72-1_amd64.deb
google-chrome --version
- name: Download e2e build
uses: actions/download-artifact@v4
with:
name: ${{ env.E2E_BUILD_DIST_NAME }}
path: ${{ env.E2E_BUILD_DIST_DIR }}
- name: Download e2e build ember
uses: actions/download-artifact@v4
with:
name: ${{ env.E2E_BUILD_DIST_EMBER_NAME }}
path: ${{ env.E2E_BUILD_DIST_EMBER_DIR }}

- name: Run Rancher
run: yarn e2e:docker

- name: Setup Rancher and user
run: |
yarn e2e:prod
env:
GREP_TAGS: "@adminUserSetup+@accessibility --@jenkins"
TEST_USERNAME: admin
TEST_ONLY: setup
- name: Run user tests
run: |
yarn e2e:prod
[ "$BUILD_DASHBOARD" != "false" ] || exit 0
env:
TEST_SKIP: setup
GREP_TAGS: "@adminUser+@accessibility --@jenkins"
TEST_USERNAME: admin
TEST_A11Y: true

- name: Upload report
uses: actions/upload-artifact@v4
with:
name: accessibility-report
path: cypress/accessibility

unit-test:
runs-on: ubuntu-latest
steps:
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ sw.*
# Cypress e2e testing
cypress/videos
cypress/screenshots
cypress/accessibility
setupTestEnv.sh

# Storybook
storybook-static/
Expand Down
15 changes: 14 additions & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineConfig } from 'cypress';
import { removeDirectory } from 'cypress-delete-downloads-folder';
import { getSpecPattern } from '@/scripts/cypress';
import websocketTasks from './cypress/support/utils/webSocket-utils';
import path from 'path';

// Required for env vars to be available in cypress
require('dotenv').config();
Expand All @@ -11,13 +12,17 @@ require('dotenv').config();
* VARIABLES
*/
const hasCoverage = (process.env.TEST_INSTRUMENT === 'true') || false; // Add coverage if instrumented
const testDirs = ['priority', 'components', 'setup', 'pages', 'navigation', 'global-ui', 'features', 'extensions'];
let testDirs = ['priority', 'components', 'setup', 'pages', 'navigation', 'global-ui', 'features', 'extensions'];
const skipSetup = process.env.TEST_SKIP?.includes('setup');
const baseUrl = (process.env.TEST_BASE_URL || 'https://localhost:8005').replace(/\/$/, '');
const DEFAULT_USERNAME = 'admin';
const username = process.env.TEST_USERNAME || DEFAULT_USERNAME;
const apiUrl = process.env.API || (baseUrl.endsWith('/dashboard') ? baseUrl.split('/').slice(0, -1).join('/') : baseUrl);

if (process.env.TEST_A11Y) {
testDirs = ['accessibility'];
}

/**
* LOGS:
* Summary of the environment variables that we have detected (or are going ot use)
Expand Down Expand Up @@ -97,6 +102,8 @@ export default defineConfig({
azureClientSecret: process.env.AZURE_CLIENT_SECRET,
customNodeIp: process.env.CUSTOM_NODE_IP,
customNodeKey: process.env.CUSTOM_NODE_KEY,
accessibility: !!process.env.TEST_A11Y, // Are we running accessibility tests?
a11yFolder: path.join('.', 'cypress', 'accessibility'),
gkeServiceAccount: process.env.GKE_SERVICE_ACCOUNT,
},
e2e: {
Expand All @@ -106,6 +113,12 @@ export default defineConfig({
require('@cypress/code-coverage/task')(on, config);
require('@cypress/grep/src/plugin')(config);
// For more info: https://www.npmjs.com/package/cypress-delete-downloads-folder

// Load Accessibility plugin if configured
if (process.env.TEST_A11Y) {
require('./cypress/support/plugins/accessibility').default(on, config);
}

on('task', { removeDirectory });
websocketTasks(on, config);

Expand Down
3 changes: 2 additions & 1 deletion cypress/e2e/blueprints/fleet/gitrepos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ export const gitRepoCreateRequest = {
type: 'fleet.cattle.io.gitrepo',
metadata: {
namespace: 'fleet-default',
name: 'fleet-e2e-test-gitrepo'
name: 'fleet-e2e-test-gitrepo',
labels: {},
},
spec: {
repo: 'https://github.com/rancher/fleet-test-data.git',
Expand Down
12 changes: 8 additions & 4 deletions cypress/e2e/po/extensions/imported/cluster-edit.po.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import PagePo from '@/cypress/e2e/po/pages/page.po';
import LabeledInputPo from '@/cypress/e2e/po/components/labeled-input.po';
import ACE from '@/cypress/e2e/po/components/ace.po';
import ResourceDetailPo from '@/cypress/e2e/po/edit/resource-detail.po';
import NameNsDescription from '@/cypress/e2e/po/components/name-ns-description.po';

/**
* Edit page for imported cluster
Expand All @@ -11,22 +11,26 @@ export default class ClusterManagerEditImportedPagePo extends PagePo {
return `/c/${ clusterId }/manager/provisioning.cattle.io.cluster/fleet-default/${ clusterName }`;
}

static goTo(clusterId: string, clusterName: string): Cypress.Chainable<Cypress.AUTWindow> {
static goTo(clusterId: string, clusterName: string ): Cypress.Chainable<Cypress.AUTWindow> {
return super.goTo(ClusterManagerEditImportedPagePo.createPath(clusterId, clusterName));
}

constructor(clusterId = '_', clusterName: string) {
super(ClusterManagerEditImportedPagePo.createPath(clusterId, clusterName));
}

name(): LabeledInputPo {
return LabeledInputPo.byLabel(this.self(), 'Name');
nameNsDescription() {
return new NameNsDescription(this.self());
}

ace(): ACE {
return new ACE();
}

enableNetworkAccordion() {
return this.self().find('[data-testid="network-accordion"]').click();
}

resourceDetail() {
return new ResourceDetailPo(this.self());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import ClusterManagerImportPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/import/cluster-import.po';

/**
* Create page for a generic imported cluster
* Import page for generic cluster
*/
export default class ClusterManagerImportGenericPagePo extends ClusterManagerImportPagePo {

}
4 changes: 4 additions & 0 deletions cypress/e2e/po/pages/account-api-keys.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export default class AccountPagePo extends PagePo {
return this.applyButton().click();
}

cancel(): Cypress.Chainable {
return this.self().get('button[type="reset"]').click();
}

currentPassword(): PasswordPo {
return new PasswordPo('[data-testid="account__current_password"]');
}
Expand Down
14 changes: 10 additions & 4 deletions cypress/e2e/po/pages/page.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,18 @@ export default class PagePo extends ComponentPo {
return cy.url().should('include', `${ Cypress.config().baseUrl + (!!path ? path : this.path) }${ !!params ? `?${ params }` : '' }${ !!fragment ? `#${ fragment }` : '' }`);
}

isCurrentPage(): Cypress.Chainable<boolean> {
return cy.url().then((url) => url === Cypress.config().baseUrl + this.path);
isCurrentPage(isExact = true): Cypress.Chainable<boolean> {
return cy.url().then((url) => {
if (isExact) {
return url === Cypress.config().baseUrl + this.path;
} else {
return url.indexOf(Cypress.config().baseUrl + this.path) === 0;
}
});
}

checkIsCurrentPage() {
return this.isCurrentPage().should('eq', true);
checkIsCurrentPage(exact = true) {
return this.isCurrentPage(exact).should('eq', true);
}

mastheadTitle() {
Expand Down
95 changes: 95 additions & 0 deletions cypress/e2e/tests/accessibility/shell.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
import { LoginPagePo } from '@/cypress/e2e/po/pages/login-page.po';
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import AboutPagePo from '@/cypress/e2e/po/pages/about.po';
import PreferencesPagePo from '@/cypress/e2e/po/pages/preferences.po';
import UserMenuPo from '@/cypress/e2e/po/side-bars/user-menu.po';
import AccountPagePo from '@/cypress/e2e/po/pages/account-api-keys.po';
import CreateKeyPagePo from '@/cypress/e2e/po/pages/account-api-keys-create_key.po';

describe('Shell a11y testing', { tags: ['@adminUser', '@accessibility'] }, () => {
it('login page', () => {
const loginPage = new LoginPagePo();

loginPage.goTo();
loginPage.waitForPage();
cy.injectAxe();
loginPage.username().set('test user');

cy.checkPageAccessibility();
});

it('locale selector', () => {
const loginPage = new LoginPagePo();

loginPage.goTo();
loginPage.waitForPage();
cy.injectAxe();
cy.get('[data-testid="locale-selector"]').click();
cy.checkPageAccessibility();
});

describe('Logged in', { testIsolation: 'off' }, () => {
const aboutPage = new AboutPagePo();
const prefPage = new PreferencesPagePo();
const userMenu = new UserMenuPo();

before(() => {
cy.login();
});

it('home page', () => {
HomePagePo.goToAndWaitForGet();
cy.injectAxe();

cy.checkPageAccessibility();
});

it('about page', () => {
AboutPagePo.navTo();
aboutPage.waitForPage();

cy.checkPageAccessibility();
});

it('preferences page', () => {
userMenu.clickMenuItem('Preferences');
userMenu.isClosed();
prefPage.waitForPage();
prefPage.checkIsCurrentPage();
prefPage.title();
cy.injectAxe();

cy.checkPageAccessibility();
});

describe('account', () => {
const accountPage = new AccountPagePo();
const createKeyPage = new CreateKeyPagePo();

it('account page', () => {
userMenu.clickMenuItem('Account & API Keys');
accountPage.waitForPage();
cy.injectAxe();
accountPage.checkIsCurrentPage();

cy.checkPageAccessibility();
});

it('change password dialog', () => {
accountPage.changePassword();

cy.checkElementAccessibility('.change-password-modal');

accountPage.cancel();
});

it('create API key', () => {
accountPage.create();
createKeyPage.waitForPage();
createKeyPage.isCurrentPage();

cy.checkPageAccessibility();
});
});
});
});
11 changes: 11 additions & 0 deletions cypress/e2e/tests/pages/fleet/gitrepo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ const fakeProvClusterId = 'some-fake-cluster-id';
const fakeMgmtClusterId = 'some-fake-mgmt-id';

describe('Git Repo', { testIsolation: 'off', tags: ['@fleet', '@adminUser'] }, () => {
let adminUsername = '';
let adminUserId = '';

describe('Create', () => {
const listPage = new FleetGitRepoListPagePo();
const gitRepoCreatePage = new GitRepoCreatePo('_');
Expand All @@ -36,6 +39,11 @@ describe('Git Repo', { testIsolation: 'off', tags: ['@fleet', '@adminUser'] }, (
});

beforeEach(() => {
cy.getRancherResource('v3', 'users?me=true').then((resp: Cypress.Response<any>) => {
adminUserId = resp.body.data[0].id.trim();
adminUsername = resp.body.data[0].username.trim();
});

cy.createE2EResourceName('git-repo').as('gitRepo');
});

Expand Down Expand Up @@ -91,7 +99,10 @@ describe('Git Repo', { testIsolation: 'off', tags: ['@fleet', '@adminUser'] }, (
return cy.wait('@interceptGitRepo');
})
.then(({ request, response }) => {
gitRepoCreateRequest.metadata.labels['fleet.cattle.io/created-by-display-name'] = adminUsername;
gitRepoCreateRequest.metadata.labels['fleet.cattle.io/created-by-user-id'] = adminUserId;
gitRepoCreateRequest.spec.helmSecretName = secretName;

expect(response.statusCode).to.eq(201);
expect(request.body).to.deep.eq(gitRepoCreateRequest);

Expand Down
2 changes: 1 addition & 1 deletion cypress/e2e/tests/pages/generic/home.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { CURRENT_RANCHER_VERSION } from '@shell/config/version.js';
import HomePagePo from '@/cypress/e2e/po/pages/home.po';
import PreferencesPagePo from '@/cypress/e2e/po/pages/preferences.po';
import ClusterManagerListPagePo from '@/cypress/e2e/po/pages/cluster-manager/cluster-manager-list.po';
import ClusterManagerImportGenericPagePo from '@/cypress/e2e/po/edit/provisioning.cattle.io.cluster/import/cluster-import.generic.po';
import ClusterManagerImportGenericPagePo from '@/cypress/e2e/po/extensions/imported/cluster-import-generic.po';
import { PARTIAL_SETTING_THRESHOLD } from '@/cypress/support/utils/settings-utils';
import { RANCHER_PAGE_EXCEPTIONS, catchTargetPageException } from '~/cypress/support/utils/exception-utils';

Expand Down
Loading

0 comments on commit 38009b2

Please sign in to comment.