Skip to content

Commit 4ae1f40

Browse files
authored
chore: add docs for adding e2e tests (#12677)
1 parent c92ceff commit 4ae1f40

File tree

9 files changed

+28
-49
lines changed

9 files changed

+28
-49
lines changed

site/e2e/README.md

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# e2e
2+
3+
The structure of the end-to-end tests is optimized for speed and reliability.
4+
Not all tests require setting up a new PostgreSQL instance or using the
5+
Terraform provisioner. Deciding when to trade time for robustness rests with the
6+
developers; the framework's role is to facilitate this process.
7+
8+
Take a look at prior art in `tests/` for inspiration. To run a test:
9+
10+
```shell
11+
cd site
12+
# Build the frontend assets. If you are actively changing
13+
# the site to debug an issue, add `--watch`.
14+
pnpm build
15+
# Install the browsers to `~/.cache/ms-playwright`.
16+
pnpm playwright:install
17+
# Run E2E tests. You can see the configuration of the server
18+
# in `playwright.config.ts`. This uses `go run -tags embed ...`.
19+
pnpm playwright:test
20+
# Run a specific test (`-g` stands for grep. It accepts regex).
21+
pnpm playwright:test -g '<your test here>'
22+
```

site/e2e/global.setup.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { test, expect } from "@playwright/test";
22
import { Language } from "pages/CreateUserPage/CreateUserForm";
33
import * as constants from "./constants";
4-
import { STORAGE_STATE } from "./playwright.config";
4+
import { storageState } from "./playwright.config";
55

66
test("setup first user", async ({ page }) => {
77
await page.goto("/", { waitUntil: "domcontentloaded" });
@@ -12,7 +12,7 @@ test("setup first user", async ({ page }) => {
1212
await page.getByTestId("create").click();
1313

1414
await expect(page).toHaveURL(/\/workspaces.*/);
15-
await page.context().storageState({ path: STORAGE_STATE });
15+
await page.context().storageState({ path: storageState });
1616

1717
await page.getByTestId("button-select-template").isVisible();
1818
});

site/e2e/helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -727,7 +727,7 @@ export const updateTemplateSettings = async (
727727
templateName: string,
728728
templateSettingValues: Pick<
729729
UpdateTemplateMeta,
730-
"name" | "display_name" | "description"
730+
"name" | "display_name" | "description" | "deprecation_message"
731731
>,
732732
) => {
733733
await page.goto(`/templates/${templateName}/settings`, {

site/e2e/playwright.config.ts

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ export const wsEndpoint = process.env.CODER_E2E_WS_ENDPOINT;
1010

1111
const coderMain = path.join(__dirname, "../../enterprise/cmd/coder");
1212

13-
export const STORAGE_STATE = path.join(__dirname, ".auth.json");
13+
// This is where auth cookies are stored!
14+
export const storageState = path.join(__dirname, ".auth.json");
1415

1516
const localURL = (port: number, path: string): string => {
1617
return `http://localhost:${port}${path}`;
@@ -27,7 +28,7 @@ export default defineConfig({
2728
testMatch: /.*\.spec\.ts/,
2829
dependencies: ["setup"],
2930
use: {
30-
storageState: STORAGE_STATE,
31+
storageState: storageState,
3132
},
3233
timeout: 60_000,
3334
},

site/e2e/pom/BasePom.ts

-17
This file was deleted.

site/e2e/pom/SignInPage.ts

-17
This file was deleted.

site/e2e/pom/WorkspacesPage.ts

-8
This file was deleted.

site/e2e/pom/index.ts

-2
This file was deleted.

site/e2e/states/.gitkeep

Whitespace-only changes.

0 commit comments

Comments
 (0)