From 13ea1a15f1fbb75d16d57f50536ddff04cbd3de9 Mon Sep 17 00:00:00 2001 From: Renata Date: Sat, 13 Apr 2024 22:29:42 +0200 Subject: [PATCH] add test-step to reproduce the bug #243 --- tests/PageObjects/SongLanguagesPage.ts | 25 +++++++++++++++++-------- tests/exclude-languages.spec.ts | 14 +++++++++++--- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/tests/PageObjects/SongLanguagesPage.ts b/tests/PageObjects/SongLanguagesPage.ts index e69ee0d37..95ff62890 100644 --- a/tests/PageObjects/SongLanguagesPage.ts +++ b/tests/PageObjects/SongLanguagesPage.ts @@ -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(); @@ -48,11 +43,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))) { @@ -61,6 +60,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(); } diff --git a/tests/exclude-languages.spec.ts b/tests/exclude-languages.spec.ts index 20cd54e33..288706b23 100644 --- a/tests/exclude-languages.spec.ts +++ b/tests/exclude-languages.spec.ts @@ -62,12 +62,20 @@ test('exclude languages from first start and menu', async ({ page }) => { await expect(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(); + }); });