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

Commitdcf1d3a

Browse files
authored
test(site): add e2e tests for experiments (#12940)
1 parentb163bc7 commitdcf1d3a

File tree

5 files changed

+61
-5
lines changed

5 files changed

+61
-5
lines changed

‎site/e2e/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ export const requireEnterpriseTests = Boolean(
3737
process.env.CODER_E2E_REQUIRE_ENTERPRISE_TESTS,
3838
);
3939
exportconstenterpriseLicense=process.env.CODER_E2E_ENTERPRISE_LICENSE??"";
40+
41+
// Fake experiments to verify that site presents them as enabled.
42+
exportconste2eFakeExperiment1="e2e-fake-experiment-1";
43+
exportconste2eFakeExperiment2="e2e-fake-experiment-2";

‎site/e2e/playwright.config.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
import{defineConfig}from"@playwright/test";
22
import*aspathfrom"path";
3-
import{coderMain,coderPort,coderdPProfPort,gitAuth}from"./constants";
3+
import{
4+
coderMain,
5+
coderPort,
6+
coderdPProfPort,
7+
e2eFakeExperiment1,
8+
e2eFakeExperiment2,
9+
gitAuth,
10+
}from"./constants";
411

512
exportconstwsEndpoint=process.env.CODER_E2E_WS_ENDPOINT;
613

@@ -22,7 +29,7 @@ export default defineConfig({
2229
testMatch:/.*\.spec\.ts/,
2330
dependencies:["testsSetup"],
2431
use:{ storageState},
25-
timeout:20_000,
32+
timeout:50_000,
2633
},
2734
],
2835
reporter:[["./reporter.ts"]],
@@ -60,6 +67,8 @@ export default defineConfig({
6067
.join(" "),
6168
env:{
6269
...process.env,
70+
// Otherwise, the runner fails on Mac with: could not determine kind of name for C.uuid_string_t
71+
CGO_ENABLED:"0",
6372

6473
// This is the test provider for git auth with devices!
6574
CODER_GITAUTH_0_ID:gitAuth.deviceProvider,
@@ -101,6 +110,7 @@ export default defineConfig({
101110
gitAuth.validatePath,
102111
),
103112
CODER_PPROF_ADDRESS:"127.0.0.1:"+coderdPProfPort,
113+
CODER_EXPERIMENTS:e2eFakeExperiment1+","+e2eFakeExperiment2,
104114
},
105115
reuseExistingServer:false,
106116
},
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import{expect,test}from"@playwright/test";
2+
import*asAPIfrom"api/api";
3+
import{setupApiCalls}from"../../api";
4+
import{e2eFakeExperiment1,e2eFakeExperiment2}from"../../constants";
5+
6+
test("experiments",async({ page})=>{
7+
awaitsetupApiCalls(page);
8+
9+
// Load experiments from backend API
10+
constavailableExperiments=awaitAPI.getAvailableExperiments();
11+
12+
// Verify if the site lists the same experiments
13+
awaitpage.goto("/deployment/general",{waitUntil:"networkidle"});
14+
15+
constexperimentsLocator=page.locator(
16+
"div.options-table tr.option-experiments ul.option-array",
17+
);
18+
awaitexpect(experimentsLocator).toBeVisible();
19+
20+
// Firstly, check if all enabled experiments are listed
21+
expect(
22+
experimentsLocator.locator(
23+
`li.option-array-item-${e2eFakeExperiment1}.option-enabled`,
24+
),
25+
).toBeVisible;
26+
expect(
27+
experimentsLocator.locator(
28+
`li.option-array-item-${e2eFakeExperiment2}.option-enabled`,
29+
),
30+
).toBeVisible;
31+
32+
// Secondly, check if available experiments are listed
33+
for(constexperimentofavailableExperiments.safe){
34+
constexperimentLocator=experimentsLocator.locator(
35+
`li.option-array-item-${experiment}`,
36+
);
37+
awaitexpect(experimentLocator).toBeVisible();
38+
}
39+
});

‎site/src/pages/DeploySettingsPage/Option.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
5151

5252
if(typeofvalue==="object"&&!Array.isArray(value)){
5353
return(
54-
<ulcss={{listStyle:"none"}}>
54+
<ulcss={{listStyle:"none"}}className="option-array">
5555
{Object.entries(value)
5656
.sort((a,b)=>a[0].localeCompare(b[0]))
5757
.map(([option,isEnabled])=>(
@@ -64,6 +64,9 @@ export const OptionValue: FC<OptionValueProps> = (props) => {
6464
color:theme.palette.text.disabled,
6565
},
6666
]}
67+
className={`option-array-item-${option}${
68+
isEnabled ?"option-enabled" :"option-disabled"
69+
}`}
6770
>
6871
<div
6972
css={{

‎site/src/pages/DeploySettingsPage/OptionsTable.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const OptionsTable: FC<OptionsTableProps> = ({ options, additionalValues }) => {
2727
}
2828

2929
return(
30-
<TableContainer>
30+
<TableContainerclassName="options-table">
3131
<Table
3232
css={css`
3333
&td {
@@ -57,7 +57,7 @@ const OptionsTable: FC<OptionsTableProps> = ({ options, additionalValues }) => {
5757
returnnull;
5858
}
5959
return(
60-
<TableRowkey={option.flag}>
60+
<TableRowkey={option.flag}className={"option-"+option.flag}>
6161
<TableCell>
6262
<OptionName>{option.name}</OptionName>
6363
<OptionDescription>{option.description}</OptionDescription>

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp