Skip to content

Commit

Permalink
pipeline test iteration v2
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanket committed Feb 5, 2020
1 parent c984599 commit 1ef54ce
Show file tree
Hide file tree
Showing 4 changed files with 204 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ import {
pipelineOverviewName,
pipelineTable,
pipelineTableBody,
pipelineStartKebab,
pipelineFilter,
pipelineStart,
pipelineRun,
pipelineRerun,
pipelineActionList,
pipelineStartLastRun,
pipelineSelect,
pipelineRuns,
pipelineRunLogs,
} from '../views/pipeline.view';
import * as sidenavView from '../../../../integration-tests/views/sidenav.view';
import * as crudView from '../../../../integration-tests/views/crud.view';
Expand All @@ -30,6 +40,7 @@ const JASMINE_EXTENDED_TIMEOUT_INTERVAL = 1000 * 60 * 3;

describe('Pipeline', async () => {
beforeAll(async () => {
await switchPerspective(Perspective.Administrator);
await browser.get(`${appHost}/k8s/cluster/projects`);
await browser.wait(until.presenceOf(sidenavView.navSectionFor('Operators')));
await sidenavView.clickNavLink(['Operators', 'OperatorHub']);
Expand All @@ -54,9 +65,10 @@ describe('Pipeline', async () => {
await catalogView.categoryTabsPresent();
await catalogView.categoryTabs.get(0).click();
await catalogPageView.catalogTileFor('Pipelines Operator').click();
await browser.wait(until.visibilityOf(operatorHubView.operatorModal));
await browser.wait(until.visibilityOf(operatorHubView.communityWarningModal));
await browser.wait(until.presenceOf(element(by.id('confirm-action'))));
await element(by.id('confirm-action')).click();
await browser.wait(until.visibilityOf(operatorHubView.operatorModal));
await browser.wait(until.presenceOf(operatorHubView.operatorModalInstallBtn));
await operatorHubView.operatorModalInstallBtn.click();
await operatorHubView.createSubscriptionFormLoaded();
Expand All @@ -79,7 +91,7 @@ describe('Pipeline', async () => {

it(`displays Operator in "Cluster Service Versions" view for "${testName}" namespace`, async () => {
await retry(() => catalogPageView.catalogTileFor('OpenShift Pipelines Operator').click());
await operatorHubView.operatorModalIsLoaded();
await browser.wait(until.visibilityOf(operatorHubView.communityWarningModal));
await element(by.id('confirm-action')).click();
await operatorHubView.viewInstalledOperator();
await crudView.isLoaded();
Expand All @@ -91,6 +103,7 @@ describe('Pipeline', async () => {
});

it('pipeline is installed', async () => {
await browser.get(`${appHost}/k8s/cluster/projects/${testName}`);
await switchPerspective(Perspective.Developer);
expect(sideHeader.getText()).toContain('Developer');
await browser.wait(until.visibilityOf(pageSidebar));
Expand Down Expand Up @@ -120,4 +133,70 @@ describe('Pipeline', async () => {
true,
);
});
it('start pipeline scenario', async () => {
let runName: string;
await browser.get(`${appHost}/k8s/cluster/projects/${testName}`);
await switchPerspective(Perspective.Developer);
await browser.wait(until.visibilityOf(pageSidebar));
await pipelinecheckStatus();
await execSync(
`oc create -f ./packages/dev-console/integration-tests/views/sample-app-pipeline.yaml -n ${testName}`,
);
await browser.wait(until.visibilityOf(pipelineTable));
expect(
pipelineTableBody.element(by.css('[data-test-id="sample-app-pipeline"]')).isPresent(),
).toBe(true);

await pipelineFilter.click();
await pipelineFilter.sendKeys('sample-app-pipeline');
await browser.wait(
until.visibilityOf(pipelineTableBody.element(by.css('[data-test-id="sample-app-pipeline"]'))),
);
await pipelineStartKebab.click();
await browser.wait(until.elementToBeClickable(pipelineStart));
browser.sleep(5000);
await pipelineStart.click();
await browser.wait(
until.visibilityOf(element(by.cssContainingText('h2', 'Pipeline Run Overview'))),
);
await pipelineOverviewName.getText().then(function(divText) {
runName = divText;
});
await pipelinecheckStatus();
await browser.wait(until.visibilityOf(pipelineTableBody));
await element(by.css('[data-test-id="sample-app-pipeline"]')).click();
await browser.wait(until.visibilityOf(pipelineRun));
await pipelineRun.click();
const pipelines = element(by.css(`[data-test-id="${runName}"]`));
await browser.wait(until.visibilityOf(pipelines));
await expect(pipelines.getText()).toBe(runName);

await pipelineStartKebab.click();
await browser.wait(until.visibilityOf(pipelineRerun));
await pipelineRerun.click();
await browser.wait(until.visibilityOf(pipelineActionList));
await pipelineActionList.click();
await pipelineStartLastRun.click();
await browser.wait(until.elementToBeClickable(pipelineRuns), 5000);
await browser.sleep(4000);
await pipelineRuns.click();
await browser.wait(until.visibilityOf(pipelineTableBody));
await pipelineTableBody.getAttribute('childElementCount').then(function(value) {
expect(value).toBe('3');
});
await pipelineSelect(runName).click();
await pipelineRunLogs.click();
// browser.wait(function() {
// return element(by.className('odc-pipeline-run-logs__tasklist')).isLoaded()
// });

await browser.wait(until.presenceOf(element(by.className('odc-pipeline-run-logs__tasklist'))));
await element(by.className('odc-pipeline-run-logs__tasklist'))
.getText()
.then(function(text) {
const sample = text.replace(/\s+/g, ' ');
// expect(text.replace(/\s+/g, ' ')).toContain('install-deps compile code-sanity e2e-tests');
expect(sample).toContain('install-deps');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,31 @@ export const pipelineTableBody = element(
);
export const pipelineGraph = $('.odc-pipeline-vis-graph__stages');
export const pipelineOverviewName = element(by.css('[data-test-id="resource-title"]'));
export const pipelineFilter = element(by.className('pf-c-form-control co-text-filter'));
export const pipelineStartKebab = pipelineTableBody.element(
by.css('[data-test-id="kebab-button"]'),
);
export const pipelineActions = element(by.css('[data-test-id="action-items"]'));
export const pipelineStart = element(
by.cssContainingText('button.pf-c-dropdown__menu-item', 'Start'),
);
export const pipelineDelete = element(
by.cssContainingText('button.pf-c-dropdown__menu-item', 'Delete Pipeline'),
);
export const pipelineRun = element(
by.cssContainingText('li.co-m-horizontal-nav__menu-item', 'Pipeline Runs'),
);
export const pipelineRuns = element(by.css('[data-test-id="breadcrumb-link-0"]'));
export const pipelineSelect = function(name) {
const newpipelineSelect = element(by.css(`[data-test-id="${name}"]`));
return newpipelineSelect;
};
export const pipelineRerun = element(by.cssContainingText('button', 'Rerun'));
export const pipelineActionList = element(by.css('[data-test-id="actions-menu-button"]'));
export const pipelineStartLastRun = element(by.cssContainingText('button', 'Start Last Run'));
export const pipelineRunLogs = element(
by.cssContainingText('li.co-m-horizontal-nav__menu-item', 'Logs'),
);

export const pipelineScriptRunner = async function() {
await browser.wait(until.presenceOf(createPipelineYaml));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
apiVersion: tekton.dev/v1alpha1
kind: Pipeline
metadata:
name: sample-app-pipeline
spec:
tasks:
- name: install-deps
taskRef:
name: install-dependencies
- name: code-sanity
taskRef:
name: lint-and-test
runAfter:
- install-deps
- name: compile
taskRef:
name: build-dist
runAfter:
- install-deps
- name: e2e-tests
taskRef:
name: run-e2e-tests
runAfter:
- code-sanity
- compile

---

apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: install-dependencies
spec:
steps:
- name: install
image: ubuntu
command:
- echo
args:
- "Installing dependencies...\n\nDependencies installed successfully."
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: lint-and-test
spec:
steps:
- name: startup
image: ubuntu
command:
- echo
args:
- "Running Linter and Tests"
- name: lint-errors
image: ubuntu
command:
- echo
args:
- "0 Lint Errors"
- name: test-status
image: ubuntu
command:
- echo
args:
- "0 Test Failures"
- name: coverage-report
image: ubuntu
command:
- echo
args:
- "Exporting Test Coverage Report...\n\nCoverage report can be found in __coverage__"
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: build-dist
spec:
steps:
- name: build
image: ubuntu
command:
- echo
args:
- "Compiling code and producing dist folder...\n\nFolder public/dist created"
---
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
name: run-e2e-tests
spec:
steps:
- name: status
image: ubuntu
command:
- echo
args:
- "Running end-to-end tests...\n\nAll tests pass"
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { browser, $, ExpectedConditions as until, by, element } from 'protractor';

export const operatorModal = $('.pf-c-modal-box');
export const operatorModal = $('.co-catalog-page__overlay');
export const operatorModalIsLoaded = () =>
browser.wait(until.presenceOf(operatorModal), 1000).then(() => browser.sleep(500));
export const operatorModalTitle = operatorModal.$('.catalog-item-header-pf-title');
Expand Down

0 comments on commit 1ef54ce

Please sign in to comment.