From dfe7558783fed7a0882ce2914127a0cfa806b7aa Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 12 Apr 2024 13:40:25 +0200 Subject: [PATCH 1/3] first appearance test --- site/e2e/tests/deployment/appearance.spec.ts | 29 +++++++++++++++++++ .../AppearanceSettingsPageView.tsx | 10 +++++++ 2 files changed, 39 insertions(+) create mode 100644 site/e2e/tests/deployment/appearance.spec.ts diff --git a/site/e2e/tests/deployment/appearance.spec.ts b/site/e2e/tests/deployment/appearance.spec.ts new file mode 100644 index 0000000000000..6b1653bf99aa3 --- /dev/null +++ b/site/e2e/tests/deployment/appearance.spec.ts @@ -0,0 +1,29 @@ +import { chromium, expect, test } from "@playwright/test"; +import { randomName, requiresEnterpriseLicense } from "../../helpers"; + +test("set application name", async ({ page }) => { + requiresEnterpriseLicense(); + + await page.goto("/deployment/appearance", { waitUntil: "domcontentloaded" }); + + const applicationName = randomName(); + + // Fill out the form + const form = page.locator("form", { hasText: "Application name"}) + await form.getByLabel("Application name", { exact: true}).fill(applicationName); + await form.getByRole("button", { name: "Submit"}).click(); + + // Open a new session without cookies to see the login page + const browser = await chromium.launch() + const incognitoContext = await browser.newContext() + await incognitoContext.clearCookies() + const incognitoPage = await incognitoContext.newPage() + await incognitoPage.goto("/", { waitUntil: "domcontentloaded" }); + + const banner = incognitoPage.locator("h1", { hasText: applicationName}) + await expect(banner).toBeVisible() + + // Shut down browser + await incognitoPage.close() + await browser.close() +}); diff --git a/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx b/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx index 07203567a0a02..784ccb94ac3b3 100644 --- a/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx +++ b/site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx @@ -105,6 +105,9 @@ export const AppearanceSettingsPageView: FC< fullWidth placeholder='Leave empty to display "Coder".' disabled={!isEntitled} + inputProps={{ + "aria-label": "Application name", + }} /> @@ -150,6 +153,9 @@ export const AppearanceSettingsPageView: FC< ), }} + inputProps={{ + "aria-label": "Logo URL", + }} /> @@ -208,6 +214,7 @@ export const AppearanceSettingsPageView: FC< ); await serviceBannerForm.setFieldValue("enabled", newState); }} + data-testid="switch-service-banner" /> } label="Enabled" @@ -221,6 +228,9 @@ export const AppearanceSettingsPageView: FC< fullWidth label="Message" multiline + inputProps={{ + "aria-label": "Message", + }} /> From c51903a703253d89248d4765374f40e2cbd447b7 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 12 Apr 2024 13:50:03 +0200 Subject: [PATCH 2/3] Logo URL --- site/e2e/tests/deployment/appearance.spec.ts | 53 ++++++++++++++++---- 1 file changed, 42 insertions(+), 11 deletions(-) diff --git a/site/e2e/tests/deployment/appearance.spec.ts b/site/e2e/tests/deployment/appearance.spec.ts index 6b1653bf99aa3..833ece105c648 100644 --- a/site/e2e/tests/deployment/appearance.spec.ts +++ b/site/e2e/tests/deployment/appearance.spec.ts @@ -9,21 +9,52 @@ test("set application name", async ({ page }) => { const applicationName = randomName(); // Fill out the form - const form = page.locator("form", { hasText: "Application name"}) - await form.getByLabel("Application name", { exact: true}).fill(applicationName); - await form.getByRole("button", { name: "Submit"}).click(); + const form = page.locator("form", { hasText: "Application name" }); + await form + .getByLabel("Application name", { exact: true }) + .fill(applicationName); + await form.getByRole("button", { name: "Submit" }).click(); // Open a new session without cookies to see the login page - const browser = await chromium.launch() - const incognitoContext = await browser.newContext() - await incognitoContext.clearCookies() - const incognitoPage = await incognitoContext.newPage() + const browser = await chromium.launch(); + const incognitoContext = await browser.newContext(); + await incognitoContext.clearCookies(); + const incognitoPage = await incognitoContext.newPage(); await incognitoPage.goto("/", { waitUntil: "domcontentloaded" }); - const banner = incognitoPage.locator("h1", { hasText: applicationName}) - await expect(banner).toBeVisible() + // Verify banner + const banner = incognitoPage.locator("h1", { hasText: applicationName }); + await expect(banner).toBeVisible(); // Shut down browser - await incognitoPage.close() - await browser.close() + await incognitoPage.close(); + await browser.close(); +}); + +test("set application logo", async ({ page }) => { + requiresEnterpriseLicense(); + + await page.goto("/deployment/appearance", { waitUntil: "domcontentloaded" }); + + const imageLink = "/icon/azure.png"; + + // Fill out the form + const form = page.locator("form", { hasText: "Logo URL" }); + await form.getByLabel("Logo URL", { exact: true }).fill(imageLink); + await form.getByRole("button", { name: "Submit" }).click(); + + // Open a new session without cookies to see the login page + const browser = await chromium.launch(); + const incognitoContext = await browser.newContext(); + await incognitoContext.clearCookies(); + const incognitoPage = await incognitoContext.newPage(); + await incognitoPage.goto("/", { waitUntil: "domcontentloaded" }); + + // Verify banner + const logo = incognitoPage.locator("img"); + await expect(logo).toHaveAttribute("src", imageLink); + + // Shut down browser + await incognitoPage.close(); + await browser.close(); }); From 2fc9807c11269341119b63149ada0df597486b23 Mon Sep 17 00:00:00 2001 From: Marcin Tojek Date: Fri, 12 Apr 2024 14:26:52 +0200 Subject: [PATCH 3/3] service banner --- site/e2e/tests/deployment/appearance.spec.ts | 28 +++++++++++++++++-- .../ServiceBanner/ServiceBannerView.tsx | 2 +- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/site/e2e/tests/deployment/appearance.spec.ts b/site/e2e/tests/deployment/appearance.spec.ts index 833ece105c648..0fec1a7d75597 100644 --- a/site/e2e/tests/deployment/appearance.spec.ts +++ b/site/e2e/tests/deployment/appearance.spec.ts @@ -1,4 +1,5 @@ import { chromium, expect, test } from "@playwright/test"; +import { expectUrl } from "../../expectUrl"; import { randomName, requiresEnterpriseLicense } from "../../helpers"; test("set application name", async ({ page }) => { @@ -22,9 +23,9 @@ test("set application name", async ({ page }) => { const incognitoPage = await incognitoContext.newPage(); await incognitoPage.goto("/", { waitUntil: "domcontentloaded" }); - // Verify banner - const banner = incognitoPage.locator("h1", { hasText: applicationName }); - await expect(banner).toBeVisible(); + // Verify the application name + const name = incognitoPage.locator("h1", { hasText: applicationName }); + await expect(name).toBeVisible(); // Shut down browser await incognitoPage.close(); @@ -58,3 +59,24 @@ test("set application logo", async ({ page }) => { await incognitoPage.close(); await browser.close(); }); + +test("set service banner", async ({ page }) => { + requiresEnterpriseLicense(); + + await page.goto("/deployment/appearance", { waitUntil: "domcontentloaded" }); + + const message = "Mary has a little lamb."; + + // Fill out the form + const form = page.locator("form", { hasText: "Service Banner" }); + await form.getByLabel("Enabled", { exact: true }).check(); + await form.getByLabel("Message", { exact: true }).fill(message); + await form.getByRole("button", { name: "Submit" }).click(); + + // Verify service banner + await page.goto("/workspaces", { waitUntil: "domcontentloaded" }); + await expectUrl(page).toHavePathName("/workspaces"); + + const bar = page.locator("div.service-banner", { hasText: message }); + await expect(bar).toBeVisible(); +}); diff --git a/site/src/modules/dashboard/ServiceBanner/ServiceBannerView.tsx b/site/src/modules/dashboard/ServiceBanner/ServiceBannerView.tsx index c747285550208..e907085cb2af4 100644 --- a/site/src/modules/dashboard/ServiceBanner/ServiceBannerView.tsx +++ b/site/src/modules/dashboard/ServiceBanner/ServiceBannerView.tsx @@ -16,7 +16,7 @@ export const ServiceBannerView: FC = ({ isPreview, }) => { return ( -
+
{isPreview && Preview}