Skip to content

Commit

Permalink
Finish editor test conversion, not yet cleaned-up
Browse files Browse the repository at this point in the history
  • Loading branch information
JeanneSon authored and megahirt committed Sep 5, 2022
1 parent 04fbe1f commit ee8ac28
Show file tree
Hide file tree
Showing 11 changed files with 496 additions and 457 deletions.
Binary file added test/common/TestLexProject/audio/TestAudio.mp3
Binary file not shown.
Binary file added test/common/TestLexProject/pictures/IMG_0214.JPG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/common/TestLexProject/pictures/TestImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions test/e2e/components/notice.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ export class NoticeElement {
readonly notice: Locator;
readonly noticeMessage: Locator;
readonly noticeDetails: Locator;
readonly closeButton: Locator;

constructor(page: Page) {
this.page = page;
this.notice = page.locator('[ng-repeat="notice in $ctrl.notices()"]');
this.noticeMessage = page.locator('[data-ng-hide="notice.details"]');
this.noticeDetails = page.locator('[ng-show="notice.details"]');
this.closeButton = this.notice.locator('.close');
}
}
881 changes: 431 additions & 450 deletions test/e2e/editor-entry.spec.ts

Large diffs are not rendered by default.

7 changes: 4 additions & 3 deletions test/e2e/pages/configuration.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export class ConfigurationPage {
}

async getTable(tableTitle: string): Promise<Locator> {
return this.page.locator(`tbody:has(th:has-text("${tableTitle}"))`);
return this.page.locator(`table:has(th:has-text("${tableTitle}"))`);
}

async getRow(tableLocator: Locator, rowTitle: string): Promise<Locator> {
Expand All @@ -47,7 +47,7 @@ export class ConfigurationPage {
const table: Locator = await this.getTable(tableTitle);
const row: Locator = await this.getRow(table, rowTitle);
const columnIndex = await this.getChildPosition(table.locator('tr').first(), 'th', columnTitle);
return row.locator('td').nth(columnIndex).locator('input');
return row.locator('css=td,th').nth(columnIndex).locator('input');
}

async getFieldSpecificButton(tableTitle: string, rowTitle: string): Promise<Locator> {
Expand All @@ -68,11 +68,12 @@ export class ConfigurationPage {

async getChildPosition(parentLocator: Locator, childElementType: string, innerText: string): Promise<number> {
const children = parentLocator.locator(childElementType);
for (let i=0; i <= await children.count(); i++) {
for (let i=0; i < await children.count(); i++) {
if (await children.nth(i).innerText() == innerText) {
return i;
}
}
console.log(`Warning: there is no element with text ${innerText} with the parent ${parentLocator}.`);
return undefined;
}
}
59 changes: 55 additions & 4 deletions test/e2e/pages/editor.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,19 @@ type LexAppToolbar = {
toggleExtraFieldsButton: Locator
};

// JeanneSonTODO: search/filter is also used in entries list so extract this
type Search = {
searchInput: Locator,
matchCount: Locator
}

type ActionMenu = {
toggleMenuButtonSelector: string,
deleteCardButtonSelector: string,
moveDownButtonSelector: string,
moveUpButtonSelector: string
}

type AudioPlayer = {
togglePlaybackAnchorSelector: string,
playIconSelector: string,
Expand All @@ -19,7 +32,8 @@ type AudioPlayer = {
type Dropbox = {
dragoverFieldSelector: string,
audioCancelButtonSelector: string,
pictureCancelButtonSelector: string
pictureCancelButtonSelector: string,
browseButtonSelector: string
};

type UploadType =
Expand All @@ -28,7 +42,8 @@ type UploadType =
;

type AudioDropdownMenu = {
uploadReplacementButtonSelector: string
uploadReplacementButtonSelector: string,
deleteAudioButtonSelector: string
}

export class EditorPage {
Expand All @@ -42,8 +57,13 @@ export class EditorPage {
readonly lexAppToolbar: LexAppToolbar;
readonly renderedDivs: Locator;

readonly search: Search;

readonly entryCard: Locator;
readonly senseCard: Locator;
readonly exampleCardSelector: string;

readonly actionMenu: ActionMenu;

readonly compactEntryListContainer: Locator;
readonly compactEntryListItem: Locator;
Expand Down Expand Up @@ -73,8 +93,21 @@ export class EditorPage {
};
this.renderedDivs = this.page.locator('.dc-rendered-entryContainer');

this.search = {
searchInput: this.page.locator('#editor-entry-search-entries'),
matchCount: this.page.locator('#totalNumberOfEntries >> span')
}

this.entryCard = this.page.locator('.entry-card');
this.senseCard = this.page.locator('[data-ng-repeat="sense in $ctrl.model.senses"]');
this.exampleCardSelector = '.dc-example';

this.actionMenu = {
toggleMenuButtonSelector: '.ellipsis-menu-toggle',
deleteCardButtonSelector: '.dropdown-item:has-text("Delete")',
moveDownButtonSelector: '.dropdown-item:has-text("Move Down")',
moveUpButtonSelector: '.dropdown-item:has-text("Move Up")'
};

this.compactEntryListContainer = this.page.locator('#compactEntryListContainer');
this.compactEntryListItem = this.compactEntryListContainer.locator('.lexiconListItemCompact');
Expand All @@ -90,11 +123,13 @@ export class EditorPage {
this.dropbox = {
dragoverFieldSelector: '.drop-box',
audioCancelButtonSelector: '#audioAddCancel',
pictureCancelButtonSelector: '#addCancel'
pictureCancelButtonSelector: '#addCancel',
browseButtonSelector: '#browseButton'
};

this.audioDropdownMenu = {
uploadReplacementButtonSelector: 'a >> text=Upload a replacement'
uploadReplacementButtonSelector: 'a >> text=Upload a replacement',
deleteAudioButtonSelector: 'a >> text=Delete'
};

this.addPictureButtonSelector = 'a >> text=Add Picture';
Expand All @@ -114,10 +149,26 @@ export class EditorPage {
await this.lexAppToolbar.backToListButton.click();
}

async getLabel(card: Locator, label: string): Promise<Locator> {
return card.locator(`label:has-text("${label}")`).first();
}

async getNumberOfElementsWithSameLabel(card: Locator, label: string): Promise<number> {
return card.locator(`label:has-text("${label}")`).count();
}

async getTextarea(card: Locator, field: string, ws: string): Promise<Locator> {
return card.locator(`label:has-text("${field}") >> xpath=.. >> div.input-group:has(span.wsid:has-text("${ws}")) >> textarea`);
}

async getDropdown(card: Locator, field: string): Promise<Locator> {
return card.locator(`label:has-text("${field}") >> xpath=.. >> select`);
}

async getSelectedValueFromSelectDropdown(card: Locator, field: string): Promise<string> {
return card.locator(`label:has-text("${field}") >> xpath=.. >> select >> [selected="selected"]`).innerText();
}

async getSoundplayer(card: Locator, field: string, ws: string): Promise<Locator> {
return card.locator(`label:has-text("${field}") >> xpath=.. >> div.input-group:has(span.wsid:has-text("${ws}")) >> dc-audio`);
}
Expand Down
4 changes: 4 additions & 0 deletions test/e2e/pages/entries-list.page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ export class EntriesListPage {
readonly filterInputClearButton: Locator;
readonly matchCount: Locator;

readonly createNewWordButton: Locator;

readonly url: string;

constructor(page: Page, projectId: string) {
Expand All @@ -22,6 +24,8 @@ export class EntriesListPage {
this.filterInputClearButton = this.page.locator('.clear-search-button');
this.matchCount = this.page.locator('#totalNumberOfEntries >> span');

this.createNewWordButton = this.page.locator('#newWord');

this.url = `/app/lexicon/${this.projectId}/#!/editor/list`;
}

Expand Down
Binary file added test/e2e/shared-files/FriedRiceWithPork.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added test/e2e/shared-files/TestAudio.mp3
Binary file not shown.
Binary file added test/e2e/shared-files/TestImage.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ee8ac28

Please sign in to comment.