Skip to content
Snippets Groups Projects
Commit 01d21ef4 authored by Nathan Hertz's avatar Nathan Hertz
Browse files

Wrote e2e tests testing that UI elements are displayed correctly and

that clicking the buttons creates corresponding requests and executions
parent f8976e2c
No related branches found
No related tags found
1 merge request!168WS-28: protractor end-to-end tests
Pipeline #1129 passed
......@@ -12,7 +12,7 @@ exports.config = {
'browserName': 'chrome'
},
directConnect: true,
baseUrl: 'http://localhost:4200/',
baseUrl: 'http://localhost:4444/',
framework: 'jasmine',
jasmineNodeOpts: {
showColors: true,
......@@ -25,4 +25,4 @@ exports.config = {
});
jasmine.getEnv().addReporter(new SpecReporter({ spec: { displayStacktrace: true } }));
}
};
\ No newline at end of file
};
import { AppPage } from "./app.po";
import {
browser,
by,
element,
ElementFinder,
logging,
protractor,
} from "protractor";
import { WorkspacesComponent } from "../../src/app/workspaces/workspaces.component";
describe("workspace-project App", () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
browser.get("http://localhost:4444/workspaces");
expect(browser.getCurrentUrl()).toBe("http://localhost:4444/workspaces");
});
it("should display science product text box for download parameters", () => {
const splInputTxtBox: ElementFinder = element(by.css("#splInput"));
const splInputLabel: ElementFinder = element(by.css("label[for=splInput]"));
expect(splInputLabel.getText()).toEqual("Science Product");
expect(splInputTxtBox.getAttribute("value")).toEqual(
"uid://evla/image/3d3db489-9331-4e61-aa80-002bc2989b1e"
);
});
it("should display email text box for download parameters", () => {
const emailTxtBox: ElementFinder = element(by.css("#userEmail"));
const emailLabel: ElementFinder = element(by.css("label[for=userEmail]"));
expect(emailLabel.getText()).toEqual("Email Address");
expect(emailTxtBox.getAttribute("value")).toEqual("");
});
it('should display a "launch download capability" button', () => {
expect(page.getLaunchDownloadCapabilityButton().getText()).toEqual(
"Launch download capability"
);
});
it('should display capability request and execution when "launch download capability" button clicked', () => {
const launchDownloadCapabilityButton: ElementFinder = element(
by.css("#launchDownloadCapabilityBtn")
);
browser
.wait(
protractor.ExpectedConditions.elementToBeClickable(
launchDownloadCapabilityButton
),
5000
)
.then(() => {
launchDownloadCapabilityButton.click();
});
browser.sleep(1000);
expect(
page.getCapabilityResults().element(by.css("#request-0")).getText()
).toContain("Capability request created: ");
expect(
page.getCapabilityResults().element(by.css("#execution-0")).getText()
).toContain("Capability execution created: ");
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(
jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry)
);
});
});
import { AppPage } from './app.po';
import { browser, logging } from 'protractor';
describe('workspace-project App', () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
});
it('should display welcome message', () => {
page.navigateTo();
expect(page.getTitleText()).toEqual('Welcome to archive2!');
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry));
});
});
import { AppPage } from "./app.po";
import {
browser,
by,
element,
ElementFinder,
logging,
protractor,
} from "protractor";
describe("workspace-project App", () => {
let page: AppPage;
beforeEach(() => {
page = new AppPage();
browser.get("http://localhost:4444/workspaces");
expect(browser.getCurrentUrl()).toBe("http://localhost:4444/workspaces");
});
it('should display a "launch null capability" button', () => {
expect(page.getLaunchNullCapabilityButton().getText()).toEqual(
"Launch null capability"
);
});
it('should display capability request and execution when "launch null capability" button clicked', () => {
const launchNullCapabilityButton: ElementFinder = element(
by.css("#launchNullCapabilityBtn")
);
browser
.wait(
protractor.ExpectedConditions.elementToBeClickable(
launchNullCapabilityButton
),
5000
)
.then(() => {
launchNullCapabilityButton.click();
});
browser.sleep(1000);
expect(
page.getCapabilityResults().element(by.css("#request-0")).getText()
).toContain("Capability request created: ");
expect(
page.getCapabilityResults().element(by.css("#execution-0")).getText()
).toContain("Capability execution created: ");
});
afterEach(async () => {
// Assert that there are no errors emitted from the browser
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
expect(logs).not.toContain(
jasmine.objectContaining({
level: logging.Level.SEVERE,
} as logging.Entry)
);
});
});
import { browser, by, element } from 'protractor';
import { browser, by, element, ElementFinder } from "protractor";
export class AppPage {
navigateTo() {
navigateToBase() {
return browser.get(browser.baseUrl) as Promise<any>;
}
getTitleText() {
return element(by.css('app-root h1')).getText() as Promise<string>;
navigateToWorkspacesHome() {
console.log(browser.baseUrl);
return browser.get(`${browser.baseUrl}/workspaces`) as Promise<any>;
}
getLaunchNullCapabilityButton() {
return element(by.css("#launchNullCapabilityBtn"));
}
getLaunchDownloadCapabilityButton() {
return element(by.css("#launchDownloadCapabilityBtn"));
}
getCapabilityResults() {
return element(by.css("#capabilityResults"));
}
}
<div class="container-fluid">
<div class="row py-2">
<div class="col">
<button type="button" class="btn btn-secondary" (click)="nullButtonOnClick()">Launch null capability</button>
<button type="button" id="launchNullCapabilityBtn" class="btn btn-secondary" (click)="nullButtonOnClick()">Launch null capability</button>
</div>
</div>
......@@ -22,12 +22,12 @@
<div class="row py-2">
<div class="col">
<button type="button" class="btn btn-warning" (click)="downloadButtonOnClick()">Launch download capability</button>
<button type="button" id="launchDownloadCapabilityBtn" class="btn btn-warning" (click)="downloadButtonOnClick()">Launch download capability</button>
</div>
</div>
</div>
<div class="p-2" *ngFor="let request of capabilityRequests; index as i">
<code>Capability request created: {{request | json}}</code><br>
<code *ngIf="capabilityExecutions[i]">Capability execution created: {{capabilityExecutions[i] | json}}</code><br/>
<div class="p-2" id="capabilityResults" *ngFor="let request of capabilityRequests; index as i">
<code id="request-{{i}}">Capability request created: {{request | json}}</code><br>
<code id="execution-{{i}}">Capability *ngIf="capabilityExecutions[i]">Capability execution created: {{capabilityExecutions[i] | json}}</code><br/>
</div>
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment