Skip to content

Commit 37b84eb

Browse files
committed
fix storybook
1 parent bb70b9a commit 37b84eb

File tree

1 file changed

+65
-0
lines changed

1 file changed

+65
-0
lines changed

site/src/pages/CreateTemplatePage/CreateTemplateForm.stories.tsx

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,40 @@ export const StarterTemplateWithOrgPicker: Story = {
6161
},
6262
};
6363

64+
const canCreateTemplate = (organizationId: string) => {
65+
return {
66+
[organizationId]: {
67+
object: {
68+
resource_type: "template",
69+
organization_id: organizationId,
70+
},
71+
action: "create",
72+
},
73+
};
74+
};
75+
6476
export const StarterTemplateWithProvisionerWarning: Story = {
6577
parameters: {
6678
queries: [
6779
{
6880
key: organizationsKey,
6981
data: [MockDefaultOrganization, MockOrganization2],
7082
},
83+
{
84+
key: [
85+
"authorization",
86+
{
87+
checks: {
88+
...canCreateTemplate(MockDefaultOrganization.id),
89+
...canCreateTemplate(MockOrganization2.id),
90+
},
91+
},
92+
],
93+
data: {
94+
[MockDefaultOrganization.id]: true,
95+
[MockOrganization2.id]: true,
96+
},
97+
},
7198
{
7299
key: getProvisionerDaemonsKey(MockOrganization2.id),
73100
data: [],
@@ -86,6 +113,44 @@ export const StarterTemplateWithProvisionerWarning: Story = {
86113
},
87114
};
88115

116+
export const StarterTemplatePermissionsCheck: Story = {
117+
parameters: {
118+
queries: [
119+
{
120+
key: organizationsKey,
121+
data: [MockDefaultOrganization, MockOrganization2],
122+
},
123+
{
124+
key: [
125+
"authorization",
126+
{
127+
checks: {
128+
...canCreateTemplate(MockDefaultOrganization.id),
129+
...canCreateTemplate(MockOrganization2.id),
130+
},
131+
},
132+
],
133+
data: {
134+
[MockDefaultOrganization.id]: true,
135+
[MockOrganization2.id]: false,
136+
},
137+
},
138+
{
139+
key: getProvisionerDaemonsKey(MockOrganization2.id),
140+
data: [],
141+
},
142+
],
143+
},
144+
args: {
145+
...StarterTemplate.args,
146+
showOrganizationPicker: true,
147+
},
148+
play: async () => {
149+
const organizationPicker = screen.getByPlaceholderText("Organization name");
150+
await userEvent.click(organizationPicker);
151+
},
152+
};
153+
89154
export const DuplicateTemplateWithVariables: Story = {
90155
args: {
91156
copiedTemplate: MockTemplate,

0 commit comments

Comments
 (0)