-
Notifications
You must be signed in to change notification settings - Fork 887
chore(site): refactor stories and test from page components #9603
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
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
52fae61
Refactor AuditPage
BrunoQuaresma cc2a549
Refactor CliAuthPageView stories
BrunoQuaresma 4f7bb53
Refactor CreateTemplateForm stories
BrunoQuaresma cd5b40f
Refactor CreateUserPage test
BrunoQuaresma c5b4eb5
Refactor CreateWorkspacePage tests
BrunoQuaresma 6121f0d
Fix stories name
BrunoQuaresma a5440cb
Refactor AppereancePageView stories
BrunoQuaresma 4b3d9f8
Refactor GitAuthSettingsPageView stories
BrunoQuaresma 8f654b6
Refactor NetworkSettingsPageView stories
BrunoQuaresma 1618d36
Refactor SecuritySettingsPageView stories
BrunoQuaresma 64ee732
Refactor UserAuthSettingsPageView stories
BrunoQuaresma 1e40624
Refactor GroupsPage stories
BrunoQuaresma 974bb3f
Refactor LoginPage tests
BrunoQuaresma 30a783a
Refactor SetupPage stories
BrunoQuaresma 5e5e35c
Refactor StarterTemplatePageView stories
BrunoQuaresma 429b823
Refactor StarterTemplatesPage tests
BrunoQuaresma 5dd69e9
Refactor TemplatePage tests
BrunoQuaresma d5532f0
RefactorTemplateSettingsPage tests
BrunoQuaresma d6444c9
Refactor TemplatesPage tests
BrunoQuaresma 08adf24
Flat TemplateVersionEditorPage
BrunoQuaresma d40214a
Refactor TemplateVersionPage stories
BrunoQuaresma 5a8b649
Refactor UserSettingsPage stories
BrunoQuaresma 2d1e6bf
Refactor UsersPage stories
BrunoQuaresma 30ad92b
Simplify IndexPage
BrunoQuaresma 5c64496
Refactor WorkspaceSettingsPage stories
BrunoQuaresma 5d8bcde
Refactor WorkspacePage stories
BrunoQuaresma 7f0e89e
Refactor Conditionals stories
BrunoQuaresma b5d365b
Fix typo
BrunoQuaresma 2f55e6b
Fix imports
BrunoQuaresma b3114d6
Fix ChooseOne story
BrunoQuaresma 397370c
Fix UserAuthSettingsPageView stories
BrunoQuaresma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,71 @@ | ||
import { Story } from "@storybook/react"; | ||
import { Meta, StoryObj } from "@storybook/react"; | ||
import { ChooseOne, Cond } from "./ChooseOne"; | ||
|
||
export default { | ||
const meta: Meta<typeof ChooseOne> = { | ||
title: "components/Conditionals/ChooseOne", | ||
component: ChooseOne, | ||
subcomponents: { Cond }, | ||
}; | ||
|
||
export const FirstIsTrue: Story = () => ( | ||
<ChooseOne> | ||
<Cond condition>The first one shows.</Cond> | ||
<Cond condition={false}>The second one does not show.</Cond> | ||
<Cond>The default does not show.</Cond> | ||
</ChooseOne> | ||
); | ||
export default meta; | ||
type Story = StoryObj<typeof ChooseOne>; | ||
|
||
export const SecondIsTrue: Story = () => ( | ||
<ChooseOne> | ||
<Cond condition={false}>The first one does not show.</Cond> | ||
<Cond condition>The second one shows.</Cond> | ||
<Cond>The default does not show.</Cond> | ||
</ChooseOne> | ||
); | ||
export const FirstIsTrue: Story = { | ||
args: { | ||
children: [ | ||
<Cond key="1" condition> | ||
The first one shows. | ||
</Cond>, | ||
<Cond key="2" condition={false}> | ||
The second one does not show. | ||
</Cond>, | ||
<Cond key="3">The default does not show.</Cond>, | ||
], | ||
}, | ||
}; | ||
|
||
export const AllAreTrue: Story = () => ( | ||
<ChooseOne> | ||
<Cond condition>Only the first one shows.</Cond> | ||
<Cond condition>The second one does not show.</Cond> | ||
<Cond>The default does not show.</Cond> | ||
</ChooseOne> | ||
); | ||
export const SecondIsTrue: Story = { | ||
args: { | ||
children: [ | ||
<Cond key="1" condition={false}> | ||
The first one does not show. | ||
</Cond>, | ||
<Cond key="2" condition> | ||
The second one shows. | ||
</Cond>, | ||
<Cond key="3">The default does not show.</Cond>, | ||
], | ||
}, | ||
}; | ||
export const AllAreTrue: Story = { | ||
args: { | ||
children: [ | ||
<Cond key="1" condition> | ||
Only the first one shows. | ||
</Cond>, | ||
<Cond key="2" condition> | ||
The second one does not show. | ||
</Cond>, | ||
<Cond key="3">The default does not show.</Cond>, | ||
], | ||
}, | ||
}; | ||
|
||
export const NoneAreTrue: Story = () => ( | ||
<ChooseOne> | ||
<Cond condition={false}>The first one does not show.</Cond> | ||
<Cond condition={false}>The second one does not show.</Cond> | ||
<Cond>The default shows.</Cond> | ||
</ChooseOne> | ||
); | ||
export const NoneAreTrue: Story = { | ||
args: { | ||
children: [ | ||
<Cond key="1" condition={false}> | ||
The first one does not show. | ||
</Cond>, | ||
<Cond key="2" condition={false}> | ||
The second one does not show. | ||
</Cond>, | ||
<Cond key="3">The default shows.</Cond>, | ||
], | ||
}, | ||
}; | ||
|
||
export const OneCond: Story = () => ( | ||
<ChooseOne> | ||
<Cond>An only child renders.</Cond> | ||
</ChooseOne> | ||
); | ||
export const OneCond: Story = { | ||
args: { | ||
children: <Cond>An only child renders.</Cond>, | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,25 @@ | ||
import { Story } from "@storybook/react"; | ||
import { Maybe, MaybeProps } from "./Maybe"; | ||
import { StoryObj, Meta } from "@storybook/react"; | ||
import { Maybe } from "./Maybe"; | ||
|
||
export default { | ||
const meta: Meta<typeof Maybe> = { | ||
title: "components/Conditionals/Maybe", | ||
component: Maybe, | ||
args: { | ||
children: "Now you see me", | ||
}, | ||
}; | ||
|
||
const Template: Story<MaybeProps> = (args: MaybeProps) => ( | ||
<Maybe {...args}>Now you see me</Maybe> | ||
); | ||
export default meta; | ||
type Story = StoryObj<typeof Maybe>; | ||
|
||
export const ConditionIsTrue = Template.bind({}); | ||
ConditionIsTrue.args = { | ||
condition: true, | ||
export const ConditionIsTrue: Story = { | ||
args: { | ||
condition: true, | ||
}, | ||
}; | ||
|
||
export const ConditionIsFalse = Template.bind({}); | ||
ConditionIsFalse.args = { | ||
condition: false, | ||
export const ConditionIsFalse: Story = { | ||
args: { | ||
condition: false, | ||
}, | ||
}; |
58 changes: 58 additions & 0 deletions
58
site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.stories.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { Meta, StoryObj } from "@storybook/react"; | ||
import { AuditLogDescription } from "./AuditLogDescription"; | ||
import { | ||
MockAuditLog, | ||
MockAuditLogSuccessfulLogin, | ||
MockAuditLogUnsuccessfulLoginKnownUser, | ||
MockAuditLogWithWorkspaceBuild, | ||
MockWorkspaceCreateAuditLogForDifferentOwner, | ||
} from "testHelpers/entities"; | ||
|
||
const meta: Meta<typeof AuditLogDescription> = { | ||
title: "components/AuditLogDescription", | ||
component: AuditLogDescription, | ||
}; | ||
|
||
export default meta; | ||
type Story = StoryObj<typeof AuditLogDescription>; | ||
|
||
export const WorkspaceCreate: Story = { | ||
args: { | ||
auditLog: MockAuditLog, | ||
}, | ||
}; | ||
|
||
export const WorkspaceBuildStop: Story = { | ||
args: { | ||
auditLog: MockAuditLogWithWorkspaceBuild, | ||
}, | ||
}; | ||
|
||
export const WorkspaceBuildDuplicatedWord: Story = { | ||
args: { | ||
auditLog: { | ||
...MockAuditLogWithWorkspaceBuild, | ||
additional_fields: { | ||
workspace_name: "workspace", | ||
}, | ||
}, | ||
}, | ||
}; | ||
|
||
export const CreateWorkspaceWithDiffOwner: Story = { | ||
args: { | ||
auditLog: MockWorkspaceCreateAuditLogForDifferentOwner, | ||
}, | ||
}; | ||
|
||
export const SuccessLogin: Story = { | ||
args: { | ||
auditLog: MockAuditLogSuccessfulLogin, | ||
}, | ||
}; | ||
|
||
export const UnsuccessfulLoginForUnknownUser: Story = { | ||
args: { | ||
auditLog: MockAuditLogUnsuccessfulLoginKnownUser, | ||
}, | ||
}; |
106 changes: 0 additions & 106 deletions
106
site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/AuditLogDescription.test.tsx
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
site/src/pages/AuditPage/AuditLogRow/AuditLogDescription/index.ts
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I liked the earlier commit where these were fragments: React will perform better with those. Does it break the
ChooseOne
component or something?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nops, it is just for the storybook. I didnt find a similar API to keep it as a fragment in the new Storybook v7 API