Skip to content

chore: change build audit log string to be clearer #6093

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 10 commits into from
Feb 8, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixed tests
  • Loading branch information
Kira-Pilot committed Feb 7, 2023
commit 7ca2a8b25bf596863971e98dd92647b6d2ef98a3
2 changes: 1 addition & 1 deletion site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@xstate/inspect": "0.6.5",
"@xstate/react": "3.0.1",
"axios": "0.26.1",
"canvas": "^2.11.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting changes here because I ran into this issue and had to re-add canvas.

"chart.js": "3.9.1",
"chartjs-adapter-date-fns": "3.0.0",
"color-convert": "2.0.1",
Expand Down Expand Up @@ -107,7 +108,6 @@
"@typescript-eslint/eslint-plugin": "5.50.0",
"@typescript-eslint/parser": "5.45.1",
"@xstate/cli": "0.3.0",
"canvas": "2.10.0",
"chromatic": "6.15.0",
"eslint": "8.33.0",
"eslint-config-prettier": "8.5.0",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,12 @@ import {
} from "testHelpers/entities"
import { AuditLogDescription } from "./AuditLogDescription"
import { AuditLogRow } from "../AuditLogRow"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These tests aren't perfect - I was having difficulty testing strings with an embedded Link. I will return at a later time and maybe turn these into stories or create a custom matcher.

import { render } from "../../../testHelpers/renderHelpers"
import { render } from "testHelpers/renderHelpers"
import { screen } from "@testing-library/react"
import { i18n } from "i18n"

const t = (str: string, variables?: Record<string, unknown>) =>
i18n.t<string>(str, variables)

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

expect(
getByTextContent("TestUser created workspace bruno-dev"),
).toBeDefined()
expect(screen.getByText("TestUser created workspace")).toBeDefined()
expect(screen.getByText("bruno-dev")).toBeDefined()
})

