Skip to content

chore: add docs for adding e2e tests #12677

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions site/e2e/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# e2e

The structure of the end-to-end tests is optimized for speed and reliability.
Not all tests require setting up a new PostgreSQL instance or using the
Terraform provisioner. Deciding when to trade time for robustness rests with the
developers; the framework's role is to facilitate this process.

Take a look at prior art in `tests/` for inspiration. To run a test:

```shell
cd site
# Build the frontend assets. If you are actively changing
# the site to debug an issue, add `--watch`.
pnpm build
# Install the browsers to `~/.cache/ms-playwright`.
pnpm playwright:install
# Run E2E tests. You can see the configuration of the server
# in `playwright.config.ts`. This uses `go run -tags embed ...`.
pnpm playwright:test
# Run a specific test (`-g` stands for grep. It accepts regex).
pnpm playwright:test -g '<your test here>'
```
4 changes: 2 additions & 2 deletions site/e2e/global.setup.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from "@playwright/test";
import { Language } from "pages/CreateUserPage/CreateUserForm";
import * as constants from "./constants";
import { STORAGE_STATE } from "./playwright.config";
import { storageState } from "./playwright.config";

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

await expect(page).toHaveURL(/\/workspaces.*/);
await page.context().storageState({ path: STORAGE_STATE });
await page.context().storageState({ path: storageState });

await page.getByTestId("button-select-template").isVisible();
});
2 changes: 1 addition & 1 deletion site/e2e/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -727,7 +727,7 @@ export const updateTemplateSettings = async (
templateName: string,
templateSettingValues: Pick<
UpdateTemplateMeta,
"name" | "display_name" | "description"
"name" | "display_name" | "description" | "deprecation_message"
>,
) => {
await page.goto(`/templates/${templateName}/settings`, {
Expand Down
5 changes: 3 additions & 2 deletions site/e2e/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export const wsEndpoint = process.env.CODER_E2E_WS_ENDPOINT;

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

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

const localURL = (port: number, path: string): string => {
return `http://localhost:${port}${path}`;
Expand All @@ -27,7 +28,7 @@ export default defineConfig({
testMatch: /.*\.spec\.ts/,
dependencies: ["setup"],
use: {
storageState: STORAGE_STATE,
storageState: storageState,
},
timeout: 60_000,
},
Expand Down
17 changes: 0 additions & 17 deletions site/e2e/pom/BasePom.ts

This file was deleted.

17 changes: 0 additions & 17 deletions site/e2e/pom/SignInPage.ts

This file was deleted.

8 changes: 0 additions & 8 deletions site/e2e/pom/WorkspacesPage.ts

This file was deleted.

2 changes: 0 additions & 2 deletions site/e2e/pom/index.ts

This file was deleted.

Empty file removed site/e2e/states/.gitkeep
Empty file.