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

Skip to content

Commit 7ca2a8b

Browse files
committed
fixed tests
1 parent c182357 commit 7ca2a8b

File tree

5 files changed

+72
-20
lines changed

5 files changed

+72
-20
lines changed

site/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
"@xstate/inspect": "0.6.5",
4646
"@xstate/react": "3.0.1",
4747
"axios": "0.26.1",
48+
"canvas": "^2.11.0",
4849
"chart.js": "3.9.1",
4950
"chartjs-adapter-date-fns": "3.0.0",
5051
"color-convert": "2.0.1",
@@ -107,7 +108,6 @@
107108
"@typescript-eslint/eslint-plugin": "5.50.0",
108109
"@typescript-eslint/parser": "5.45.1",
109110
"@xstate/cli": "0.3.0",
110-
"canvas": "2.10.0",
111111
"chromatic": "6.15.0",
112112
"eslint": "8.33.0",
113113
"eslint-config-prettier": "8.5.0",

site/src/components/AuditLogRow/AuditLogDescription/AuditLogDescription.test.tsx

Lines changed: 44 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,12 @@ import {
88
} from "testHelpers/entities"
99
import { AuditLogDescription } from "./AuditLogDescription"
1010
import { AuditLogRow } from "../AuditLogRow"
11-
import { render } from "../../../testHelpers/renderHelpers"
11+
import { render } from "testHelpers/renderHelpers"
1212
import { screen } from "@testing-library/react"
13+
import { i18n } from "i18n"
14+
15+
const t = (str: string, variables?: Record<string, unknown>) =>
16+
i18n.t<string>(str, variables)
1317

