Skip to content

chore: use emotion for styling (pt. 9) #10474

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 28 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
fix storybook!
  • Loading branch information
aslilac committed Nov 2, 2023
commit 9af85c89529276a432f994cc31f97f999595bc03
2 changes: 1 addition & 1 deletion site/src/pages/GroupsPage/GroupsPageView.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ const styles = {
},

"& .MuiTableCell-root:last-child": {
paddingRight: theme.spacing(2),
paddingRight: `${theme.spacing(2)} !important`,
},
}),
arrowRight: (theme) => ({
Expand Down
37 changes: 31 additions & 6 deletions site/src/pages/LoginPage/LoginPageView.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
import { MockAuthMethods, mockApiError } from "testHelpers/entities";
import {
MockAuthMethodsAll,
MockAuthMethodsExternal,
MockAuthMethodsPasswordOnly,
mockApiError,
} from "testHelpers/entities";
import { LoginPageView } from "./LoginPageView";
import type { Meta, StoryObj } from "@storybook/react";

Expand All @@ -12,17 +17,37 @@ type Story = StoryObj<typeof LoginPageView>;

export const Example: Story = {
args: {
authMethods: MockAuthMethods,
authMethods: MockAuthMethodsPasswordOnly,
},
};

export const WithExternalAuthMethods: Story = {
args: {
authMethods: MockAuthMethodsExternal,
},
};

export const WithAllAuthMethods: Story = {
args: {
authMethods: MockAuthMethodsAll,
},
};

export const AuthError: Story = {
args: {
error: mockApiError({
message: "User or password is incorrect",
detail: "Please, try again",
message: "Incorrect email or password.",
}),
authMethods: MockAuthMethodsPasswordOnly,
},
};

export const ExternalAuthError: Story = {
args: {
error: mockApiError({
message: "Incorrect email or password.",
}),
authMethods: MockAuthMethods,
authMethods: MockAuthMethodsAll,
},
};

Expand All @@ -35,6 +60,6 @@ export const LoadingAuthMethods: Story = {
export const SigningIn: Story = {
args: {
isSigningIn: true,
authMethods: MockAuthMethods,
authMethods: MockAuthMethodsPasswordOnly,
},
};
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,7 @@ import {
waitForLoaderToBeRemoved,
} from "testHelpers/renderHelpers";
import { SecurityPage } from "./SecurityPage";
import {
MockAuthMethodsWithPasswordType,
mockApiError,
} from "testHelpers/entities";
import { MockAuthMethodsAll, mockApiError } from "testHelpers/entities";
import userEvent from "@testing-library/user-event";
import * as SSO from "./SingleSignOnSection";
import { OAuthConversionResponse } from "api/typesGenerated";
Expand Down Expand Up @@ -40,9 +37,7 @@ const fillAndSubmitSecurityForm = () => {
};

beforeEach(() => {
jest
.spyOn(API, "getAuthMethods")
.mockResolvedValue(MockAuthMethodsWithPasswordType);
jest.spyOn(API, "getAuthMethods").mockResolvedValue(MockAuthMethodsAll);
jest.spyOn(API, "getUserLoginType").mockResolvedValue({
login_type: "password",
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { Meta, StoryObj } from "@storybook/react";
import { SecurityPageView } from "./SecurityPage";
import { action } from "@storybook/addon-actions";
import {
MockAuthMethods,
MockAuthMethodsWithPasswordType,
MockAuthMethodsPasswordOnly,
MockAuthMethodsAll,
} from "testHelpers/entities";
import { ComponentProps } from "react";
import set from "lodash/fp/set";
Expand All @@ -22,7 +22,7 @@ const defaultArgs: ComponentProps<typeof SecurityPageView> = {
userLoginType: {
login_type: "password",
},
authMethods: MockAuthMethods,
authMethods: MockAuthMethodsPasswordOnly,
closeConfirmation: action("closeConfirmation"),
confirm: action("confirm"),
error: undefined,
Expand Down Expand Up @@ -52,19 +52,15 @@ export const NoOIDCAvailable: Story = {
};

export const UserLoginTypeIsPassword: Story = {
args: set(
"oidc.section.authMethods",
MockAuthMethodsWithPasswordType,
defaultArgs,
),
args: set("oidc.section.authMethods", MockAuthMethodsAll, defaultArgs),
};

export const ConfirmingOIDCConversion: Story = {
args: set(
"oidc.section",
{
...defaultArgs.oidc?.section,
authMethods: MockAuthMethodsWithPasswordType,
authMethods: MockAuthMethodsAll,
isConfirming: true,
},
defaultArgs,
Expand Down
4 changes: 2 additions & 2 deletions site/src/pages/UsersPage/UsersPageView.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
MockUser2,
MockAssignableSiteRoles,
mockApiError,
MockAuthMethods,
MockAuthMethodsPasswordOnly,
} from "testHelpers/entities";
import { UsersPageView } from "./UsersPageView";
import { ComponentProps } from "react";
Expand Down Expand Up @@ -37,7 +37,7 @@ const meta: Meta<typeof UsersPageView> = {
count: 2,
canEditUsers: true,
filterProps: defaultFilterProps,
authMethods: MockAuthMethods,
authMethods: MockAuthMethodsPasswordOnly,
},
};

Expand Down
4 changes: 2 additions & 2 deletions site/src/pages/UsersPage/UsersTable/UsersTable.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import {
MockUser,
MockUser2,
MockAssignableSiteRoles,
MockAuthMethods,
MockAuthMethodsPasswordOnly,
MockGroup,
} from "testHelpers/entities";
import { UsersTable } from "./UsersTable";
Expand All @@ -18,7 +18,7 @@ const meta: Meta<typeof UsersTable> = {
component: UsersTable,
args: {
isNonInitialPage: false,
authMethods: MockAuthMethods,
authMethods: MockAuthMethodsPasswordOnly,
},
};

Expand Down
22 changes: 18 additions & 4 deletions site/src/testHelpers/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1254,16 +1254,30 @@ export const MockUserAgent = {
os: "Windows 10",
};

export const MockAuthMethods: TypesGen.AuthMethods = {
export const MockAuthMethodsPasswordOnly: TypesGen.AuthMethods = {
password: { enabled: true },
github: { enabled: false },
oidc: { enabled: false, signInText: "", iconUrl: "" },
};

export const MockAuthMethodsWithPasswordType: TypesGen.AuthMethods = {
...MockAuthMethods,
export const MockAuthMethodsExternal: TypesGen.AuthMethods = {
password: { enabled: false },
github: { enabled: true },
oidc: { enabled: true, signInText: "", iconUrl: "" },
oidc: {
enabled: true,
signInText: "Google",
iconUrl: "/icon/google.svg",
},
};

export const MockAuthMethodsAll: TypesGen.AuthMethods = {
password: { enabled: true },
github: { enabled: true },
oidc: {
enabled: true,
signInText: "Google",
iconUrl: "/icon/google.svg",
},
};

export const MockGitSSHKey: TypesGen.GitSSHKey = {
Expand Down
2 changes: 1 addition & 1 deletion site/src/testHelpers/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ export const handlers = [
return res(ctx.status(200), ctx.json(M.MockAPIKey));
}),
rest.get("/api/v2/users/authmethods", async (req, res, ctx) => {
return res(ctx.status(200), ctx.json(M.MockAuthMethods));
return res(ctx.status(200), ctx.json(M.MockAuthMethodsPasswordOnly));
}),
rest.get("/api/v2/users/roles", async (req, res, ctx) => {
return res(ctx.status(200), ctx.json(M.MockSiteRoles));
Expand Down