Skip to content

Commit 00ef754

Browse files
committed
Add more audit mocks
To test different org names and no org.
1 parent 8556f92 commit 00ef754

File tree

2 files changed

+54
-5
lines changed

2 files changed

+54
-5
lines changed

site/src/pages/AuditPage/AuditPageView.stories.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ import {
1010
} from "components/PaginationWidget/PaginationContainer.mocks";
1111
import type { UsePaginatedQueryResult } from "hooks/usePaginatedQuery";
1212
import { chromaticWithTablet } from "testHelpers/chromatic";
13-
import { MockAuditLog, MockAuditLog2, MockUser } from "testHelpers/entities";
13+
import {
14+
MockAuditLog,
15+
MockAuditLog2,
16+
MockAuditLog3,
17+
MockUser,
18+
} from "testHelpers/entities";
1419
import { AuditPageView } from "./AuditPageView";
1520

1621
type FilterProps = ComponentProps<typeof AuditPageView>["filterProps"];
@@ -35,7 +40,7 @@ const meta: Meta<typeof AuditPageView> = {
3540
title: "pages/AuditPage",
3641
component: AuditPageView,
3742
args: {
38-
auditLogs: [MockAuditLog, MockAuditLog2],
43+
auditLogs: [MockAuditLog, MockAuditLog2, MockAuditLog3],
3944
isAuditLogVisible: true,
4045
filterProps: defaultFilterProps,
4146
},

site/src/testHelpers/entities.ts

Lines changed: 47 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2211,16 +2211,19 @@ export const MockEntitlementsWithUserLimit: TypesGen.Entitlements = {
22112211

22122212
export const MockExperiments: TypesGen.Experiment[] = [];
22132213

2214+
/**
2215+
* An audit log for MockOrganization.
2216+
*/
22142217
export const MockAuditLog: TypesGen.AuditLog = {
22152218
id: "fbd2116a-8961-4954-87ae-e4575bd29ce0",
22162219
request_id: "53bded77-7b9d-4e82-8771-991a34d759f9",
22172220
time: "2022-05-19T16:45:57.122Z",
22182221
organization_id: MockOrganization.id,
22192222
organization: {
22202223
id: MockOrganization.id,
2221-
name: "mock name",
2222-
display_name: "mock display name",
2223-
icon: "/emojis/1f48f-1f3ff.png",
2224+
name: MockOrganization.name,
2225+
display_name: MockOrganization.display_name,
2226+
icon: MockOrganization.icon,
22242227
},
22252228
ip: "127.0.0.1",
22262229
user_agent:
@@ -2245,12 +2248,22 @@ export const MockAuditLog: TypesGen.AuditLog = {
22452248
is_deleted: false,
22462249
};
22472250

2251+
/**
2252+
* An audit log for MockOrganization2.
2253+
*/
22482254
export const MockAuditLog2: TypesGen.AuditLog = {
22492255
...MockAuditLog,
22502256
id: "53bded77-7b9d-4e82-8771-991a34d759f9",
22512257
action: "write",
22522258
time: "2022-05-20T16:45:57.122Z",
22532259
description: "{user} updated workspace {target}",
2260+
organization_id: MockOrganization2.id,
2261+
organization: {
2262+
id: MockOrganization2.id,
2263+
name: MockOrganization2.name,
2264+
display_name: MockOrganization2.display_name,
2265+
icon: MockOrganization2.icon,
2266+
},
22542267
diff: {
22552268
workspace_name: {
22562269
old: "old-workspace-name",
@@ -2275,6 +2288,37 @@ export const MockAuditLog2: TypesGen.AuditLog = {
22752288
},
22762289
};
22772290

2291+
/**
2292+
* An audit log without an organization.
2293+
*/
2294+
export const MockAuditLog3: TypesGen.AuditLog = {
2295+
id: "8efa9208-656a-422d-842d-b9dec0cf1bf3",
2296+
request_id: "57ee9510-8330-480d-9ffa-4024e5805465",
2297+
time: "2024-06-11T01:32:11.123Z",
2298+
organization_id: "00000000-0000-0000-000000000000",
2299+
ip: "127.0.0.1",
2300+
user_agent:
2301+
'"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36"',
2302+
resource_type: "template",
2303+
resource_id: "a624458c-1562-4689-a671-42c0b7d2d0c5",
2304+
resource_target: "docker",
2305+
resource_icon: "",
2306+
action: "write",
2307+
diff: {
2308+
display_name: {
2309+
old: "old display",
2310+
new: "new display",
2311+
secret: false,
2312+
},
2313+
},
2314+
status_code: 200,
2315+
additional_fields: {},
2316+
description: "{user} updated template {target}",
2317+
user: MockUser,
2318+
resource_link: "/templates/docker",
2319+
is_deleted: false,
2320+
};
2321+
22782322
export const MockWorkspaceCreateAuditLogForDifferentOwner = {
22792323
...MockAuditLog,
22802324
additional_fields: {

0 commit comments

Comments
 (0)