Skip to content

Commit

Permalink
Merge pull request #249 from RenBabiuch/exclude-languages-test-improv…
Browse files Browse the repository at this point in the history
…ements2

Exclude-languages-test - reproduce the bug #243
  • Loading branch information
Asvarox authored Apr 22, 2024
2 parents 116eb45 + 13ea1a1 commit 2a932e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 11 deletions.
25 changes: 17 additions & 8 deletions tests/PageObjects/SongLanguagesPage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ export class SongLanguagesPagePO {
return this.page.locator(`[data-test = "lang-${language}"] svg`);
}

public async selectLanguage(language: string) {
await expect(this.getCheckbox(language)).toHaveAttribute('data-testid', 'CheckBoxOutlineBlankIcon');
await this.getLanguageEntry(language).click();
}

public async unselectLanguage(language: string) {
await expect(this.getCheckbox(language)).toHaveAttribute('data-testid', 'CheckBoxIcon');
await this.getLanguageEntry(language).click();
Expand Down Expand Up @@ -49,11 +44,15 @@ export class SongLanguagesPagePO {
return languageCheckboxValue === 'CheckBoxIcon';
}

public async ensureAllLanguagesAreSelected() {
public async getAllLanguageCheckboxes() {
const languageCheckbox = this.page.locator('[data-test^="lang-"] svg');

await expect(languageCheckbox.first()).toBeVisible();
const languages = await languageCheckbox.all();

return languageCheckbox.all();
}

public async ensureAllLanguagesAreSelected() {
const languages = await this.getAllLanguageCheckboxes();

for (const language of languages) {
if (!(await this.isLanguageSelected(language))) {
Expand All @@ -62,6 +61,16 @@ export class SongLanguagesPagePO {
}
}

public async ensureAllLanguagesAreDeselected() {
const languages = await this.getAllLanguageCheckboxes();

for (const language of languages) {
if (await this.isLanguageSelected(language)) {
await language.click();
}
}
}

public async goBackToMainMenu() {
await this.page.getByTestId('close-exclude-languages').click();
}
Expand Down
14 changes: 11 additions & 3 deletions tests/exclude-languages.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,20 @@ test('exclude languages from first start and menu', async ({ page }) => {
await expect(await pages.songListPage.getSongElement(song1)).not.toBeVisible();
});

await test.step('Exclude all', async () => {
await test.step('Exclude all languages - excluded alert should be visible', async () => {
await pages.songListPage.goBackToMainMenu();
await pages.mainMenuPage.goToManageSongs();
await pages.manageSongsPage.goToSelectSongLanguage();
await pages.songLanguagesPage.ensureSongLanguageIsDeselected(language2);
await pages.songLanguagesPage.ensureSongLanguageIsDeselected(language1);
await pages.songLanguagesPage.ensureAllLanguagesAreDeselected();
await expect(pages.songLanguagesPage.allLanguagesExcludedAlert).toBeVisible();
});

await test.step('After `Backspace` key, changes should not be saved', async () => {
await page.keyboard.press('Backspace');
await pages.mainMenuPage.goToManageSongs();
await pages.manageSongsPage.goToSelectSongLanguage();
test.fixme(true, 'Changes should not be saved');
await page.waitForTimeout(1_000);
await expect(pages.songLanguagesPage.allLanguagesExcludedAlert).not.toBeVisible();
});
});

0 comments on commit 2a932e6

Please sign in to comment.