Skip to content

Commit

Permalink
e2e test update
Browse files Browse the repository at this point in the history
  • Loading branch information
jrichter1 authored and rohitkrai03 committed May 4, 2023
1 parent c335677 commit 9f402b5
Show file tree
Hide file tree
Showing 19 changed files with 150 additions and 175 deletions.
3 changes: 1 addition & 2 deletions integration-tests/support/constants/PageTitle.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
export const pageTitles = {
applications: 'Applications',
createApp: 'Create application',
buildApp: 'Add component',
createApp: 'Grab some code',
sampleStart: 'Start with a sample',
reviewComponent: 'Review your new components',
componentSettings: 'Component settings',
Expand Down
17 changes: 9 additions & 8 deletions integration-tests/support/pageObjects/createApplication-po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@ export const addComponentPagePO = {

export const componentSamplesPagePO = {
grid: '.catalog-page__grid',
nodejs: '[data-test="sample-Node"]',
python: '[data-test="sample-Python"]',
quarkus: '[data-test="sample-Quarkus"]',
spring: '[data-test="sample-Spring Boot"]',
create: '[data-test="submit-button"]',
sample: (name: string) => `[data-test="${name}"]`,
import: (name: string) => `[data-test="import-${name}"]`,
nodejs: 'sample-Node',
python: 'sample-Python',
quarkus: 'sample-Quarkus',
spring: 'sample-Spring Boot',
};

export const createApplicationPagePO = {
Expand All @@ -32,10 +33,10 @@ export const createApplicationPagePO = {
};

export const ComponentsPagePO = {
appInput: '[data-test="app-name-field"] input',
create: 'button[type=submit]',
createText: 'Create',
extractComponentName: '[class="editable-label-field__label"]',
editComponentNameIcon: '[data-test="pencil-icon"]',
componentNameField: '[data-test="component-name-field"] input',
checkIcon: '[data-test="check-icon"]',
closeIcon: '[data-test="close-icon"]',
showAdvancedSetting: 'Show advanced deployment options',
Expand All @@ -51,7 +52,7 @@ export const ComponentsPagePO = {
loading: '[data-test="loading-indicator"]',
saveButton: '[data-test="submit-button"]',
editNameInput: '[data-test="editable-label-input"]',
customBuildPipelineRadioBtn: '[data-test="custom-build-pipelines"]',
customBuildPipelineRadioBtn: '[for*="defaultBuildPipeline"] .pf-c-switch__toggle',
customBuildRequestedState: '[data-testid="requested-state"]',
label: '[class="pf-c-label__content"]',
customBuildPipelineModalCloseBtn: '[data-test="close-button custom-pipeline-modal"]',
Expand Down
3 changes: 2 additions & 1 deletion integration-tests/support/pageObjects/global-po.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const formPO = {
create: '[data-test-id="submit-button"]',
create: 'button[type=submit]',
cancel: '[data-test-id="reset-button"]',
};
export const alert = '.pf-c-alert';
Expand Down Expand Up @@ -34,6 +34,7 @@ export const waits = {
export const actions = {
kebabButton: '[data-testid="kebab-button"]',
deleteItem: '[data-testid="Delete"]',
deleteComponent: '[data-testid="Delete component"]',
deleteModalInput: 'input[name*="resourceName"]',
deleteModalButton: 'button[data-testid="delete-resource"]',
editItem: '[data-testid="Edit"]',
Expand Down
8 changes: 2 additions & 6 deletions integration-tests/support/pages/AddComponentPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@ export class AddComponentPage extends AbstractWizardPage {
cy.get(addComponentPagePO.enterSource).clear().type(source);
}

clickGitOptions() {
cy.contains(addComponentPagePO.gitOptions).click();
}

setGitReference(gitReference: string) {
cy.get(addComponentPagePO.gitReference).clear().type(gitReference);
}
Expand All @@ -33,8 +29,8 @@ export class AddComponentPage extends AbstractWizardPage {
cy.get(addComponentPagePO.contextDir).clear().type(contextDir);
}

clickNext() {
cy.get(addComponentPagePO.next).click({ force: true });
submit() {
cy.get(addComponentPagePO.next).click({ force: true }).click();
}

clickCancel() {
Expand Down
6 changes: 3 additions & 3 deletions integration-tests/support/pages/ApplicationDetailPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,14 +91,14 @@ export class ApplicationDetailPage {

openAddComponentPage() {
cy.get(addComponentPagePO.addComponent).click({ force: true });
Common.verifyPageTitle(pageTitles.buildApp);
Common.verifyPageTitle(pageTitles.createApp);
Common.waitForLoad();
cy.testA11y(`${pageTitles.buildApp} page`);
cy.testA11y(`${pageTitles.createApp} page`);
}

deleteComponent(componentName: string) {
this.openActionList(componentName);
cy.get(actions.deleteItem).click();
cy.get(actions.deleteComponent).click();
cy.get(actions.deleteModalInput).clear().type(componentName);
cy.get(actions.deleteModalButton).click();
}
Expand Down
5 changes: 4 additions & 1 deletion integration-tests/support/pages/ComponentSamplesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ export class ComponentSamplesPage extends AbstractWizardPage {
}

selectSample(sampleName: string) {
cy.get(sampleName).click();
cy.get(componentSamplesPagePO.sample(sampleName)).within(() => {
cy.get(componentSamplesPagePO.import(sampleName)).click();
});
cy.contains('Importing sample...').should('not.exist');
Common.waitForLoad();
}
}
27 changes: 16 additions & 11 deletions integration-tests/support/pages/ComponentsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,27 @@ import { UIhelper } from '../../utils/UIhelper';
import { CPUUnit, MemoryUnit } from '../constants/Units';
import { addComponentPagePO, ComponentsPagePO } from '../pageObjects/createApplication-po';
import { alertTitle } from '../pageObjects/global-po';
import { componentsTabPO } from '../pageObjects/pages-po';
import { AbstractWizardPage } from './AbstractWizardPage';

export class ComponentPage extends AbstractWizardPage {
public componentName: string;

editComponentName(newName: string) {
cy.get(ComponentsPagePO.dropdown, { timeout: 80000 }).eq(0).should('be.enabled'); // Work around for issue : HAC-3585 to reduce test flakiness
cy.get(ComponentsPagePO.editComponentNameIcon, { timeout: 80000 }).eq(0).click();
cy.get(ComponentsPagePO.editNameInput).clear().type(newName);
cy.get(ComponentsPagePO.checkIcon).click();
cy.contains('div', newName).should('be.visible');
cy.get(ComponentsPagePO.componentNameField).clear().type(newName);
cy.get(ComponentsPagePO.componentNameField).should('have.value', newName);
}

extractComponentName() {
cy.get(ComponentsPagePO.componentNameField)
.invoke('val')
.then((val: string) => {
this.componentName = val.trim();
});
}

setApplicationName(name: string) {
cy.get(ComponentsPagePO.appInput).clear().type(name);
}

saveChanges() {
Expand Down Expand Up @@ -45,7 +54,7 @@ export class ComponentPage extends AbstractWizardPage {
}

setCpuByButton(value: number, unit: CPUUnit) {
cy.contains(`.pf-c-dropdown__toggle-text`, 'cores').parent().click();
cy.contains(`[data-test="dropdown"]`, 'cores').click();
cy.contains('li', new RegExp(`^${unit}$`)).click();

cy.get(ComponentsPagePO.cpuInput).then(($cpu) => {
Expand Down Expand Up @@ -76,11 +85,6 @@ export class ComponentPage extends AbstractWizardPage {
cy.contains('li', unit).click();
}

showAdvancedOptions() {
cy.contains('button', ComponentsPagePO.showAdvancedSetting).click();
cy.testA11y(`Component deployment options`);
}

selectRuntime(runtimeName: string) {
UIhelper.selectValueInDropdownbyLabelName('Runtime', runtimeName);
}
Expand All @@ -102,6 +106,7 @@ export class ComponentPage extends AbstractWizardPage {

selectCustomBuildPipeline() {
cy.get(ComponentsPagePO.customBuildPipelineRadioBtn).click();
cy.contains('Custom build pipeline').should('be.visible');
}

checkStatusOnModal(labelText: string) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export class TaskRunsTab {
status: 'Succeeded',
},
{ name: `${pipelineName}-sbom-json-check`, task: 'sbom-json-check', status: 'Succeeded' },
{ name: `${pipelineName}-clair-scan`, task: 'clair-scan', status: 'Succeeded|Test Warnings' }, // Adding Test Warnings as some packages might have medium vulnerabilities sometimes
{ name: `${pipelineName}-clair-scan`, task: 'clair-scan', status: 'Succeeded|Test Failures' }, // Adding Test Warnings as some packages might have medium vulnerabilities sometimes
{ name: `${pipelineName}-clamav-scan`, task: 'clamav-scan', status: 'Succeeded' },
{ name: `${pipelineName}-label-check`, task: 'label-check', status: 'Succeeded' },
{
Expand Down
17 changes: 5 additions & 12 deletions integration-tests/tests/advanced-happy-path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,11 @@ describe('Advanced Happy path', () => {
Applications.deleteApplication(applicationName);
});

describe('Create an Application with a component', () => {
it('Set Application Name', () => {
Applications.createApplication(applicationName);
});

it('Add a component to Application', () => {
Applications.createComponent(repoLink, componentName, 'Go', true, {
varName: 'TEST_ENV_VAR',
value: 'Test go app',
});
it('Create an Application with a component', () => {
Applications.createApplication();
Applications.createComponent(repoLink, componentName, applicationName, 'Go', true, {
varName: 'TEST_ENV_VAR',
value: 'Test go app',
});
});

Expand Down Expand Up @@ -99,9 +94,7 @@ describe('Advanced Happy path', () => {
'Custom',
);
});
});

describe('Verify and wait for "Pipeline runs" Tab', () => {
it('Verify the Pipeline run details and Task runs', () => {
Applications.goToPipelinerunsTab();
UIhelper.getTableRow('Pipeline run List', 'Running')
Expand Down
52 changes: 19 additions & 33 deletions integration-tests/tests/basic-happy-path.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { applicationDetailPagePO } from '../support/pageObjects/createApplication-po';
import { AddComponentPage } from '../support/pages/AddComponentPage';
import { ApplicationDetailPage } from '../support/pages/ApplicationDetailPage';
import {
DetailsTab,
Expand All @@ -14,7 +13,6 @@ import { FULL_APPLICATION_TITLE } from '../support/constants/PageTitle';
describe('Basic Happy Path', { tags: ['@PR-check', '@publicRepo'] }, () => {
const applicationName = Common.generateAppName();
const applicationDetailPage = new ApplicationDetailPage();
const addComponent = new AddComponentPage();
const publicRepo = 'https://github.com/hac-test/devfile-sample-code-with-quarkus';
const componentName: string = Common.generateAppName('java-quarkus');
const piplinerunlogsTasks = ['init', 'clone-repository', 'build-container', 'show-summary'];
Expand All @@ -24,55 +22,43 @@ describe('Basic Happy Path', { tags: ['@PR-check', '@publicRepo'] }, () => {
Applications.deleteApplication(applicationName);
});

describe('Create an Application with a component', () => {
it('Create an Application with a component', () => {
Applications.createApplication(applicationName);
Applications.createComponent(publicRepo, componentName);
Applications.checkComponentInListView(
componentName,
applicationName,
'Build Running',
'Default',
);
});
it('Create an Application with a component', () => {
Applications.createApplication();
Applications.createComponent(publicRepo, componentName, applicationName);
Applications.checkComponentInListView(
componentName,
applicationName,
'Build Running',
'Default',
);
});

describe('Try to add a new component using the "Overview" tab', () => {
describe('Check different ways to add a component', () => {
it("Use 'Components' tabs to start adding a new component", () => {
Applications.goToOverviewTab().addComponent();
cy.title().should('eq', `Import - Add components | ${FULL_APPLICATION_TITLE}`);
});

it('Verify we are on "Add Component" wizard, and then hit Cancel', () => {
cy.url().should('include', `/import?application=${applicationName}`);
addComponent.clickCancel();
cy.url().should('include', `${applicationName}/overview`);

Applications.clickBreadcrumbLink(applicationName);
cy.url().should('include', `${applicationName}`);
});
});

describe('Try to add a new component using the "Components" tab', () => {
it("Use HACBS 'Components' tabs to start adding a new component", () => {
Applications.goToComponentsTab().clickAddComponent();
cy.title().should('eq', `Import - Add components | ${FULL_APPLICATION_TITLE}`);
});

it('Verify we are on "Add Component" wizard, and then hit Cancel', () => {
cy.url().should('include', `/import?application=${applicationName}`);
addComponent.clickCancel();
cy.url().should('include', `${applicationName}/components`);

Applications.clickBreadcrumbLink(applicationName);
cy.url().should('include', `${applicationName}`);
});
});

describe('Try to add a new component using the "Actions" dropdown', () => {
it("Click 'Actions' dropdown to add a component", () => {
Applications.clickActionsDropdown('Add component');
cy.title().should('eq', `Import - Add components | ${FULL_APPLICATION_TITLE}`);
});

it('Verify we are on "Add Component" wizard, and then hit Cancel', () => {
cy.url().should('include', `/import?application=${applicationName}`);
addComponent.clickCancel();
cy.url().should('include', `${applicationName}/components`);

Applications.clickBreadcrumbLink(applicationName);
cy.url().should('include', `${applicationName}`);
});
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe(

before(function () {
Tokens.removeBindingsAndTokens();
Applications.createApplication(applicationName);
Applications.createApplication();
});

after(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe(

before(function () {
Tokens.removeBindingsAndTokens();
Applications.createApplication(applicationName);
Applications.createApplication();
});

after(function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
import { CPUUnit, MemoryUnit } from '../support/constants/Units';
import { ComponentsPagePO } from '../support/pageObjects/createApplication-po';
import { AddComponentPage } from '../support/pages/AddComponentPage';
import { ApplicationDetailPage } from '../support/pages/ApplicationDetailPage';
import { ComponentPage } from '../support/pages/ComponentsPage';
import { Applications } from '../utils/Applications';
import { Common } from '../utils/Common';
import { UIhelper } from '../utils/UIhelper';

describe('Create Component from Public Git Source', { tags: ['@PR-check', '@publicRepo'] }, () => {
const addComponent = new AddComponentPage();
Expand All @@ -26,37 +24,24 @@ describe('Create Component from Public Git Source', { tags: ['@PR-check', '@publ
});

describe('Creating a Quarkus Component', () => {
it('Create Application', () => {
Applications.createApplication(applicationName);
});
it('Validate Repo', () => {
// Enter git repo URL
it('Import code', () => {
Applications.createApplication();
addComponent.setSource(publicRepo);
// Check if the source is validated
addComponent.waitRepoValidated();
});

it('Setup Git Options', () => {
addComponent.clickGitOptions();

addComponent.setGitReference(gitReference);
addComponent.setContextDir(contextDir);
UIhelper.clickButton('Next', { invoke: true });
addComponent.submit();
Common.waitForLoad();
});

it('Update Build & deploy configuration', () => {
Common.waitForLoad();
cy.get(ComponentsPagePO.extractComponentName).then((innerText) => {
componentPage.componentName = innerText.text().trim();

componentPage.expandDetails(componentPage.componentName);
componentPage.setCpuByButton(cpuCount + 1, cpuUnit);
componentPage.setRam(ramValue, ramUnit);
});
componentPage.setApplicationName(applicationName);
componentPage.extractComponentName();
componentPage.setCpuByButton(cpuCount + 1, cpuUnit);
componentPage.setRam(ramValue, ramUnit);
});

it('Update replicas in advanced deployment options and set Env var', () => {
componentPage.showAdvancedOptions();
it('Update replicas in and set Env var', () => {
componentPage.setReplicas(replicaCount);
componentPage.addEnvVar('secondEnvVar', '3000');
});
Expand All @@ -71,7 +56,7 @@ describe('Create Component from Public Git Source', { tags: ['@PR-check', '@publ
);
});

it('Check python component should not exists', () => {
it('Check python component does not exist', () => {
cy.contains('python-app-multi-components').should('not.exist');
});
});
Expand Down
Loading

0 comments on commit 9f402b5

Please sign in to comment.