Skip to content

Commit

Permalink
fix(test): fix advanced happy path
Browse files Browse the repository at this point in the history
  • Loading branch information
Katka92 committed Jun 12, 2024
1 parent a598cfd commit 1c19720
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ export const ComponentsPagePO = {
customBuildRequestedState: '[data-testid="requested-state"]',
label: '[class="pf-v5-c-label__content"]',
customBuildPipelineModalCloseBtn: '[data-test="close-button custom-pipeline-modal"]',
dockerfileInput: 'input[id="form-input-source-git-dockerfileUrl-field"]',
};

export const applicationDetailPagePO = {
Expand Down
8 changes: 8 additions & 0 deletions integration-tests/support/pages/ComponentsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ import { componentDetailsPO } from '../pageObjects/pages-po';
import { AbstractWizardPage } from './AbstractWizardPage';

export class ComponentPage extends AbstractWizardPage {
setDockerfilePath(dockerfilePath: string) {
cy.get(ComponentsPagePO.dockerfileInput).clear().type(dockerfilePath);
}

clickSubmitButton() {
cy.get(ComponentsPagePO.create).should('be.enabled').click();
}

openPipelinePlanModal() {
cy.contains('button', 'Merge pull request').should('be.visible').click();
}
Expand Down
4 changes: 4 additions & 0 deletions integration-tests/support/pages/SecretsPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ import { UIhelper } from '../../utils/UIhelper';
import { actions } from '../pageObjects/global-po';

export class SecretsPage {
static searchSecret(secretName: string) {
cy.get('[name="nameInput"]').clear().type(secretName);
}

static deleteSecret(secretName: string) {
UIhelper.getTableRow('Secret List', secretName).find(actions.kebabButton).click();
cy.get(actions.delete).click();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ export class IntegrationTestsTabPage {
this.verifySaveChangesIsDisabled();
UIhelper.inputValueInTextBoxByLabelName('Integration test name', integrationTestName);
UIhelper.inputValueInTextBoxByLabelName('GitHub URL', githubURL);
cy.contains(addIntegrationTestStepPO.accessValidationMsg, 'Access validated', {
timeout: 80000,
}).should('be.visible');
UIhelper.inputValueInTextBoxByLabelName('Revision', revision);
UIhelper.inputValueInTextBoxByLabelName('Path in repository', pathInRepository);
if (markOptionalForRelease === 'uncheck') {
Expand All @@ -56,9 +53,6 @@ export class IntegrationTestsTabPage {

if (githubURL) {
UIhelper.inputValueInTextBoxByLabelName('GitHub URL', githubURL);
cy.contains(addIntegrationTestStepPO.accessValidationMsg, 'Access validated', {
timeout: 80000,
}).should('be.visible');
}

if (markOptionalForRelease === 'uncheck')
Expand Down
8 changes: 0 additions & 8 deletions integration-tests/support/pages/tabs/LatestCommitsTabPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ export class LatestCommitsTabPage {
);
}

verifyBranch(branchName: string, repoLink: string) {
UIhelper.verifyLabelAndValue('Branch', branchName).should(
'have.attr',
'href',
`${repoLink}/tree/${branchName}`,
);
}

verifyNodesOnCommitOverview(nodes: string[]) {
nodes.forEach((nodetext) => {
UIhelper.verifyGraphNodes(nodetext);
Expand Down
23 changes: 18 additions & 5 deletions integration-tests/tests/advanced-happy-path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('Advanced Happy path', () => {
const gitHubUser = Cypress.env('GH_USERNAME');
const componentName = Common.generateAppName('go');
const pipeline = 'docker-build';
const dockerfilePath = 'docker/Dockerfile';

after(function () {
// If some test failed, don't remove the app
Expand Down Expand Up @@ -85,13 +86,23 @@ describe('Advanced Happy path', () => {
});
});

it('Create an Application with a component', () => {
Applications.createApplication(applicationName);
Applications.createComponent(repoLink, componentName, pipeline, applicationName, secret);
it('Create clean application and add a component', () => {
Applications.createCleanApp(applicationName);
Applications.goToOverviewTab().addComponent();
Applications.createComponent(
repoLink,
componentName,
pipeline,
undefined,
dockerfilePath,
secret,
);
});

describe('Trigger a new Pipelinerun related to push event', () => {
it('Merge the auto-generated PR, and verify the event status on modal', () => {
Applications.goToComponentsTab();
componentPage.openPipelinePlanModal();
componentPage.verifyAndWaitForPRIsSent();

APIHelper.mergePR(
Expand All @@ -103,6 +114,7 @@ describe('Advanced Happy path', () => {
);

componentPage.verifyAndWaitForPRMerge();

componentPage.closeModal();
});

Expand All @@ -111,7 +123,7 @@ describe('Advanced Happy path', () => {
componentName,
applicationName,
'Build running',
'Custom',
'Automatic',
);
});

Expand Down Expand Up @@ -458,7 +470,7 @@ describe('Advanced Happy path', () => {
Cypress.env(`${componentInfo.updatedCommitMessage}_SHA`),
repoLink,
); // Commit SHA was stored in dynamic env at latestCommitsTabPage.editFile()
latestCommitsTabPage.verifyBranch('main', repoLink);
UIhelper.verifyLabelAndValue('Branch', 'main');
UIhelper.verifyLabelAndValue('By', gitHubUser);
UIhelper.verifyLabelAndValue('Status', 'Succeeded');
latestCommitsTabPage.verifyNodesOnCommitOverview(['commit', `${componentName}-build`]);
Expand Down Expand Up @@ -501,6 +513,7 @@ describe('Advanced Happy path', () => {
});

it('Verify Secret on Secret List', () => {
SecretsPage.searchSecret(secret.secretName);
UIhelper.verifyRowInTable('Secret List', secret.secretName, ['Key/value']);
});

Expand Down
2 changes: 1 addition & 1 deletion integration-tests/tests/basic-happy-path.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe('Basic Happy Path', () => {

it('Create an Application with a component', () => {
Applications.createApplication(applicationName);
Applications.createComponent(publicRepo, componentName, pipeline, applicationName);
Applications.createComponent(publicRepo, componentName, pipeline);
Applications.checkComponentInListView(
componentName,
applicationName,
Expand Down
19 changes: 16 additions & 3 deletions integration-tests/utils/Applications.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,15 @@ import { Common } from './Common';
import { UIhelper } from './UIhelper';

export class Applications {
static createCleanApp(applicationName: string) {
cy.title().should('eq', `Applications | ${FULL_APPLICATION_TITLE}`);
const createApplicationPage = new CreateApplicationPage();
createApplicationPage.clickCreateApplication();
cy.testA11y(`${pageTitles.createApp} page`);
createApplicationPage.setApplicationName(applicationName);
createApplicationPage.clickCreateApplication();
}

static deleteApplication(applicationName: string) {
APIHelper.requestHACAPI({
method: 'DELETE',
Expand Down Expand Up @@ -48,16 +57,16 @@ export class Applications {
componentName: string,
pipeline: string,
applicationName?: string,
dockerfilePath?: string,
secret?: { secretName: string; key: string; value: string },
) {
const addComponent = new AddComponentPage();
const componentPage = new ComponentPage();
cy.title().should('eq', `Applications | ${FULL_APPLICATION_TITLE}`);

addComponent.setSource(publicGitRepo);
this.configureComponentsStep(componentName, pipeline, applicationName, secret);
this.configureComponentsStep(componentName, pipeline, applicationName, dockerfilePath, secret);
addComponent.waitRepoValidated();
componentPage.clickCreateApplication();
componentPage.clickSubmitButton();
}

static checkComponentInListView(
Expand Down Expand Up @@ -136,6 +145,7 @@ export class Applications {
componentName: string,
pipeline: string,
applicationName?: string,
dockerfilePath?: string,
secret?: { secretName: string; key: string; value: string },
) {
const componentPage = new ComponentPage();
Expand All @@ -145,6 +155,9 @@ export class Applications {
if (applicationName) {
componentPage.setApplicationName(applicationName);
}
if (dockerfilePath) {
componentPage.setDockerfilePath(dockerfilePath);
}
if (secret) {
UIhelper.clickButton('Add secret');
cy.contains(applicationsPagePO.formGroup, 'Select or enter name').within(() => {
Expand Down

0 comments on commit 1c19720

Please sign in to comment.