Skip to content
This repository has been archived by the owner on Jan 24, 2023. It is now read-only.

Commit

Permalink
Ensure list is card mode before waiting to find a card
Browse files Browse the repository at this point in the history
  • Loading branch information
richard-cox committed Dec 4, 2020
1 parent 9b5841a commit e44d6ea
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/test-e2e/endpoints/endpoints.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { ElementFinder } from 'protractor/built';

import { E2EEndpointConfig } from '../e2e.types';
import { ConsoleUserType, E2EHelpers } from '../helpers/e2e-helpers';
import { ListCardComponent, ListComponent, ListHeaderComponent, ListTableComponent } from '../po/list.po';
import { ListCardComponent, ListComponent, ListTableComponent } from '../po/list.po';
import { MetaCard, MetaCardItem } from '../po/meta-card.po';
import { Page } from '../po/page.po';
import { SnackBarPo } from '../po/snackbar.po';

export class EndpointCards extends ListCardComponent {
constructor(locator: ElementFinder, header: ListHeaderComponent) {
super(locator, header);
constructor(locator: ElementFinder, list: ListComponent) {
super(locator, list);
}

findCardByTitle(title: string, subtitle = 'Cloud Foundry'): promise.Promise<MetaCard> {
Expand Down Expand Up @@ -108,7 +108,7 @@ export class EndpointsPage extends Page {

// Endpoints table (as opposed to generic list.table)
public table = new EndpointsTable(this.list.getComponent());
public cards = new EndpointCards(this.list.locator, this.list.header);
public cards = new EndpointCards(this.list.locator, this.list);

constructor() {
super('/endpoints');
Expand Down
15 changes: 11 additions & 4 deletions src/test-e2e/po/list.po.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ export class ListCardComponent extends Component {

static cardsCss = 'app-card:not(.row-filler)';

constructor(locator: ElementFinder, private header: ListHeaderComponent) {
constructor(locator: ElementFinder, private list: ListComponent) {
super(locator);
}

Expand All @@ -181,6 +181,13 @@ export class ListCardComponent extends Component {
}

private findCardElementByTitle(title: string, metaType = MetaCardTitleType.CUSTOM): ElementFinder {
this.list.header.getCardListViewToggleButton().click();
this.list.isTableView().then(isTableView => {
if (isTableView) {
return this.list.header.getCardListViewToggleButton().click();
}
});

const card = this.locator.all(by.css(`${ListCardComponent.cardsCss} ${metaType}`)).filter(elem =>
elem.getText().then(text => text === title)
).first();
Expand All @@ -198,8 +205,8 @@ export class ListCardComponent extends Component {

findCardByTitle(title: string, metaType = MetaCardTitleType.CUSTOM, filter = false): promise.Promise<MetaCard> {
if (filter) {
this.header.waitUntilShown();
this.header.setSearchText(title);
this.list.header.waitUntilShown();
this.list.header.setSearchText(title);
return this.waitForCardByTitle(title, metaType);
}

Expand Down Expand Up @@ -485,7 +492,7 @@ export class ListComponent extends Component {
super(locator);
this.table = new ListTableComponent(locator);
this.header = new ListHeaderComponent(locator);
this.cards = new ListCardComponent(locator, this.header);
this.cards = new ListCardComponent(locator, this);
this.pagination = new ListPaginationComponent(locator);
this.empty = new ListEmptyComponent(locator);
}
Expand Down

0 comments on commit e44d6ea

Please sign in to comment.