Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit cf2d2a9

Browse files
authored
test(site): add e2e tests for appearance (coder#12950)
1 parent b71af32 commit cf2d2a9

File tree

3 files changed

+93
-1
lines changed

3 files changed

+93
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
import { chromium, expect, test } from "@playwright/test";
2+
import { expectUrl } from "../../expectUrl";
3+
import { randomName, requiresEnterpriseLicense } from "../../helpers";
4+
5+
test("set application name", async ({ page }) => {
6+
requiresEnterpriseLicense();
7+
8+
await page.goto("/deployment/appearance", { waitUntil: "domcontentloaded" });
9+
10+
const applicationName = randomName();
11+
12+
// Fill out the form
13+
const form = page.locator("form", { hasText: "Application name" });
14+
await form
15+
.getByLabel("Application name", { exact: true })
16+
.fill(applicationName);
17+
await form.getByRole("button", { name: "Submit" }).click();
18+
19+
// Open a new session without cookies to see the login page
20+
const browser = await chromium.launch();
21+
const incognitoContext = await browser.newContext();
22+
await incognitoContext.clearCookies();
23+
const incognitoPage = await incognitoContext.newPage();
24+
await incognitoPage.goto("/", { waitUntil: "domcontentloaded" });
25+
26+
// Verify the application name
27+
const name = incognitoPage.locator("h1", { hasText: applicationName });
28+
await expect(name).toBeVisible();
29+
30+
// Shut down browser
31+
await incognitoPage.close();
32+
await browser.close();
33+
});
34+
35+
test("set application logo", async ({ page }) => {
36+
requiresEnterpriseLicense();
37+
38+
await page.goto("/deployment/appearance", { waitUntil: "domcontentloaded" });
39+
40+
const imageLink = "/icon/azure.png";
41+
42+
// Fill out the form
43+
const form = page.locator("form", { hasText: "Logo URL" });
44+
await form.getByLabel("Logo URL", { exact: true }).fill(imageLink);
45+
await form.getByRole("button", { name: "Submit" }).click();
46+
47+
// Open a new session without cookies to see the login page
48+
const browser = await chromium.launch();
49+
const incognitoContext = await browser.newContext();
50+
await incognitoContext.clearCookies();
51+
const incognitoPage = await incognitoContext.newPage();
52+
await incognitoPage.goto("/", { waitUntil: "domcontentloaded" });
53+
54+
// Verify banner
55+
const logo = incognitoPage.locator("img");
56+
await expect(logo).toHaveAttribute("src", imageLink);
57+
58+
// Shut down browser
59+
await incognitoPage.close();
60+
await browser.close();
61+
});
62+
63+
test("set service banner", async ({ page }) => {
64+
requiresEnterpriseLicense();
65+
66+
await page.goto("/deployment/appearance", { waitUntil: "domcontentloaded" });
67+
68+
const message = "Mary has a little lamb.";
69+
70+
// Fill out the form
71+
const form = page.locator("form", { hasText: "Service Banner" });
72+
await form.getByLabel("Enabled", { exact: true }).check();
73+
await form.getByLabel("Message", { exact: true }).fill(message);
74+
await form.getByRole("button", { name: "Submit" }).click();
75+
76+
// Verify service banner
77+
await page.goto("/workspaces", { waitUntil: "domcontentloaded" });
78+
await expectUrl(page).toHavePathName("/workspaces");
79+
80+
const bar = page.locator("div.service-banner", { hasText: message });
81+
await expect(bar).toBeVisible();
82+
});

site/src/modules/dashboard/ServiceBanner/ServiceBannerView.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const ServiceBannerView: FC<ServiceBannerViewProps> = ({
1616
isPreview,
1717
}) => {
1818
return (
19-
<div css={[styles.banner, { backgroundColor }]}>
19+
<div css={[styles.banner, { backgroundColor }]} className="service-banner">
2020
{isPreview && <Pill type="info">Preview</Pill>}
2121
<div
2222
css={[

site/src/pages/DeploySettingsPage/AppearanceSettingsPage/AppearanceSettingsPageView.tsx

+10
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,9 @@ export const AppearanceSettingsPageView: FC<
105105
fullWidth
106106
placeholder='Leave empty to display "Coder".'
107107
disabled={!isEntitled}
108+
inputProps={{
109+
"aria-label": "Application name",
110+
}}
108111
/>
109112
</Fieldset>
110113

@@ -150,6 +153,9 @@ export const AppearanceSettingsPageView: FC<
150153
</InputAdornment>
151154
),
152155
}}
156+
inputProps={{
157+
"aria-label": "Logo URL",
158+
}}
153159
/>
154160
</Fieldset>
155161

@@ -208,6 +214,7 @@ export const AppearanceSettingsPageView: FC<
208214
);
209215
await serviceBannerForm.setFieldValue("enabled", newState);
210216
}}
217+
data-testid="switch-service-banner"
211218
/>
212219
}
213220
label="Enabled"
@@ -221,6 +228,9 @@ export const AppearanceSettingsPageView: FC<
221228
fullWidth
222229
label="Message"
223230
multiline
231+
inputProps={{
232+
"aria-label": "Message",
233+
}}
224234
/>
225235
</Stack>
226236

0 commit comments

Comments
 (0)