Skip to content

Commit

Permalink
test: add all accessibility test cases (#3405)
Browse files Browse the repository at this point in the history
* tests: add accessibility test for performance panel

* tests: add accessibility test for customr esources

* tests: add accessibility test for modules view

* chore: remove duplicated run acc tests command

* chore: cypress.config.js

* chore: fix empty spec for CR

* chore: add kyma for accessbility tests

* chore: bring back Absa for creating k3d

* tests: remove unnecesary comment

* tests: add accessibility test for extensions

* tests: add accessibility test for pizza orders

* tests: add accessibility test for cron jobs

* chore: cypress.config.js

* tests: fix all of the tests

* tests: fix all of the tests

* chore: add moduleName instead of pageTitle
  • Loading branch information
mrCherry97 authored Oct 17, 2024
1 parent 47f0114 commit 604b4bc
Show file tree
Hide file tree
Showing 12 changed files with 581 additions and 10 deletions.
13 changes: 9 additions & 4 deletions .github/workflows/accessibility-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,15 @@ jobs:
with:
ref: ${{ github.event.pull_request.head.sha }}
fetch-depth: 0
- name: Install k3d
env:
K3D_URL: https://raw.githubusercontent.com/k3d-io/k3d/main/install.sh
run: curl --silent --fail $K3D_URL | bash
- name: Create Single Cluster
uses: AbsaOSS/k3d-action@4e8b3239042be1dc0aed6c5eb80c13b18200fc79 #v2.4.0
with:
cluster-name: "k3dCluster"
args: >-
--agents 1
--port 80:80@loadbalancer
--port 443:443@loadbalancer
--wait
- name: Setup Kyma
run: |
set -o pipefail
Expand Down
2 changes: 1 addition & 1 deletion src/resources/CustomResourceDefinitions/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const convert = (arg, currentPath, spec) => {

export function createTemplate(crd) {
const spec = {};
const currentVersion = crd.spec.versions.find(ver => ver.storage);
const currentVersion = crd?.spec?.versions.find(ver => ver.storage);

return {
apiVersion: `${crd.spec.group}/${currentVersion.name}`,
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/continuum/cypress.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,10 @@ const failIfAnyAccessibilityConcerns = () => {
).to.have.lengthOf(0);
};

const submitAccessibilityConcernsToAMP = (reportTitle = 'Busola ACC') => {
const submitAccessibilityConcernsToAMP = (
reportTitle = 'Busola ACC',
moduleName,
) => {
const accessibilityConcerns = Continuum.getAccessibilityConcerns();
if (accessibilityConcerns.length <= 0) {
return;
Expand All @@ -113,7 +116,10 @@ const submitAccessibilityConcernsToAMP = (reportTitle = 'Busola ACC') => {
await ampReportingService.setActiveOrganization(10274); // ID of AMP organization to submit test results to
await ampReportingService.setActiveAsset(38893); // ID of AMP asset to submit test results to
await ampReportingService.setActiveReportByName(reportTitle);
await ampReportingService.setActiveModuleByName(pageTitle, pageUrl);
await ampReportingService.setActiveModuleByName(
moduleName ?? pageTitle,
pageUrl,
);
await ampReportingService.setActiveReportManagementStrategy(
ReportManagementStrategy.APPEND,
);
Expand Down
6 changes: 6 additions & 0 deletions tests/integration/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ module.exports = defineConfig({
specPattern: [
'tests/accessibility/test-acc-cluster.spec.js',
'tests/accessibility/test-acc-namespace-overview.spec.js',
'tests/accessibility/test-acc-modules.spec.js',
'tests/accessibility/test-acc-cron-jobs.spec.js',
'tests/accessibility/test-acc-performance.spec.js',
'tests/accessibility/test-acc-extensions.spec.js',
'tests/accessibility/test-acc-pizzas.spec.js',
'tests/accessibility/test-acc-custom-resoureces.spec.js',
'tests/cluster/test-download-a-kubeconfig.spec.js',
'tests/cluster/test-edit-cluster.spec.js',
'tests/cluster/test-cluster-overview.spec.js',
Expand Down
10 changes: 8 additions & 2 deletions tests/integration/tests/accessibility/test-acc-cluster.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ context('Accessibility test Cluster list and overview', () => {
cy.visit(`${config.clusterAddress}/clusters`)
.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(Cypress.env('AMP_REPORT_NAME'));
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Clusters list',
);
});

it('Acc test cluster overview', () => {
Expand All @@ -23,6 +26,9 @@ context('Accessibility test Cluster list and overview', () => {

cy.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(Cypress.env('AMP_REPORT_NAME'));
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Cluster overview',
);
});
});
141 changes: 141 additions & 0 deletions tests/integration/tests/accessibility/test-acc-cron-jobs.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
/// <reference types="cypress" />

import 'cypress-file-upload';

const NAMESPACE_NAME = 'acc-cron-jobs';
const CRON_JOB_NAME = 'acc-test-cron-job';

context('Accessibility test Cron Jobs', () => {
Cypress.skipAfterFail();

before(() => {
cy.handleExceptions();
cy.setUpContinuum('continuum/continuum.conf.js');
cy.loginAndSelectCluster();
cy.createNamespace(NAMESPACE_NAME);
});

it('Acc test Cron Jobs list', () => {
cy.loginAndSelectCluster();

cy.getLeftNav()
.contains('Namespaces')
.click();

cy.get('ui5-input[placeholder="Search"]:visible')
.find('input')
.wait(1000)
.type(NAMESPACE_NAME);

cy.clickGenericListLink(NAMESPACE_NAME);

cy.navigateTo('Workloads', 'Cron Jobs');

cy.contains('ui5-title', 'Cron Jobs').should('be.visible');

cy.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Cron Jobs list',
);
});

it('Acc test Cron Jobs create', () => {
cy.openCreate();

cy.getMidColumn()
.contains('ui5-title', 'Create Cron Job')
.should('be.visible');

cy.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Cron Jobs create',
);
});

it('Acc test Cron Jobs details', () => {
cy.get('[accessible-name="CronJob name"]')
.find('input')
.type(CRON_JOB_NAME, { force: true });

cy.get('[placeholder="Minute"]')
.find('input')
.click()
.clear()
.type(0, { force: true });

cy.get('[placeholder="Hour"]')
.find('input')
.click()
.clear()
.type(0, { force: true });

cy.get('[placeholder="Day of Month"]')
.find('input')
.click()
.clear()
.type(1, { force: true });

cy.get('[placeholder="Month"]')
.find('input')
.click()
.clear()
.type('*', { force: true });

cy.get('[placeholder="Day of Week"]')
.find('input')
.click()
.clear()
.type('*', { force: true });

cy.get(
'[aria-label="expand Schedule: At 12:00 AM, on day 1 of the month"]',
).click();

cy.contains('Command').click();

cy.get('[placeholder="Command to run in a container"]')
.find('input')
.click()
.clear()
.type('ls -la', { force: true });

cy.get('[accessible-name="Container name"]')
.find('input')
.click()
.clear()
.type('test-container', { force: true });

cy.get(
'[placeholder="Enter the Docker image tag, for example, \'busybox\'"]',
)
.find('input')
.click()
.clear()
.type('busybox', { force: true });

cy.get('ui5-combobox[value="IfNotPresent"]')
.find('ui5-icon[accessible-name="Select Options"]')
.click();

cy.get('ui5-li:visible')
.contains('Always')
.click();

cy.saveChanges('Create');

cy.getMidColumn()
.contains('ui5-title', CRON_JOB_NAME)
.should('be.visible');

cy.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Cron Jobs details',
);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/// <reference types="cypress" />

import { loadFile } from '../../support/loadFile';

const FILE_NAME = 'test-customresourcedefinisions-cluster.yaml';
const TCLUSTER_FILE_NAME = 'test-Tcluster.yaml';

context('Accessibility test Custom Resources', () => {
Cypress.skipAfterFail();

before(() => {
cy.setUpContinuum('continuum/continuum.conf.js');

cy.loginAndSelectCluster();

cy.navigateTo('Configuration', 'Custom Resource Definitions');

cy.openCreate().click();

cy.wrap(loadFile(FILE_NAME)).then(CRD_CONFIG => {
const CRD = JSON.stringify(CRD_CONFIG);
cy.pasteToMonaco(CRD);
});

cy.checkUnsavedDialog();

cy.saveChanges('Create');
});

it('Acc test Custom Resources overview', () => {
cy.getLeftNav()
.contains('Custom Resources')
.click();

cy.contains('ui5-title', 'Custom Resources').should('be.visible');

cy.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Custom Resources overview',
);
});

it('Acc test single Custom Resource list', () => {
cy.get('ui5-table-row')
.contains('Tclusters')
.click();

cy.contains('ui5-title', 'Tclusters').should('be.visible');

cy.contains('ui5-button', /Create/i).should('be.visible');

cy.url().should('match', /customresources/);

cy.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Custom Resources single list',
);
});

it('Acc test Tcluster Custom Resource details', () => {
cy.getLeftNav()
.contains('Custom Resources')
.click();

cy.get('ui5-input[placeholder="Search"]:visible')
.find('input')
.wait(1000)
.type('cypress');
cy.clickGenericListLink('Tclusters');

cy.contains('ui5-button', 'Create').click();

cy.wrap(loadFile(TCLUSTER_FILE_NAME)).then(TC_CONFIG => {
const TC = JSON.stringify(TC_CONFIG);
cy.pasteToMonaco(TC);
});

cy.checkUnsavedDialog();

cy.saveChanges('Create');

cy.contains('ui5-title', 'tcluster-test').should('be.visible');

cy.runAllAccessibilityTests()
.printAccessibilityTestResults()
.submitAccessibilityConcernsToAMP(
Cypress.env('AMP_REPORT_NAME'),
'Tcluster Custom Resource details',
);
});
});
Loading

0 comments on commit 604b4bc

Please sign in to comment.