Skip to content

Commit c425a19

Browse files
committed
org aware createTemplate step
1 parent c7a6ddb commit c425a19

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

site/e2e/helpers.ts

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ function isStarterTemplate(
190190
export const createTemplate = async (
191191
page: Page,
192192
responses?: EchoProvisionerResponses | StarterTemplates,
193+
organizationName: string = "coder",
193194
): Promise<string> => {
194195
let path = "/templates/new";
195196
if (isStarterTemplate(responses)) {
@@ -210,12 +211,26 @@ export const createTemplate = async (
210211
});
211212
}
212213

214+
// If the organization picker is present on the page, select the default
215+
// organization.
216+
const orgPicker = page.getByLabel("Belongs to *");
217+
const organizationsEnabled = await orgPicker.isVisible();
218+
if (organizationsEnabled) {
219+
await orgPicker.click();
220+
await page.getByText(organizationName, { exact: true }).click();
221+
}
222+
213223
const name = randomName();
214224
await page.getByLabel("Name *").fill(name);
215225
await page.getByTestId("form-submit").click();
216-
await expectUrl(page).toHavePathName(`/templates/${name}/files`, {
217-
timeout: 30000,
218-
});
226+
await expectUrl(page).toHavePathName(
227+
organizationsEnabled
228+
? `/templates/${organizationName}/${name}/files`
229+
: `/templates/${name}/files`,
230+
{
231+
timeout: 30000,
232+
},
233+
);
219234
return name;
220235
};
221236

0 commit comments

Comments
 (0)