Skip to content

Commit 0479d34

Browse files
committed
Add frontend mock for buildinfo route
1 parent 0eac736 commit 0479d34

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

site/src/components/Page/Footer.test.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { screen } from "@testing-library/react"
22
import React from "react"
3-
import { render } from "../../test_helpers"
3+
import { MockBuildInfo, render } from "../../test_helpers"
44
import { Footer } from "./Footer"
55

66
describe("Footer", () => {
@@ -10,5 +10,6 @@ describe("Footer", () => {
1010

1111
// Then
1212
await screen.findByText("Copyright", { exact: false })
13+
await screen.findByText(MockBuildInfo.version, { exact: false })
1314
})
1415
})

site/src/test_helpers/entities.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1-
import { Organization, Project, Provisioner, UserAgent, UserResponse, Workspace } from "../api/types"
1+
import { BuildInfoResponse, Organization, Project, Provisioner, UserAgent, UserResponse, Workspace } from "../api/types"
22

33
export const MockSessionToken = { session_token: "my-session-token" }
44

55
export const MockAPIKey = { key: "my-api-key" }
66

7+
export const MockBuildInfo: BuildInfoResponse = {
8+
version: "v99.999.9999+c9cdf14",
9+
}
10+
711
export const MockUser: UserResponse = {
812
id: "test-user",
913
username: "TestUser",

site/src/test_helpers/handlers.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ import { rest } from "msw"
22
import * as M from "./entities"
33

44
export const handlers = [
5+
// build info
6+
rest.get("/api/v2/buildinfo", async (req, res, ctx) => {
7+
return res(ctx.status(200), ctx.json(M.MockBuildInfo))
8+
}),
9+
510
// organizations
611
rest.get("/api/v2/organizations/:organizationId", async (req, res, ctx) => {
712
return res(ctx.status(200), ctx.json(M.MockOrganization))

0 commit comments

Comments
 (0)