Skip to content

Commit 2695f4e

Browse files
chore: improve variable names of mocked users (#17701)
Many times I got confused when using MockUser and MockUser2 so I just decided to better naming them to MockUserOwner and MockUserMember.
1 parent c66e80e commit 2695f4e

File tree

43 files changed

+189
-192
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+189
-192
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,5 @@ result
8282

8383
# dlv debug binaries for go tests
8484
__debug_bin*
85+
86+
**/.claude/settings.local.json

docs/contributing/frontend.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ export const WithQuota: Story = {
131131
parameters: {
132132
queries: [
133133
{
134-
key: getWorkspaceQuotaQueryKey(MockUser.username),
134+
key: getWorkspaceQuotaQueryKey(MockUserOwner.username),
135135
data: {
136136
credits_consumed: 2,
137137
budget: 40,

site/src/components/OrganizationAutocomplete/OrganizationAutocomplete.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { userEvent, within } from "@storybook/test";
44
import {
55
MockOrganization,
66
MockOrganization2,
7-
MockUser,
7+
MockUserOwner,
88
} from "testHelpers/entities";
99
import { OrganizationAutocomplete } from "./OrganizationAutocomplete";
1010

@@ -22,7 +22,7 @@ type Story = StoryObj<typeof OrganizationAutocomplete>;
2222
export const ManyOrgs: Story = {
2323
parameters: {
2424
showOrganizations: true,
25-
user: MockUser,
25+
user: MockUserOwner,
2626
features: ["multiple_organizations"],
2727
permissions: { viewDeploymentConfig: true },
2828
queries: [
@@ -42,7 +42,7 @@ export const ManyOrgs: Story = {
4242
export const OneOrg: Story = {
4343
parameters: {
4444
showOrganizations: true,
45-
user: MockUser,
45+
user: MockUserOwner,
4646
features: ["multiple_organizations"],
4747
permissions: { viewDeploymentConfig: true },
4848
queries: [

site/src/components/UserAutocomplete/UserAutocomplete.stories.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { Meta, StoryObj } from "@storybook/react";
2-
import { MockUser } from "testHelpers/entities";
2+
import { MockUserOwner } from "testHelpers/entities";
33
import { UserAutocomplete } from "./UserAutocomplete";
44

55
const meta: Meta<typeof UserAutocomplete> = {
@@ -12,13 +12,13 @@ type Story = StoryObj<typeof UserAutocomplete>;
1212

1313
export const WithLabel: Story = {
1414
args: {
15-
value: MockUser,
15+
value: MockUserOwner,
1616
label: "User",
1717
},
1818
};
1919

2020
export const NoLabel: Story = {
2121
args: {
22-
value: MockUser,
22+
value: MockUserOwner,
2323
},
2424
};

site/src/contexts/auth/RequireAuth.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useAuthenticated } from "hooks";
33
import { http, HttpResponse } from "msw";
44
import type { FC, PropsWithChildren } from "react";
55
import { QueryClientProvider } from "react-query";
6-
import { MockPermissions, MockUser } from "testHelpers/entities";
6+
import { MockPermissions, MockUserOwner } from "testHelpers/entities";
77
import {
88
createTestQueryClient,
99
renderWithAuth,
@@ -82,7 +82,7 @@ describe("useAuthenticated", () => {
8282

8383
expect(() => {
8484
renderHook(() => useAuthenticated(), {
85-
wrapper: createAuthWrapper({ user: MockUser }),
85+
wrapper: createAuthWrapper({ user: MockUserOwner }),
8686
});
8787
}).toThrow("Permissions are not available.");
8888

@@ -93,7 +93,7 @@ describe("useAuthenticated", () => {
9393
expect(() => {
9494
renderHook(() => useAuthenticated(), {
9595
wrapper: createAuthWrapper({
96-
user: MockUser,
96+
user: MockUserOwner,
9797
permissions: MockPermissions,
9898
}),
9999
});

site/src/hooks/useEmbeddedMetadata.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import {
55
MockBuildInfo,
66
MockEntitlements,
77
MockExperiments,
8-
MockUser,
98
MockUserAppearanceSettings,
9+
MockUserOwner,
1010
} from "testHelpers/entities";
1111
import {
1212
DEFAULT_METADATA_KEY,
@@ -38,7 +38,7 @@ const mockDataForTags = {
3838
"build-info": MockBuildInfo,
3939
entitlements: MockEntitlements,
4040
experiments: MockExperiments,
41-
user: MockUser,
41+
user: MockUserOwner,
4242
userAppearance: MockUserAppearanceSettings,
4343
regions: MockRegions,
4444
} as const satisfies Record<MetadataKey, MetadataValue>;
@@ -97,7 +97,7 @@ const populatedMetadata: RuntimeHtmlMetadata = {
9797
},
9898
user: {
9999
available: true,
100-
value: MockUser,
100+
value: MockUserOwner,
101101
},
102102
userAppearance: {
103103
available: true,

site/src/modules/dashboard/Navbar/MobileMenu.stories.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ import {
66
MockPrimaryWorkspaceProxy,
77
MockProxyLatencies,
88
MockSupportLinks,
9-
MockUser,
10-
MockUser2,
9+
MockUserMember,
10+
MockUserOwner,
1111
MockWorkspaceProxies,
1212
} from "testHelpers/entities";
1313
import { MobileMenu } from "./MobileMenu";
@@ -36,7 +36,7 @@ const meta: Meta<typeof MobileMenu> = {
3636
proxyLatencies: MockProxyLatencies,
3737
proxies: MockWorkspaceProxies,
3838
},
39-
user: MockUser,
39+
user: MockUserOwner,
4040
supportLinks: MockSupportLinks,
4141
onSignOut: fn(),
4242
isDefaultOpen: true,
@@ -63,7 +63,7 @@ export const Admin: Story = {
6363

6464
export const Auditor: Story = {
6565
args: {
66-
user: MockUser2,
66+
user: MockUserMember,
6767
canViewAuditLog: true,
6868
canViewDeployment: false,
6969
canViewHealth: false,
@@ -74,7 +74,7 @@ export const Auditor: Story = {
7474

7575
export const OrgAdmin: Story = {
7676
args: {
77-
user: MockUser2,
77+
user: MockUserMember,
7878
canViewAuditLog: true,
7979
canViewDeployment: false,
8080
canViewHealth: false,
@@ -85,7 +85,7 @@ export const OrgAdmin: Story = {
8585

8686
export const Member: Story = {
8787
args: {
88-
user: MockUser2,
88+
user: MockUserMember,
8989
canViewAuditLog: false,
9090
canViewDeployment: false,
9191
canViewHealth: false,

site/src/modules/dashboard/Navbar/NavbarView.stories.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type { Meta, StoryObj } from "@storybook/react";
22
import { userEvent, within } from "@storybook/test";
33
import { chromaticWithTablet } from "testHelpers/chromatic";
4-
import { MockUser, MockUser2 } from "testHelpers/entities";
4+
import { MockUserMember, MockUserOwner } from "testHelpers/entities";
55
import { withDashboardProvider } from "testHelpers/storybook";
66
import { NavbarView } from "./NavbarView";
77

@@ -10,7 +10,7 @@ const meta: Meta<typeof NavbarView> = {
1010
parameters: { chromatic: chromaticWithTablet, layout: "fullscreen" },
1111
component: NavbarView,
1212
args: {
13-
user: MockUser,
13+
user: MockUserOwner,
1414
canViewAuditLog: true,
1515
canViewDeployment: true,
1616
canViewHealth: true,
@@ -33,7 +33,7 @@ export const ForAdmin: Story = {
3333

3434
export const ForAuditor: Story = {
3535
args: {
36-
user: MockUser2,
36+
user: MockUserMember,
3737
canViewAuditLog: true,
3838
canViewDeployment: false,
3939
canViewHealth: false,
@@ -49,7 +49,7 @@ export const ForAuditor: Story = {
4949

5050
export const ForOrgAdmin: Story = {
5151
args: {
52-
user: MockUser2,
52+
user: MockUserMember,
5353
canViewAuditLog: true,
5454
canViewDeployment: false,
5555
canViewHealth: false,
@@ -65,7 +65,7 @@ export const ForOrgAdmin: Story = {
6565

6666
export const ForMember: Story = {
6767
args: {
68-
user: MockUser2,
68+
user: MockUserMember,
6969
canViewAuditLog: false,
7070
canViewDeployment: false,
7171
canViewHealth: false,

site/src/modules/dashboard/Navbar/NavbarView.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { screen } from "@testing-library/react";
22
import userEvent from "@testing-library/user-event";
33
import type { ProxyContextValue } from "contexts/ProxyContext";
4-
import { MockPrimaryWorkspaceProxy, MockUser } from "testHelpers/entities";
4+
import { MockPrimaryWorkspaceProxy, MockUserOwner } from "testHelpers/entities";
55
import { renderWithAuth } from "testHelpers/renderHelpers";
66
import { NavbarView } from "./NavbarView";
77

@@ -26,7 +26,7 @@ describe("NavbarView", () => {
2626
renderWithAuth(
2727
<NavbarView
2828
proxyContextValue={proxyContextValue}
29-
user={MockUser}
29+
user={MockUserOwner}
3030
onSignOut={noop}
3131
canViewDeployment
3232
canViewOrganizations
@@ -43,7 +43,7 @@ describe("NavbarView", () => {
4343
renderWithAuth(
4444
<NavbarView
4545
proxyContextValue={proxyContextValue}
46-
user={MockUser}
46+
user={MockUserOwner}
4747
onSignOut={noop}
4848
canViewDeployment
4949
canViewOrganizations
@@ -60,7 +60,7 @@ describe("NavbarView", () => {
6060
renderWithAuth(
6161
<NavbarView
6262
proxyContextValue={proxyContextValue}
63-
user={MockUser}
63+
user={MockUserOwner}
6464
onSignOut={noop}
6565
canViewDeployment
6666
canViewOrganizations
@@ -78,7 +78,7 @@ describe("NavbarView", () => {
7878
renderWithAuth(
7979
<NavbarView
8080
proxyContextValue={proxyContextValue}
81-
user={MockUser}
81+
user={MockUserOwner}
8282
onSignOut={noop}
8383
canViewDeployment
8484
canViewOrganizations

site/src/modules/dashboard/Navbar/ProxyMenu.stories.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
MockAuthMethodsAll,
99
MockPermissions,
1010
MockProxyLatencies,
11-
MockUser,
11+
MockUserOwner,
1212
MockWorkspaceProxies,
1313
} from "testHelpers/entities";
1414
import { withDesktopViewport } from "testHelpers/storybook";
@@ -41,7 +41,7 @@ const meta: Meta<typeof ProxyMenu> = {
4141
],
4242
parameters: {
4343
queries: [
44-
{ key: ["me"], data: MockUser },
44+
{ key: ["me"], data: MockUserOwner },
4545
{ key: ["authMethods"], data: MockAuthMethodsAll },
4646
{ key: ["hasFirstUser"], data: true },
4747
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy