Skip to content

Commit

Permalink
test(Archive Run): Clean up test harnesses
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreykwan committed Aug 21, 2023
1 parent 55551cd commit 5efc759
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,28 @@ export class SelectRunsControlsHarness extends ComponentHarness {
protected getSelectAllCheckbox = this.locatorFor(MatCheckboxHarness);

async checkCheckbox(): Promise<void> {
const selectAllCheckBox = await this.getSelectAllCheckbox();
return await selectAllCheckBox.check();
return (await this.getSelectAllCheckbox()).check();
}

async uncheckCheckbox(): Promise<void> {
const selectAllCheckBox = await this.getSelectAllCheckbox();
return await selectAllCheckBox.uncheck();
return (await this.getSelectAllCheckbox()).uncheck();
}

async toggleCheckbox(): Promise<void> {
const selectAllCheckBox = await this.getSelectAllCheckbox();
return await selectAllCheckBox.toggle();
return (await this.getSelectAllCheckbox()).toggle();
}

async isChecked(): Promise<boolean> {
const checkbox = await this.getSelectAllCheckbox();
return await checkbox.isChecked();
return (await this.getSelectAllCheckbox()).isChecked();
}

async isIndeterminate(): Promise<boolean> {
const checkbox = await this.getSelectAllCheckbox();
return await checkbox.isIndeterminate();
return (await this.getSelectAllCheckbox()).isIndeterminate();
}

async clickMenuButton(menuButtonText: string): Promise<void> {
const menu = await this.getMenu();
await menu.open();
return await menu.clickItem({ text: menuButtonText });
return menu.clickItem({ text: menuButtonText });
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,16 @@ export class TeacherRunListItemHarness extends ComponentHarness {
protected getMenu = this.locatorFor(MatMenuHarness);

async checkCheckbox(): Promise<void> {
const checkbox = await this.getCheckbox();
return await checkbox.check();
return (await this.getCheckbox()).check();
}

async isChecked(): Promise<boolean> {
const checkbox = await this.getCheckbox();
return await checkbox.isChecked();
return (await this.getCheckbox()).isChecked();
}

async clickMenuButton(menuButtonText: string): Promise<void> {
const menu = await this.getMenu();
await menu.open();
return await menu.clickItem({ text: menuButtonText });
return menu.clickItem({ text: menuButtonText });
}
}
42 changes: 14 additions & 28 deletions src/app/teacher/teacher-run-list/teacher-run-list.harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,72 +15,58 @@ export class TeacherRunListHarness extends ComponentHarness {
);

async isShowingArchived(): Promise<boolean> {
const archiveToggle = await this.getArchiveToggle();
return await archiveToggle.isChecked();
return (await this.getArchiveToggle()).isChecked();
}

async toggleArchiveToggle(): Promise<void> {
const archiveToggle = await this.getArchiveToggle();
return await archiveToggle.toggle();
return (await this.getArchiveToggle()).toggle();
}

async checkSelectRunsCheckbox(): Promise<void> {
const selectRunsControls = await this.getSelectRunsControls();
return await selectRunsControls.checkCheckbox();
return (await this.getSelectRunsControls()).checkCheckbox();
}

async uncheckSelectRunsCheckbox(): Promise<void> {
const selectRunsControls = await this.getSelectRunsControls();
return await selectRunsControls.uncheckCheckbox();
return (await this.getSelectRunsControls()).uncheckCheckbox();
}

async toggleSelectRunsCheckbox(): Promise<void> {
const selectRunsControls = await this.getSelectRunsControls();
return await selectRunsControls.toggleCheckbox();
return (await this.getSelectRunsControls()).toggleCheckbox();
}

async isSelectRunsCheckboxChecked(): Promise<boolean> {
const selectRunsControls = await this.getSelectRunsControls();
return await selectRunsControls.isChecked();
return (await this.getSelectRunsControls()).isChecked();
}

async isSelectRunsCheckboxIndeterminate(): Promise<boolean> {
const selectRunsControls = await this.getSelectRunsControls();
return await selectRunsControls.isIndeterminate();
return (await this.getSelectRunsControls()).isIndeterminate();
}

async clickSelectRunsMenuButton(menuButtonText: string): Promise<void> {
const selectRunsControls = await this.getSelectRunsControls();
return await selectRunsControls.clickMenuButton(menuButtonText);
return (await this.getSelectRunsControls()).clickMenuButton(menuButtonText);
}

async clickRunListItemCheckbox(index: number): Promise<void> {
const runListItem = await this.getRunListItem(index);
return runListItem.checkCheckbox();
return (await this.getRunListItem(index)).checkCheckbox();
}

async getRunListItem(index: number): Promise<any> {
const runListItems = await this.getRunListItems();
return runListItems[index];
return (await this.getRunListItems())[index];
}

async getNumRunListItems(): Promise<number> {
const runListItems = await this.getRunListItems();
return runListItems.length;
return (await this.getRunListItems()).length;
}

async clickRunListItemMenuButton(index: number, menuButtonText: string): Promise<void> {
const runListItem = await this.getRunListItem(index);
return await runListItem.clickMenuButton(menuButtonText);
return (await this.getRunListItem(index)).clickMenuButton(menuButtonText);
}

async clickArchiveButton(): Promise<void> {
const button = await this.getArchiveButton();
return await button.click();
return (await this.getArchiveButton()).click();
}

async clickUnarchiveButton(): Promise<void> {
const button = await this.getUnarchiveButton();
return await button.click();
return (await this.getUnarchiveButton()).click();
}
}

0 comments on commit 5efc759

Please sign in to comment.