1418
const getByTextContent = (text: string) => {
1519
return screen.getByText((_, element) => {
@@ -25,9 +29,8 @@ describe("AuditLogDescription", () => {
2529
it("renders the correct string for a workspace create audit log", async () => {
2630
render(<AuditLogDescription auditLog={MockAuditLog} />)
2731

28-
expect(
29-
getByTextContent("TestUser created workspace bruno-dev"),
30-
).toBeDefined()
32+
expect(screen.getByText("TestUser created workspace")).toBeDefined()
33+
expect(screen.getByText("bruno-dev")).toBeDefined()
3134
})
3235

3336
it("renders the correct string for a workspace_build stop audit log", async () => {
@@ -55,27 +58,59 @@ describe("AuditLogDescription", () => {
5558
auditLog={MockWorkspaceCreateAuditLogForDifferentOwner}
5659
/>,
5760
)
61+
5862
expect(
59-
getByTextContent(
60-
`TestUser created workspace bruno-dev on behalf of ${MockWorkspaceCreateAuditLogForDifferentOwner.additional_fields.workspace_owner}`,
63+
screen.getByText(
64+
`on behalf of ${MockWorkspaceCreateAuditLogForDifferentOwner.additional_fields.workspace_owner}`,
65+
{ exact: false },
6166
),
6267
).toBeDefined()
6368
})
6469
it("renders the correct string for successful login", async () => {
6570
render(<AuditLogRow auditLog={MockAuditLogSuccessfulLogin} />)
66-
expect(getByTextContent(`TestUser logged in`)).toBeDefined()
71+
72+
expect(
73+
screen.getByText(
74+
t("auditLog:table.logRow.description.unlinkedAuditDescription", {
75+
truncatedDescription: `${MockAuditLogSuccessfulLogin.user?.username} logged in`,
76+
target: "",
77+
onBehalfOf: undefined,
78+
}).trim(),
79+
),
80+
).toBeInTheDocument()
81+
6782
const statusPill = screen.getByRole("status")
6883
expect(statusPill).toHaveTextContent("201")
6984
})
7085
it("renders the correct string for unsuccessful login for a known user", async () => {
7186
render(<AuditLogRow auditLog={MockAuditLogUnsuccessfulLoginKnownUser} />)
72-
expect(getByTextContent(`TestUser logged in`)).toBeDefined()
87+
88+
expect(
89+
screen.getByText(
90+
t("auditLog:table.logRow.description.unlinkedAuditDescription", {
91+
truncatedDescription: `${MockAuditLogUnsuccessfulLoginKnownUser.user?.username} logged in`,
92+
target: "",
93+
onBehalfOf: undefined,
94+
}).trim(),
95+
),
96+
).toBeInTheDocument()
97+
7398
const statusPill = screen.getByRole("status")
7499
expect(statusPill).toHaveTextContent("401")
75100
})
76101
it("renders the correct string for unsuccessful login for an unknown user", async () => {
77102
render(<AuditLogRow auditLog={MockAuditLogUnsuccessfulLoginUnknownUser} />)
78-
expect(getByTextContent(`an unknown user logged in`)).toBeDefined()
103+
104+
expect(
105+
screen.getByText(
106+
t("auditLog:table.logRow.description.unlinkedAuditDescription", {
107+
truncatedDescription: "an unknown user logged in",
108+
target: "",
109+
onBehalfOf: undefined,
110+
}).trim(),
111+
),
112+
).toBeInTheDocument()
113+
79114
const statusPill = screen.getByRole("status")
80115
expect(statusPill).toHaveTextContent("401")
81116
})
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
export {AuditLogDescription} from "./AuditLogDescription"
1+
export { AuditLogDescription } from "./AuditLogDescription"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export {AuditLogDiff} from './AuditLogDiff'
2-
export {determineGroupDiff} from './auditUtils'
1+
export { AuditLogDiff } from "./AuditLogDiff"
2+
export { determineGroupDiff } from "./auditUtils"

site/yarn.lock

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5165,13 +5165,13 @@ caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001304, caniuse-lite@^1.0.300014
51655165
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz#e7c59bd1bc518fae03a4656be442ce6c4887a795"
51665166
integrity sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==
51675167

5168-
canvas@2.10.0:
5169-
version "2.10.0"
5170-
resolved "https://registry.yarnpkg.com/canvas/-/canvas-2.10.0.tgz#5f48c8d1ff86c96356809097020336c3a1ccce27"
5171-
integrity sha512-A0RPxLcH0pPKAY2VN243LdCNcOJXAT8n7nJnN7TZMGv9OuF8we9wfpWgVT/eFMzi+cDYf/384w4BpfjGCD9aKQ==
5168+
canvas@^2.11.0:
5169+
version "2.11.0"
5170+
resolved "https://registry.yarnpkg.com/canvas/-/canvas-2.11.0.tgz#7f0c3e9ae94cf469269b5d3a7963a7f3a9936434"
5171+
integrity sha512-bdTjFexjKJEwtIo0oRx8eD4G2yWoUOXP9lj279jmQ2zMnTQhT8C3512OKz3s+ZOaQlLbE7TuVvRDYDB3Llyy5g==
51725172
dependencies:
51735173
"@mapbox/node-pre-gyp" "^1.0.0"
5174-
nan "^2.15.0"
5174+
nan "^2.17.0"
51755175
simple-get "^3.0.3"
51765176

51775177
capture-exit@^2.0.0:
@@ -10783,6 +10783,11 @@ minipass@^3.0.0, minipass@^3.1.1:
1078310783
dependencies:
1078410784
yallist "^4.0.0"
1078510785

10786+
minipass@^4.0.0:
10787+
version "4.0.2"
10788+
resolved "https://registry.yarnpkg.com/minipass/-/minipass-4.0.2.tgz#26fc3364d5ea6cb971c6e5259eac67a0887510d1"
10789+
integrity sha512-4Hbzei7ZyBp+1aw0874YWpKOubZd/jc53/XU+gkYry1QV+VvrbO8icLM5CUtm4F0hyXn85DXYKEMIS26gitD3A==
10790+
1078610791
minizlib@^2.1.1:
1078710792
version "2.1.2"
1078810793
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931"
@@ -10907,7 +10912,7 @@ [email protected]:
1090710912
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
1090810913
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==
1090910914

10910-
nan@^2.12.1, nan@^2.15.0:
10915+
nan@^2.12.1, nan@^2.17.0:
1091110916
version "2.17.0"
1091210917
resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb"
1091310918
integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==
@@ -13669,7 +13674,7 @@ tar-stream@^2.0.1:
1366913674
inherits "^2.0.3"
1367013675
readable-stream "^3.1.1"
1367113676

13672-
tar@^6.0.2, tar@^6.1.11:
13677+
tar@^6.0.2:
1367313678
version "6.1.12"
1367413679
resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.12.tgz#3b742fb05669b55671fb769ab67a7791ea1a62e6"
1367513680
integrity sha512-jU4TdemS31uABHd+Lt5WEYJuzn+TJTCBLljvIAHZOz6M9Os5pJ4dD+vRFLxPa/n3T0iEFzpi+0x1UfuDZYbRMw==
@@ -13681,6 +13686,18 @@ tar@^6.0.2, tar@^6.1.11:
1368113686
mkdirp "^1.0.3"
1368213687
yallist "^4.0.0"
1368313688

13689+
tar@^6.1.11:
13690+
version "6.1.13"
13691+
resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.13.tgz#46e22529000f612180601a6fe0680e7da508847b"
13692+
integrity sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==
13693+
dependencies:
13694+
chownr "^2.0.0"
13695+
fs-minipass "^2.0.0"
13696+
minipass "^4.0.0"
13697+
minizlib "^2.1.1"
13698+
mkdirp "^1.0.3"
13699+
yallist "^4.0.0"
13700+
1368413701
telejson@^6.0.8:
1368513702
version "6.0.8"
1368613703
resolved "https://registry.yarnpkg.com/telejson/-/telejson-6.0.8.tgz#1c432db7e7a9212c1fbd941c3e5174ec385148f7"

0 commit comments

Comments
 (0)