it("renders the correct string for a workspace_build stop audit log", async () => {
Expand Down Expand Up @@ -55,27 +58,59 @@ describe("AuditLogDescription", () => {
auditLog={MockWorkspaceCreateAuditLogForDifferentOwner}
/>,
)

expect(
getByTextContent(
`TestUser created workspace bruno-dev on behalf of ${MockWorkspaceCreateAuditLogForDifferentOwner.additional_fields.workspace_owner}`,
screen.getByText(
`on behalf of ${MockWorkspaceCreateAuditLogForDifferentOwner.additional_fields.workspace_owner}`,
{ exact: false },
),
).toBeDefined()
})
it("renders the correct string for successful login", async () => {
render(<AuditLogRow auditLog={MockAuditLogSuccessfulLogin} />)
expect(getByTextContent(`TestUser logged in`)).toBeDefined()

expect(
screen.getByText(
t("auditLog:table.logRow.description.unlinkedAuditDescription", {
truncatedDescription: `${MockAuditLogSuccessfulLogin.user?.username} logged in`,
target: "",
onBehalfOf: undefined,
}).trim(),
),
).toBeInTheDocument()

const statusPill = screen.getByRole("status")
expect(statusPill).toHaveTextContent("201")
})
it("renders the correct string for unsuccessful login for a known user", async () => {
render(<AuditLogRow auditLog={MockAuditLogUnsuccessfulLoginKnownUser} />)
expect(getByTextContent(`TestUser logged in`)).toBeDefined()

expect(
screen.getByText(
t("auditLog:table.logRow.description.unlinkedAuditDescription", {
truncatedDescription: `${MockAuditLogUnsuccessfulLoginKnownUser.user?.username} logged in`,
target: "",
onBehalfOf: undefined,
}).trim(),
),
).toBeInTheDocument()

const statusPill = screen.getByRole("status")
expect(statusPill).toHaveTextContent("401")
})
it("renders the correct string for unsuccessful login for an unknown user", async () => {
render(<AuditLogRow auditLog={MockAuditLogUnsuccessfulLoginUnknownUser} />)
expect(getByTextContent(`an unknown user logged in`)).toBeDefined()

expect(
screen.getByText(
t("auditLog:table.logRow.description.unlinkedAuditDescription", {
truncatedDescription: "an unknown user logged in",
target: "",
onBehalfOf: undefined,
}).trim(),
),
).toBeInTheDocument()

const statusPill = screen.getByRole("status")
expect(statusPill).toHaveTextContent("401")
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {AuditLogDescription} from "./AuditLogDescription"
export { AuditLogDescription } from "./AuditLogDescription"
4 changes: 2 additions & 2 deletions site/src/components/AuditLogRow/AuditLogDiff/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export {AuditLogDiff} from './AuditLogDiff'
export {determineGroupDiff} from './auditUtils'
export { AuditLogDiff } from "./AuditLogDiff"
export { determineGroupDiff } from "./auditUtils"
31 changes: 24 additions & 7 deletions site/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5165,13 +5165,13 @@ caniuse-lite@^1.0.30001109, caniuse-lite@^1.0.30001304, caniuse-lite@^1.0.300014
resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30001431.tgz#e7c59bd1bc518fae03a4656be442ce6c4887a795"
integrity sha512-zBUoFU0ZcxpvSt9IU66dXVT/3ctO1cy4y9cscs1szkPlcWb6pasYM144GqrUygUbT+k7cmUCW61cvskjcv0enQ==

canvas@2.10.0:
version "2.10.0"
resolved "https://registry.yarnpkg.com/canvas/-/canvas-2.10.0.tgz#5f48c8d1ff86c96356809097020336c3a1ccce27"
integrity sha512-A0RPxLcH0pPKAY2VN243LdCNcOJXAT8n7nJnN7TZMGv9OuF8we9wfpWgVT/eFMzi+cDYf/384w4BpfjGCD9aKQ==
canvas@^2.11.0:
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're getting changes here because I ran into this issue and had to re-add canvas.

version "2.11.0"
resolved "https://registry.yarnpkg.com/canvas/-/canvas-2.11.0.tgz#7f0c3e9ae94cf469269b5d3a7963a7f3a9936434"
integrity sha512-bdTjFexjKJEwtIo0oRx8eD4G2yWoUOXP9lj279jmQ2zMnTQhT8C3512OKz3s+ZOaQlLbE7TuVvRDYDB3Llyy5g==
dependencies:
"@mapbox/node-pre-gyp" "^1.0.0"
nan "^2.15.0"
nan "^2.17.0"
simple-get "^3.0.3"

capture-exit@^2.0.0:
Expand Down Expand Up @@ -10783,6 +10783,11 @@ minipass@^3.0.0, minipass@^3.1.1:
dependencies:
yallist "^4.0.0"

minipass@^4.0.0:
version "4.0.2"
resolved "https://registry.yarnpkg.com/minipass/-/minipass-4.0.2.tgz#26fc3364d5ea6cb971c6e5259eac67a0887510d1"
integrity sha512-4Hbzei7ZyBp+1aw0874YWpKOubZd/jc53/XU+gkYry1QV+VvrbO8icLM5CUtm4F0hyXn85DXYKEMIS26gitD3A==

minizlib@^2.1.1:
version "2.1.2"
resolved "https://registry.yarnpkg.com/minizlib/-/minizlib-2.1.2.tgz#e90d3466ba209b932451508a11ce3d3632145931"
Expand Down Expand Up @@ -10907,7 +10912,7 @@ mute-stream@0.0.8:
resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.8.tgz#1630c42b2251ff81e2a283de96a5497ea92e5e0d"
integrity sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==

nan@^2.12.1, nan@^2.15.0:
nan@^2.12.1, nan@^2.17.0:
version "2.17.0"
resolved "https://registry.yarnpkg.com/nan/-/nan-2.17.0.tgz#c0150a2368a182f033e9aa5195ec76ea41a199cb"
integrity sha512-2ZTgtl0nJsO0KQCjEpxcIr5D+Yv90plTitZt9JBfQvVJDS5seMl3FOvsh3+9CoYWXf/1l5OaZzzF6nDm4cagaQ==
Expand Down Expand Up @@ -13669,7 +13674,7 @@ tar-stream@^2.0.1:
inherits "^2.0.3"
readable-stream "^3.1.1"

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

tar@^6.1.11:
version "6.1.13"
resolved "https://registry.yarnpkg.com/tar/-/tar-6.1.13.tgz#46e22529000f612180601a6fe0680e7da508847b"
integrity sha512-jdIBIN6LTIe2jqzay/2vtYLlBHa3JF42ot3h1dW8Q0PaAG4v8rm0cvpVePtau5C6OKXGGcgO9q2AMNSWxiLqKw==
dependencies:
chownr "^2.0.0"
fs-minipass "^2.0.0"
minipass "^4.0.0"
minizlib "^2.1.1"
mkdirp "^1.0.3"
yallist "^4.0.0"

telejson@^6.0.8:
version "6.0.8"
resolved "https://registry.yarnpkg.com/telejson/-/telejson-6.0.8.tgz#1c432db7e7a9212c1fbd941c3e5174ec385148f7"
Expand Down