mirror of https://github.com/coder/coder.git
chore: skip global.setup if first user already exists (#12930)
* chore: skip global.setup if first user already exists treat test as a setup, rather than a test Co-authored-by: Kayla Washburn-Love <mckayla@hey.com> --------- Co-authored-by: Kayla Washburn-Love <mckayla@hey.com>
This commit is contained in:
parent
2ad7fcc0b7
commit
93b46fe1f6
|
@ -46,3 +46,11 @@ Enterprise tests require a license key to run.
|
||||||
```shell
|
```shell
|
||||||
export CODER_E2E_ENTERPRISE_LICENSE=<license key>
|
export CODER_E2E_ENTERPRISE_LICENSE=<license key>
|
||||||
```
|
```
|
||||||
|
|
||||||
|
# Debugging tests
|
||||||
|
|
||||||
|
To debug a test, it is more helpful to run it in `ui` mode.
|
||||||
|
|
||||||
|
```
|
||||||
|
pnpm playwright:test-ui
|
||||||
|
```
|
||||||
|
|
|
@ -6,8 +6,12 @@ import { findSessionToken, randomName } from "./helpers";
|
||||||
let currentOrgId: string;
|
let currentOrgId: string;
|
||||||
|
|
||||||
export const setupApiCalls = async (page: Page) => {
|
export const setupApiCalls = async (page: Page) => {
|
||||||
const token = await findSessionToken(page);
|
try {
|
||||||
API.setSessionToken(token);
|
const token = await findSessionToken(page);
|
||||||
|
API.setSessionToken(token);
|
||||||
|
} catch {
|
||||||
|
// If this fails, we have an unauthenticated client.
|
||||||
|
}
|
||||||
API.setHost(`http://127.0.0.1:${coderPort}`);
|
API.setHost(`http://127.0.0.1:${coderPort}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,19 @@
|
||||||
import { expect, test } from "@playwright/test";
|
import { expect, test } from "@playwright/test";
|
||||||
|
import { hasFirstUser } from "api/api";
|
||||||
import { Language } from "pages/CreateUserPage/CreateUserForm";
|
import { Language } from "pages/CreateUserPage/CreateUserForm";
|
||||||
|
import { setupApiCalls } from "./api";
|
||||||
import * as constants from "./constants";
|
import * as constants from "./constants";
|
||||||
import { storageState } from "./playwright.config";
|
import { storageState } from "./playwright.config";
|
||||||
|
|
||||||
test("setup deployment", async ({ page }) => {
|
test("setup deployment", async ({ page }) => {
|
||||||
await page.goto("/", { waitUntil: "domcontentloaded" });
|
await page.goto("/", { waitUntil: "domcontentloaded" });
|
||||||
|
await setupApiCalls(page);
|
||||||
|
const exists = await hasFirstUser();
|
||||||
|
// First user already exists, abort early. All tests execute this as a dependency,
|
||||||
|
// if you run multiple tests in the UI, this will fail unless we check this.
|
||||||
|
if (exists) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Setup first user
|
// Setup first user
|
||||||
await page.getByLabel(Language.usernameLabel).fill(constants.username);
|
await page.getByLabel(Language.usernameLabel).fill(constants.username);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
"lint:types": "tsc -p .",
|
"lint:types": "tsc -p .",
|
||||||
"playwright:install": "playwright install --with-deps chromium",
|
"playwright:install": "playwright install --with-deps chromium",
|
||||||
"playwright:test": "playwright test --config=e2e/playwright.config.ts",
|
"playwright:test": "playwright test --config=e2e/playwright.config.ts",
|
||||||
|
"playwright:test-ui": "playwright test --config=e2e/playwright.config.ts --ui $([[ \"$CODER\" == \"true\" ]] && echo --ui-port=7500 --ui-host=0.0.0.0)",
|
||||||
"gen:provisioner": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./e2e/ --ts_proto_opt=outputJsonMethods=false,outputEncodeMethods=encode-no-creation,outputClientImpl=false,nestJs=false,outputPartialMethods=false,fileSuffix=Generated,suffix=hey -I ../provisionersdk/proto ../provisionersdk/proto/provisioner.proto && pnpm exec prettier --ignore-path '/dev/null' --cache --write './e2e/provisionerGenerated.ts'",
|
"gen:provisioner": "protoc --plugin=./node_modules/.bin/protoc-gen-ts_proto --ts_proto_out=./e2e/ --ts_proto_opt=outputJsonMethods=false,outputEncodeMethods=encode-no-creation,outputClientImpl=false,nestJs=false,outputPartialMethods=false,fileSuffix=Generated,suffix=hey -I ../provisionersdk/proto ../provisionersdk/proto/provisioner.proto && pnpm exec prettier --ignore-path '/dev/null' --cache --write './e2e/provisionerGenerated.ts'",
|
||||||
"storybook": "STORYBOOK=true storybook dev -p 6006",
|
"storybook": "STORYBOOK=true storybook dev -p 6006",
|
||||||
"storybook:build": "storybook build",
|
"storybook:build": "storybook build",
|
||||||
|
|
Loading…
Reference in New Issue