Skip to content

Commit 1938f07

Browse files
committed
Add more audit mocks
To test different org names and no org.
1 parent 63d736f commit 1938f07

File tree

2 files changed

+60
-5
lines changed

2 files changed

+60
-5
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ 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 { MockAuditLog, MockAuditLog2, MockAuditLog3, MockUser } from "testHelpers/entities";
1414
import { AuditPageView } from "./AuditPageView";
1515

1616
type FilterProps = ComponentProps<typeof AuditPageView>["filterProps"];
@@ -35,7 +35,7 @@ const meta: Meta<typeof AuditPageView> = {
3535
title: "pages/AuditPage",
3636
component: AuditPageView,
3737
args: {
38-
auditLogs: [MockAuditLog, MockAuditLog2],
38+
auditLogs: [MockAuditLog, MockAuditLog2, MockAuditLog3],
3939
isAuditLogVisible: true,
4040
filterProps: defaultFilterProps,
4141
},

site/src/testHelpers/entities.ts

Lines changed: 58 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ export const MockOrganization: TypesGen.Organization = {
2222
is_default: false,
2323
};
2424

25+
export const MockOrganization2: TypesGen.Organization = {
26+
id: "8efa9208-656a-422d-842d-b9dec0cf1bf3",
27+
name: "my-second-organization",
28+
display_name: "My Second Organization",
29+
description: "A second organization that gets used for stuff.",
30+
icon: "",
31+
created_at: "",
32+
updated_at: "",
33+
is_default: false,
34+
};
35+
2536
export const MockDefaultOrganization: TypesGen.Organization = {
2637
...MockOrganization,
2738
is_default: true,
@@ -2148,16 +2159,19 @@ export const MockEntitlementsWithUserLimit: TypesGen.Entitlements = {
21482159

21492160
export const MockExperiments: TypesGen.Experiment[] = [];
21502161

2162+
/**
2163+
* An audit log for MockOrganization.
2164+
*/
21512165
export const MockAuditLog: TypesGen.AuditLog = {
21522166
id: "fbd2116a-8961-4954-87ae-e4575bd29ce0",
21532167
request_id: "53bded77-7b9d-4e82-8771-991a34d759f9",
21542168
time: "2022-05-19T16:45:57.122Z",
21552169
organization_id: MockOrganization.id,
21562170
organization: {
21572171
id: MockOrganization.id,
2158-
name: "mock name",
2159-
display_name: "mock display name",
2160-
icon: "/emojis/1f48f-1f3ff.png",
2172+
name: MockOrganization.name,
2173+
display_name: MockOrganization.display_name,
2174+
icon: MockOrganization.icon,
21612175
},
21622176
ip: "127.0.0.1",
21632177
user_agent:
@@ -2182,12 +2196,22 @@ export const MockAuditLog: TypesGen.AuditLog = {
21822196
is_deleted: false,
21832197
};
21842198

2199+
/**
2200+
* An audit log for MockOrganization2.
2201+
*/
21852202
export const MockAuditLog2: TypesGen.AuditLog = {
21862203
...MockAuditLog,
21872204
id: "53bded77-7b9d-4e82-8771-991a34d759f9",
21882205
action: "write",
21892206
time: "2022-05-20T16:45:57.122Z",
21902207
description: "{user} updated workspace {target}",
2208+
organization_id: MockOrganization2.id,
2209+
organization: {
2210+
id: MockOrganization2.id,
2211+
name: MockOrganization2.name,
2212+
display_name: MockOrganization2.display_name,
2213+
icon: MockOrganization2.icon,
2214+
},
21912215
diff: {
21922216
workspace_name: {
21932217
old: "old-workspace-name",
@@ -2212,6 +2236,37 @@ export const MockAuditLog2: TypesGen.AuditLog = {
22122236
},
22132237
};
22142238

2239+
/**
2240+
* An audit log without an organization.
2241+
*/
2242+
export const MockAuditLog3: TypesGen.AuditLog = {
2243+
id: "8efa9208-656a-422d-842d-b9dec0cf1bf3",
2244+
request_id: "57ee9510-8330-480d-9ffa-4024e5805465",
2245+
time: "2024-06-11T01:32:11.123Z",
2246+
organization_id: "00000000-0000-0000-000000000000",
2247+
ip: "127.0.0.1",
2248+
user_agent:
2249+
'"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"',
2250+
resource_type: "template",
2251+
resource_id: "a624458c-1562-4689-a671-42c0b7d2d0c5",
2252+
resource_target: "docker",
2253+
resource_icon: "",
2254+
action: "write",
2255+
diff: {
2256+
display_name: {
2257+
old: "old display",
2258+
new: "new display",
2259+
secret: false,
2260+
},
2261+
},
2262+
status_code: 200,
2263+
additional_fields: {},
2264+
description: "{user} updated template {target}",
2265+
user: MockUser,
2266+
resource_link: "/templates/docker",
2267+
is_deleted: false,
2268+
};
2269+
22152270
export const MockWorkspaceCreateAuditLogForDifferentOwner = {
22162271
...MockAuditLog,
22172272
additional_fields: {

0 commit comments

Comments
 (0)