Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 978a1ee

Browse files
committed
Fixing tests after minor UI updates
Signed-off-by: Danny Kopping <[email protected]>
1 parent fd08cee commit 978a1ee

File tree

4 files changed

+28
-17
lines changed

4 files changed

+28
-17
lines changed

site/e2e/constants.ts

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export const users = {
2929
username: "admin",
3030
password: defaultPassword,
3131
32+
roles: ["Owner"],
3233
},
3334
templateAdmin: {
3435
username: "template-admin",

site/e2e/tests/presets/basic-presets-with-prebuild/main.tf

+9-8
Original file line numberDiff line numberDiff line change
@@ -60,15 +60,8 @@ resource "coder_agent" "main" {
6060
fi
6161
EOT
6262

63-
# These environment variables allow you to make Git commits right away after creating a
64-
# workspace. Note that they take precedence over configuration defined in ~/.gitconfig!
65-
# You can remove this block if you'd prefer to configure Git manually or using
66-
# dotfiles. (see docs/dotfiles.md)
6763
env = {
68-
GIT_AUTHOR_NAME = coalesce(data.coder_workspace_owner.me.full_name, data.coder_workspace_owner.me.name)
69-
GIT_AUTHOR_EMAIL = "${data.coder_workspace_owner.me.email}"
70-
GIT_COMMITTER_NAME = coalesce(data.coder_workspace_owner.me.full_name, data.coder_workspace_owner.me.name)
71-
GIT_COMMITTER_EMAIL = "${data.coder_workspace_owner.me.email}"
64+
OWNER_EMAIL = data.coder_workspace_owner.me.email
7265
}
7366

7467
# The following metadata blocks are optional. They are used to display
@@ -84,6 +77,14 @@ resource "coder_agent" "main" {
8477
timeout = 1
8578
}
8679

80+
metadata {
81+
display_name = "Owner"
82+
key = "owner"
83+
script = "echo $OWNER_EMAIL"
84+
interval = 10
85+
timeout = 1
86+
}
87+
8788
metadata {
8889
display_name = "Hostname"
8990
key = "hostname"

site/e2e/tests/presets/prebuilds.spec.ts

+17-8
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import path from "node:path";
2-
import { type Locator, expect, test } from "@playwright/test";
2+
import {type Locator, expect, test, Page} from "@playwright/test";
33
import { users } from "../../constants";
44
import {
55
currentUser,
@@ -54,9 +54,7 @@ test("create template with desired prebuilds", async ({ page, baseURL }) => {
5454
await waitForExpectedCount(prebuilds, expectedPrebuilds);
5555

5656
// Wait for prebuilds to start.
57-
const runningPrebuilds = page
58-
.getByTestId("build-status")
59-
.getByText("Running");
57+
const runningPrebuilds = runningPrebuildsLocator(page);
6058
await waitForExpectedCount(runningPrebuilds, expectedPrebuilds);
6159
});
6260

@@ -86,15 +84,15 @@ test("claim prebuild matching selected preset", async ({ page, baseURL }) => {
8684
);
8785

8886
// Wait for prebuilds to start.
89-
let runningPrebuilds = page.getByTestId("build-status").getByText("Running");
87+
let runningPrebuilds = runningPrebuildsLocator(page);
9088
await waitForExpectedCount(runningPrebuilds, expectedPrebuilds);
9189

9290
// Open the first prebuild.
9391
await runningPrebuilds.first().click();
9492
await page.waitForURL(/\/@prebuilds\/prebuild-.+/);
9593

9694
// Wait for the prebuild to become ready so it's eligible to be claimed.
97-
await page.getByTestId("agent-status-ready").waitFor({ timeout: 60_000 });
95+
await page.getByTestId("agent-status-ready").waitFor({ timeout: 120_000 });
9896

9997
// Logout as admin, and login as an unprivileged user.
10098
await login(page, users.member);
@@ -127,12 +125,19 @@ test("claim prebuild matching selected preset", async ({ page, baseURL }) => {
127125
timeout: waitForBuildTimeout, // Account for workspace build time.
128126
});
129127

130-
// Validate the workspace metadata that it was indeed a claimed prebuild.
128+
// Validate via the workspace metadata that it was indeed a claimed prebuild.
131129
const indicator = page.getByText("Was Prebuild");
132130
await indicator.waitFor({ timeout: 60_000 });
133131
const text = indicator.locator("xpath=..").getByText("Yes");
134132
await text.waitFor({ timeout: 30_000 });
135133

134+
// Validate via the workspace metadata that terraform was run again, injecting the new owner via agent environment,
135+
// and the agent picked this up and reinitialized with a new environment.
136+
const owner = page.getByText("Owner");
137+
await owner.waitFor({ timeout: 60_000 });
138+
const ownerTxt = owner.locator("xpath=..").getByText(users.member.email);
139+
await ownerTxt.waitFor({ timeout: 30_000 });
140+
136141
// Logout as unprivileged user, and login as admin.
137142
await login(page, users.admin);
138143

@@ -156,10 +161,14 @@ test("claim prebuild matching selected preset", async ({ page, baseURL }) => {
156161
expect(currentWorkspaceNames).not.toEqual(previousWorkspaceNames);
157162

158163
// Wait for prebuilds to start.
159-
runningPrebuilds = page.getByTestId("build-status").getByText("Running");
164+
runningPrebuilds = runningPrebuildsLocator(page);
160165
await waitForExpectedCount(runningPrebuilds, expectedPrebuilds);
161166
});
162167

168+
function runningPrebuildsLocator(page: Page): Locator {
169+
return page.locator(".build-status").getByText("Running");
170+
}
171+
163172
function waitForExpectedCount(prebuilds: Locator, expectedCount: number) {
164173
return expect
165174
.poll(

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ const WorkspaceStatusCell: FC<WorkspaceStatusCellProps> = ({ workspace }) => {
376376

377377
return (
378378
<TableCell>
379-
<div className="flex flex-col">
379+
<div className="flex flex-col build-status">
380380
<StatusIndicator variant={variantByStatusType[type]}>
381381
<StatusIndicatorDot />
382382
{text}

0 commit comments

Comments
 (0)