Skip to content

Commit 5396dcd

Browse files
committed
Wait for agent ready
1 parent 3cac0ee commit 5396dcd

File tree

11 files changed

+48
-16
lines changed

11 files changed

+48
-16
lines changed

site/e2e/playwright.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ const config: PlaywrightTestConfig = {
2020
port,
2121
reuseExistingServer: false,
2222
},
23+
timeout: 120 * 1000,
2324
}
2425

2526
export default config

site/e2e/pom/CreateTemplatePage.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,12 @@ export class CreateTemplatePage extends BasePom {
2121

2222
async submitForm() {
2323
await this.createTemplateForm
24-
.getByTestId("form-template-upload")
25-
.setInputFiles("./e2e/testdata/docker.tar")
24+
.getByTestId("form-template-upload")
25+
.setInputFiles("./e2e/testdata/docker.tar")
2626
await this.createTemplateForm.getByLabel("Name *").fill("my-first-template")
27-
await this.createTemplateForm.getByLabel("Display name").fill("My First Template")
27+
await this.createTemplateForm
28+
.getByLabel("Display name")
29+
.fill("My First Template")
2830
await this.createTemplateForm
2931
.getByLabel("Description")
3032
.fill("This is my first template.")

site/e2e/pom/CreateWorkspacePage.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class CreateWorkspacePage extends BasePom {
2020
}
2121

2222
async submitForm() {
23-
await this.createWorkspaceForm.getByLabel("Workspace Name").fill("my-first-workspace")
23+
await this.createWorkspaceForm
24+
.getByLabel("Workspace Name")
25+
.fill("my-first-workspace")
2426

2527
await this.submitButton.click()
2628
}

site/e2e/pom/WorkspacePage.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,23 @@ import { BasePom } from "./BasePom"
44
export class WorkspacePage extends BasePom {
55
readonly workspaceRunningBadge: Locator
66
readonly workspaceStoppedBadge: Locator
7+
readonly terminalButton: Locator
8+
readonly agentVersion: Locator
9+
readonly agentLifecycleReady: Locator
710
readonly stopWorkspaceButton: Locator
811

912
constructor(baseURL: string | undefined, page: Page) {
1013
super(baseURL, `/templates/docker/workspace`, page)
1114

12-
this.workspaceRunningBadge = page.getByTestId("badge-workspace-status-running")
13-
this.workspaceStoppedBadge = page.getByTestId("badge-workspace-status-stopped")
15+
this.workspaceRunningBadge = page.getByTestId(
16+
"badge-workspace-status-running",
17+
)
18+
this.workspaceStoppedBadge = page.getByTestId(
19+
"badge-workspace-status-stopped",
20+
)
21+
this.terminalButton = page.getByTestId("button-terminal")
22+
this.agentVersion = page.getByTestId("agent-version")
23+
this.agentLifecycleReady = page.getByTestId("agent-lifecycle-ready")
1424
this.stopWorkspaceButton = page.getByTestId("button-stop-workspace")
1525
}
1626

@@ -21,6 +31,10 @@ export class WorkspacePage extends BasePom {
2131

2232
async isRunning() {
2333
await this.workspaceRunningBadge.waitFor({ state: "visible" })
34+
await this.terminalButton.waitFor({ state: "visible" })
35+
await this.agentVersion.waitFor({ state: "visible" })
36+
await this.agentLifecycleReady.waitFor({ state: "visible" })
37+
await this.page.waitForTimeout(1000) // Wait for 1s to snapshot the agent status on the video
2438
}
2539

2640
async stop() {

site/e2e/tests/basicScenario.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,27 +28,27 @@ test("Basic scenario", async ({ page, baseURL }) => {
2828
await templatePage.loaded()
2929
})
3030

31-
await test.step("Start a workspace", async() => {
31+
await test.step("Start a workspace", async () => {
3232
await templatePage.createWorkspace()
3333
await createWorkspacePage.loaded()
3434

3535
await createWorkspacePage.submitForm()
3636
await workspacePage.loaded()
3737
})
3838

39-
await test.step("Workspace is up and running", async() => {
39+
await test.step("Workspace is up and running", async () => {
4040
await workspacePage.isRunning()
4141
})
4242

43-
await test.step("Stop the workspace", async() => {
43+
await test.step("Stop the workspace", async () => {
4444
await workspacePage.stop()
4545
})
4646

47-
await test.step("Workspace is stopped", async() => {
47+
await test.step("Workspace is stopped", async () => {
4848
await workspacePage.isStopped()
4949
})
5050

51-
await test.step("Finally", async() => {
51+
await test.step("Finally", async () => {
5252
await page.waitForTimeout(5 * 60 * 1000) // FIXME
5353
})
5454
})

site/src/components/Resources/AgentStatus.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const ReadyLifecycle: React.FC = () => {
2828
role="status"
2929
aria-label={t("agentStatus.connected.ready")}
3030
className={combineClasses([styles.status, styles.connected])}
31+
data-testid="agent-lifecycle-ready"
3132
/>
3233
)
3334
}

site/src/components/Resources/AgentVersion.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export const AgentVersion: FC<{
1919
)
2020

2121
if (!outdated) {
22-
return <span>{displayVersion}</span>
22+
return <span data-testid="agent-version">{displayVersion}</span>
2323
}
2424

2525
return (
@@ -31,6 +31,7 @@ export const AgentVersion: FC<{
3131
onMouseEnter={() => setIsOpen(true)}
3232
onMouseLeave={() => setIsOpen(false)}
3333
className={styles.trigger}
34+
data-testid="agent-version"
3435
>
3536
Agent Outdated
3637
</span>

site/src/components/TerminalLink/TerminalLink.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export const TerminalLink: FC<React.PropsWithChildren<TerminalLinkProps>> = ({
4242
href={href}
4343
className={combineClasses([styles.link, className])}
4444
target="_blank"
45+
data-testid="button-terminal"
4546
onClick={(event) => {
4647
event.preventDefault()
4748
window.open(

site/src/components/WorkspaceStatusBadge/WorkspaceStatusBadge.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,13 @@ export const WorkspaceStatusBadge: FC<
100100
PropsWithChildren<WorkspaceStatusBadgeProps>
101101
> = ({ build, className }) => {
102102
const { text, icon, type } = getStatus(build.status)
103-
return <Pill className={className} icon={icon} text={text} type={type} dataTestId={"badge-workspace-status-" + build.status }
104-
/>
103+
return (
104+
<Pill
105+
className={className}
106+
icon={icon}
107+
text={text}
108+
type={type}
109+
dataTestId={"badge-workspace-status-" + build.status}
110+
/>
111+
)
105112
}

site/src/pages/CreateWorkspacePage/CreateWorkspacePageView.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ export const CreateWorkspacePageView: FC<
211211

212212
return (
213213
<FullPageHorizontalForm title="New workspace" onCancel={props.onCancel}>
214-
<HorizontalForm onSubmit={form.handleSubmit} data-testid="form-create-workspace">
214+
<HorizontalForm
215+
onSubmit={form.handleSubmit}
216+
data-testid="form-create-workspace"
217+
>
215218
{/* General info */}
216219
<FormSection
217220
title="General info"

site/src/pages/TemplatePage/TemplateSummaryPage/TemplateSummaryPageView.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export const TemplateSummaryPageView: FC<TemplateSummaryPageViewProps> = ({
5151
<Stack spacing={4}>
5252
<TemplateStats template={template} activeVersion={activeVersion} />
5353
{daus && <DAUChart daus={daus} />}
54-
<TemplateResourcesTable resources={getStartedResources(resources)}/>
54+
<TemplateResourcesTable resources={getStartedResources(resources)} />
5555
</Stack>
5656
)
5757
}

0 commit comments

Comments
 (0)