Skip to content

Commit dd00b8c

Browse files
author
Nathan Jones
committed
WIP e2e tests
1 parent 9f7432a commit dd00b8c

File tree

6 files changed

+24
-20
lines changed

6 files changed

+24
-20
lines changed

src/test-e2e/app.po.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { browser, by, element } from 'protractor';
22

33
export class AppPage {
44
navigateTo() {
5-
return browser.get('/');
5+
return browser.driver.get('/');
66
}
77

88
getParagraphText() {

src/test-e2e/e2e.ts

+11-5
Original file line numberDiff line numberDiff line change
@@ -195,28 +195,34 @@ export class E2ESetup {
195195
return userType === ConsoleUserType.admin ? this.adminReq : this.userReq;
196196
}
197197

198-
private async doSetup() {
198+
private doSetup() {
199+
const p = promise.fulfilled(true);
200+
199201
// Create the sessions neeed
200202
if (this.needAdminSession) {
201-
await this.createSession(this.adminReq, ConsoleUserType.admin);
203+
p.then(() => this.createSession(this.adminReq, ConsoleUserType.admin));
202204
}
203205

204206
if (this.needUserSession) {
205-
await this.createSession(this.userReq, ConsoleUserType.user);
207+
p.then(() => this.createSession(this.userReq, ConsoleUserType.user));
206208
}
207209

208-
this.setupOps.forEach(async op => {
209-
await protractor.promise.controlFlow().execute(() => op.bind(this)());
210+
this.setupOps.forEach(op => {
211+
p.then(() => protractor.promise.controlFlow().execute(() => op.bind(this)()));
210212
});
213+
214+
return promise;
211215
}
212216

213217
private addSetupOp(fn: Function, desc?: string) {
218+
const that = this;
214219
this.setupOps.push(() => protractor.promise.controlFlow().execute(() => {
215220
E2E.debugLog(desc || 'Performing setup op');
216221
return fn();
217222
}));
218223
return this;
219224
}
225+
220226
}
221227

222228
/**

src/test-e2e/endpoints/endpoints.po.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,9 @@ export class EndpointsTable extends ListTableComponent {
1616

1717
async getEndpointData(row: ElementFinder) {
1818
const allRows = row.all(by.tagName('app-table-cell') as ElementFinder);
19-
const favoriteCell = allRows.get(6);
20-
const favElement = favoriteCell.element(`app-table-cell-favorite app-table-cell-favorite ${FavoritesStarMock.BASE_CLASS_SELECTOR}`);
21-
console.log(await favElement.getText());
19+
const star = await allRows.get(6).getWebElement();
2220
const favorite = new FavoritesStarMock(
23-
favElement
21+
element(star)
2422
);
2523
const data = {
2624
name: await allRows.get(0).getText(),
@@ -55,7 +53,7 @@ export class EndpointsTable extends ListTableComponent {
5553

5654
async setEndpointAsFavorite(name: string) {
5755
const data = await this.getEndpointDataForEndpoint(name);
58-
data.favorite.set();
56+
await data.favorite.set();
5957
}
6058

6159
openActionMenu(row: ElementFinder) {

src/test-e2e/home/home-e2e.spec.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ fdescribe('Home', () => {
2828
fit('- should have favorites list', async () => {
2929
await endpointPage.navigateTo();
3030
await endpointPage.table.setEndpointAsFavorite(toConnect.name);
31-
await dashboardPage.navigateTo();
32-
await dashboardPage.favoritesList.waitUntilShown();
33-
const starShown = await dashboardPage.favoritesList.endpointCard.isFavoriteStarShown();
34-
expect(starShown).toBe(true);
31+
// await dashboardPage.navigateTo();
32+
// await dashboardPage.favoritesList.waitUntilShown();
33+
// const starShown = await dashboardPage.favoritesList.endpointCard.isFavoriteStarShown();
34+
// expect(starShown).toBe(true);
3535
});
3636
});

src/test-e2e/po/favorites/favorite-star.po.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,9 @@ export class FavoritesStarMock extends Component {
88
}
99

1010
public async isFavorite() {
11-
const favoriteIcon = this.finder.element('mat-icon');
11+
const favoriteIcon = this.finder;
1212
const icon = await favoriteIcon.getText();
13+
console.log(icon)
1314
return icon === 'star';
1415
}
1516

src/test-e2e/po/favorites/favorites-global-list.endpoint.component.po.ts

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@ import { by, ElementFinder } from 'protractor';
33
import { BASE_CSS_SELECTOR } from './favorite-test-helpers';
44
import { MetaCard, MetaCardTitleType } from '../meta-card.po';
55

6-
export class FavoritesGlobalListEndpointMock extends MetaCard {
6+
export class FavoritesGlobalListEndpointMock {
77
static readonly SELECTOR = `${BASE_CSS_SELECTOR}__endpoint-card`;
88
constructor(groupElementFinder: ElementFinder) {
9-
groupElementFinder.getText().then(console.log);
10-
const endpointCard = groupElementFinder.element(by.css(FavoritesGlobalListEndpointMock.SELECTOR));
11-
super(endpointCard, MetaCardTitleType.CUSTOM);
9+
// const endpointCard = groupElementFinder.element(by.css(FavoritesGlobalListEndpointMock.SELECTOR));
10+
// super(endpointCard, MetaCardTitleType.CUSTOM);
1211
}
1312
}

0 commit comments

Comments
 (0)