From 8b1191c3322c0675923ae7d72d7f33997f638d66 Mon Sep 17 00:00:00 2001 From: Georgina Bidder Date: Sat, 14 Oct 2023 14:22:47 +0100 Subject: [PATCH] help links tests + clean up of system info --- .../DefaultConfig/HelpPanel/helpLinks.spec.ts | 41 +++++++++++++++++++ .../HelpPanel/systemInformation.spec.ts | 23 ++++++----- 2 files changed, 53 insertions(+), 11 deletions(-) create mode 100644 tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/helpLinks.spec.ts diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/helpLinks.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/helpLinks.spec.ts new file mode 100644 index 0000000000..882eaf1bbf --- /dev/null +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/helpLinks.spec.ts @@ -0,0 +1,41 @@ +import { test } from '@umbraco/playwright-testhelpers'; +import { expect } from '@playwright/test'; + +test.describe("Help panel links", () => { + const enCulture = "en-US"; + + test.beforeEach(async ({ umbracoApi }, testInfo) => { + await umbracoApi.report.report(testInfo); + await umbracoApi.login(); + await umbracoApi.users.setCurrentLanguage(enCulture); + }); + + test.afterEach(async ({ umbracoApi }) => { + await umbracoApi.users.setCurrentLanguage(enCulture); + }); + +test("Check the youtube link works as expected", async ({ page, umbracoUi }) => { + // Action + await umbracoUi.clickElement(umbracoUi.getGlobalHelp()); + let watchVideoLink = await page.locator('[key="help_umbracoLearningBase"]'); + await watchVideoLink.click(); + + // Wait for a popup event + const youtubeConsent = page.waitForEvent("popup"); + const youtubePopup = await youtubeConsent; + + if (youtubePopup) { + // If the YouTube consent popup is displayed, interact with it + const rejectAllButton = await youtubePopup.locator('[aria-label="Reject all"]').first(); + await rejectAllButton.waitFor({ state: "visible" }); + await rejectAllButton.click(); + + // Assert the URL of the popup + await expect(youtubePopup).toHaveURL(/.*UmbracoLearningBase/); + await youtubePopup.close(); + + } else { + await expect(page).toHaveURL(/.*UmbracoLearningBase/); + } + }); +}); \ No newline at end of file diff --git a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/systemInformation.spec.ts b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/systemInformation.spec.ts index a202a60053..643ec2fad9 100644 --- a/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/systemInformation.spec.ts +++ b/tests/Umbraco.Tests.AcceptanceTest/tests/DefaultConfig/HelpPanel/systemInformation.spec.ts @@ -1,36 +1,38 @@ -import {ConstantHelper, test, UiHelpers} from '@umbraco/playwright-testhelpers'; -import {expect, Page} from "@playwright/test"; +import { ConstantHelper, test, UiHelpers } from '@umbraco/playwright-testhelpers'; +import { expect, Page } from '@playwright/test'; -test.describe('System Information', () => { +test.describe("System Information", () => { const enCulture = "en-US"; const dkCulture = "da-DK"; - test.beforeEach(async ({ page, umbracoApi }, testInfo) => { + test.beforeEach(async ({ umbracoApi }, testInfo) => { await umbracoApi.report.report(testInfo); await umbracoApi.login(); await umbracoApi.users.setCurrentLanguage(enCulture); }); - test.afterEach(async ({page, umbracoApi}) => { + test.afterEach(async ({ umbracoApi }) => { await umbracoApi.users.setCurrentLanguage(enCulture); }); async function openSystemInformation(page: Page, umbracoUi: UiHelpers) { //We have to wait for page to load, if the site is slow await umbracoUi.clickElement(umbracoUi.getGlobalHelp()); - await expect(page.locator('.umb-help-list-item').last()).toBeVisible(); - await umbracoUi.clickElement(page.locator('.umb-help-list-item').last()); - await page.locator('.umb-drawer-content').scrollIntoViewIfNeeded(); + await expect(page.locator(".umb-help-list-item").last()).toBeVisible(); + await umbracoUi.clickElement( + Promise.resolve(page.locator(".umb-help-list-item").last()) + ); + await page.locator(".umb-drawer-content").scrollIntoViewIfNeeded(); } - test('Check System Info Displays', async ({page, umbracoApi, umbracoUi}) => { + test('Check System Info Displays', async ({page, umbracoUi}) => { await openSystemInformation(page, umbracoUi); await expect(page.locator('.table').locator('tr')).toHaveCount(15); await expect(await page.locator("tr", {hasText: "Current Culture"})).toContainText(enCulture); await expect(await page.locator("tr", {hasText: "Current UI Culture"})).toContainText(enCulture); }); - test('Checks language displays correctly after switching', async ({page, umbracoApi, umbracoUi}) => { + test("Checks language displays correctly after switching", async ({ page, umbracoUi }) => { //Navigate to edit user and change language await umbracoUi.clickElement(umbracoUi.getGlobalUser()); await page.locator('[alias="editUser"]').click(); @@ -39,7 +41,6 @@ test.describe('System Information', () => { await umbracoUi.isSuccessNotificationVisible(); await openSystemInformation(page, umbracoUi); - //Assert await expect(await page.locator("tr", {hasText: "Current Culture"})).toContainText(dkCulture); await expect(await page.locator("tr", {hasText: "Current UI Culture"})).toContainText(dkCulture);