Skip to content

Commit 56516ef

Browse files
committed
Fix tests
1 parent 90a2c6c commit 56516ef

File tree

2 files changed

+37
-22
lines changed

2 files changed

+37
-22
lines changed

site/src/pages/WorkspacePage/WorkspacePage.test.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { rest } from "msw"
33
import React from "react"
44
import * as api from "../../api/api"
55
import { Workspace } from "../../api/typesGenerated"
6-
import { Language } from "../../components/WorkspaceStatusBar/WorkspaceStatusBar"
6+
import { Language } from "../../components/WorkspaceActions/WorkspaceActions"
77
import {
88
MockBuilds,
99
MockCancelingWorkspace,
@@ -20,6 +20,7 @@ import {
2020
renderWithAuth,
2121
} from "../../testHelpers/renderHelpers"
2222
import { server } from "../../testHelpers/server"
23+
import { DisplayStatusLanguage } from "../../util/workspace"
2324
import { WorkspacePage } from "./WorkspacePage"
2425

2526
// It renders the workspace page and waits for it be loaded
@@ -133,28 +134,28 @@ describe("Workspace Page", () => {
133134
await testButton(Language.update, getTemplateMock)
134135
})
135136
it("shows the Stopping status when the workspace is stopping", async () => {
136-
await testStatus(MockStoppingWorkspace, Language.stopping)
137+
await testStatus(MockStoppingWorkspace, DisplayStatusLanguage.stopping)
137138
})
138139
it("shows the Stopped status when the workspace is stopped", async () => {
139-
await testStatus(MockStoppedWorkspace, Language.stopped)
140+
await testStatus(MockStoppedWorkspace, DisplayStatusLanguage.stopped)
140141
})
141142
it("shows the Building status when the workspace is starting", async () => {
142-
await testStatus(MockStartingWorkspace, Language.starting)
143+
await testStatus(MockStartingWorkspace, DisplayStatusLanguage.starting)
143144
})
144145
it("shows the Running status when the workspace is started", async () => {
145-
await testStatus(MockWorkspace, Language.started)
146+
await testStatus(MockWorkspace, DisplayStatusLanguage.started)
146147
})
147-
it("shows the Error status when the workspace is failed or canceled", async () => {
148-
await testStatus(MockFailedWorkspace, Language.error)
148+
it("shows the Failed status when the workspace is failed or canceled", async () => {
149+
await testStatus(MockFailedWorkspace, DisplayStatusLanguage.failed)
149150
})
150-
it("shows the Loading status when the workspace is canceling", async () => {
151-
await testStatus(MockCancelingWorkspace, Language.canceling)
151+
it("shows the Canceling status when the workspace is canceling", async () => {
152+
await testStatus(MockCancelingWorkspace, DisplayStatusLanguage.canceling)
152153
})
153154
it("shows the Deleting status when the workspace is deleting", async () => {
154-
await testStatus(MockDeletingWorkspace, Language.deleting)
155+
await testStatus(MockDeletingWorkspace, DisplayStatusLanguage.deleting)
155156
})
156157
it("shows the Deleted status when the workspace is deleted", async () => {
157-
await testStatus(MockDeletedWorkspace, Language.deleted)
158+
await testStatus(MockDeletedWorkspace, DisplayStatusLanguage.deleted)
158159
})
159160
it("shows the timeline build", async () => {
160161
await renderWorkspacePage()

site/src/util/workspace.ts

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,20 @@ export const getWorkspaceStatus = (workspaceBuild?: WorkspaceBuild): WorkspaceSt
5050
}
5151
}
5252

53+
export const DisplayStatusLanguage = {
54+
loading: "Loading...",
55+
started: "Running",
56+
starting: "Starting",
57+
stopping: "Stopping",
58+
stopped: "Stopped",
59+
deleting: "Deleting",
60+
deleted: "Deleted",
61+
canceling: "Canceling",
62+
canceled: "Canceled",
63+
failed: "Failed",
64+
queued: "Queued",
65+
}
66+
5367
export const getDisplayStatus = (
5468
theme: Theme,
5569
build: WorkspaceBuild,
@@ -62,57 +76,57 @@ export const getDisplayStatus = (
6276
case undefined:
6377
return {
6478
color: theme.palette.text.secondary,
65-
status: "Loading...",
79+
status: DisplayStatusLanguage.loading,
6680
}
6781
case "started":
6882
return {
6983
color: theme.palette.success.main,
70-
status: "⦿ Running",
84+
status: `⦿ ${DisplayStatusLanguage.started}`,
7185
}
7286
case "starting":
7387
return {
7488
color: theme.palette.success.main,
75-
status: "⦿ Starting",
89+
status: `⦿ ${DisplayStatusLanguage.starting}`,
7690
}
7791
case "stopping":
7892
return {
7993
color: theme.palette.text.secondary,
80-
status: "◍ Stopping",
94+
status: `◍ ${DisplayStatusLanguage.stopping}`,
8195
}
8296
case "stopped":
8397
return {
8498
color: theme.palette.text.secondary,
85-
status: "◍ Stopped",
99+
status: `◍ ${DisplayStatusLanguage.stopped}`,
86100
}
87101
case "deleting":
88102
return {
89103
color: theme.palette.text.secondary,
90-
status: "⦸ Deleting",
104+
status: `⦸ ${DisplayStatusLanguage.deleting}`,
91105
}
92106
case "deleted":
93107
return {
94108
color: theme.palette.text.secondary,
95-
status: "⦸ Deleted",
109+
status: `⦸ ${DisplayStatusLanguage.deleted}`,
96110
}
97111
case "canceling":
98112
return {
99113
color: theme.palette.warning.light,
100-
status: "◍ Canceling",
114+
status: `◍ ${DisplayStatusLanguage.canceling}`,
101115
}
102116
case "canceled":
103117
return {
104118
color: theme.palette.text.secondary,
105-
status: "◍ Canceled",
119+
status: `◍ ${DisplayStatusLanguage.canceled}`,
106120
}
107121
case "error":
108122
return {
109123
color: theme.palette.error.main,
110-
status: "ⓧ Failed",
124+
status: `ⓧ ${DisplayStatusLanguage.failed}`,
111125
}
112126
case "queued":
113127
return {
114128
color: theme.palette.text.secondary,
115-
status: "◍ Queued",
129+
status: `◍ ${DisplayStatusLanguage.queued}`,
116130
}
117131
}
118132
throw new Error("unknown status " + status)

0 commit comments

Comments
 (0)