Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit93b46fe

Browse files
Emyrkaslilac
andauthored
chore: skip global.setup if first user already exists (#12930)
* chore: skip global.setup if first user already existstreat test as a setup, rather than a testCo-authored-by: Kayla Washburn-Love <mckayla@hey.com>---------Co-authored-by: Kayla Washburn-Love <mckayla@hey.com>
1 parent2ad7fcc commit93b46fe

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

‎site/e2e/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,3 +46,11 @@ Enterprise tests require a license key to run.
4646
```shell
4747
export CODER_E2E_ENTERPRISE_LICENSE=<license key>
4848
```
49+
50+
#Debugging tests
51+
52+
To debug a test, it is more helpful to run it in`ui` mode.
53+
54+
```
55+
pnpm playwright:test-ui
56+
```

‎site/e2e/api.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,12 @@ import { findSessionToken, randomName } from "./helpers";
66
letcurrentOrgId:string;
77

88
exportconstsetupApiCalls=async(page:Page)=>{
9-
consttoken=awaitfindSessionToken(page);
10-
API.setSessionToken(token);
9+
try{
10+
consttoken=awaitfindSessionToken(page);
11+
API.setSessionToken(token);
12+
}catch{
13+
// If this fails, we have an unauthenticated client.
14+
}
1115
API.setHost(`http://127.0.0.1:${coderPort}`);
1216
};
1317

‎site/e2e/global.setup.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,19 @@
11
import{expect,test}from"@playwright/test";
2+
import{hasFirstUser}from"api/api";
23
import{Language}from"pages/CreateUserPage/CreateUserForm";
4+
import{setupApiCalls}from"./api";
35
import*asconstantsfrom"./constants";
46
import{storageState}from"./playwright.config";
57

68
test("setup deployment",async({ page})=>{
79
awaitpage.goto("/",{waitUntil:"domcontentloaded"});
10+
awaitsetupApiCalls(page);
11+
constexists=awaithasFirstUser();
12+
// First user already exists, abort early. All tests execute this as a dependency,
13+
// if you run multiple tests in the UI, this will fail unless we check this.
14+
if(exists){
15+
return;
16+
}
817

918
// Setup first user
1019
awaitpage.getByLabel(Language.usernameLabel).fill(constants.username);

‎site/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
"lint:types":"tsc -p .",
1717
"playwright:install":"playwright install --with-deps chromium",
1818
"playwright:test":"playwright test --config=e2e/playwright.config.ts",
19+
"playwright:test-ui":"playwright test --config=e2e/playwright.config.ts --ui $([[\"$CODER\" ==\"true\" ]] && echo --ui-port=7500 --ui-host=0.0.0.0)",
1920
"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'",
2021
"storybook":"STORYBOOK=true storybook dev -p 6006",
2122
"storybook:build":"storybook build",

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp