-
Notifications
You must be signed in to change notification settings - Fork 875
feat: enable editing of IDP sync configuration for groups and roles in the UI #16098
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
Changes from all commits
96b0c09
a88b72f
cb00c73
4b15a2a
0befeca
f8349de
7124c11
30c8a9c
a7c954b
c09a3f3
8714f5e
b558f35
aa0e53c
7635856
91ca380
328ce2f
52d563c
b1d7649
b3812f1
d19a0dc
43159ff
528f2d8
d283fa1
ad2fc45
c99e009
31cd599
2354883
3c63c8c
623a50e
5779c8d
395fdc8
79ce400
854684a
50c12db
16665e2
3dbcee3
9b709ae
bee5783
d3b64b2
0362c16
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
jaaydenh marked this conversation as resolved.
Show resolved
Hide resolved
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,184 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { | ||
createGroupSyncSettings, | ||
createOrganizationWithName, | ||
deleteOrganization, | ||
setupApiCalls, | ||
} from "../../api"; | ||
import { randomName, requiresLicense } from "../../helpers"; | ||
import { login } from "../../helpers"; | ||
import { beforeCoderTest } from "../../hooks"; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
beforeCoderTest(page); | ||
await login(page); | ||
await setupApiCalls(page); | ||
}); | ||
|
||
test.describe("IdpGroupSyncPage", () => { | ||
test("show empty table when no group mappings are present", async ({ | ||
page, | ||
}) => { | ||
requiresLicense(); | ||
const org = await createOrganizationWithName(randomName()); | ||
await page.goto(`/organizations/${org.name}/idp-sync?tab=groups`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
|
||
await expect( | ||
page.getByRole("row", { name: "idp-group-1" }), | ||
).not.toBeVisible(); | ||
await expect( | ||
page.getByRole("heading", { name: "No group mappings" }), | ||
).toBeVisible(); | ||
|
||
await deleteOrganization(org.name); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm asking because I haven't had much chance to touch Playwright yet, and don't know what it does for test setup: is I'm mainly wondering why the call is present for the first two tests as (what looks like) a cleanup step, but some of the later, non-deletion tests in this file don't have it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm also not sure if Playwright supports any "true concurrency", rather than doing everything through the event loop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I originally added this to fix some test failures across tests that were creating organizations. From the documentation and my testing, it does appear tests are run in parallel. The intention was to add this cleanup step anytime an org is created to avoid test flakes in the future. |
||
}); | ||
|
||
test("add new IdP group mapping with API", async ({ page }) => { | ||
requiresLicense(); | ||
const org = await createOrganizationWithName(randomName()); | ||
await createGroupSyncSettings(org.id); | ||
|
||
await page.goto(`/organizations/${org.name}/idp-sync?tab=groups`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
|
||
await expect( | ||
page.getByRole("switch", { name: "Auto create missing groups" }), | ||
).toBeChecked(); | ||
|
||
await expect(page.getByRole("row", { name: "idp-group-1" })).toBeVisible(); | ||
await expect( | ||
page.getByRole("row", { name: "fbd2116a-8961-4954-87ae-e4575bd29ce0" }), | ||
).toBeVisible(); | ||
|
||
await expect(page.getByRole("row", { name: "idp-group-2" })).toBeVisible(); | ||
await expect( | ||
page.getByRole("row", { name: "6b39f0f1-6ad8-4981-b2fc-d52aef53ff1b" }), | ||
).toBeVisible(); | ||
|
||
await deleteOrganization(org.name); | ||
}); | ||
|
||
test("delete a IdP group to coder group mapping row", async ({ page }) => { | ||
requiresLicense(); | ||
const org = await createOrganizationWithName(randomName()); | ||
await createGroupSyncSettings(org.id); | ||
|
||
await page.goto(`/organizations/${org.name}/idp-sync?tab=groups`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
|
||
const row = page.getByTestId("group-idp-group-1"); | ||
await expect(row.getByRole("cell", { name: "idp-group-1" })).toBeVisible(); | ||
await row.getByRole("button", { name: /delete/i }).click(); | ||
await expect( | ||
row.getByRole("cell", { name: "idp-group-1" }), | ||
).not.toBeVisible(); | ||
await expect( | ||
page.getByText("IdP Group sync settings updated."), | ||
).toBeVisible(); | ||
}); | ||
|
||
test("update sync field", async ({ page }) => { | ||
requiresLicense(); | ||
const org = await createOrganizationWithName(randomName()); | ||
await page.goto(`/organizations/${org.name}/idp-sync?tab=groups`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
|
||
const syncField = page.getByRole("textbox", { | ||
name: "Group sync field", | ||
}); | ||
const saveButton = page.getByRole("button", { name: /save/i }); | ||
|
||
await expect(saveButton).toBeDisabled(); | ||
|
||
await syncField.fill("test-field"); | ||
await expect(saveButton).toBeEnabled(); | ||
|
||
await page.getByRole("button", { name: /save/i }).click(); | ||
|
||
await expect( | ||
page.getByText("IdP Group sync settings updated."), | ||
).toBeVisible(); | ||
}); | ||
|
||
test("toggle off auto create missing groups", async ({ page }) => { | ||
requiresLicense(); | ||
const org = await createOrganizationWithName(randomName()); | ||
await page.goto(`/organizations/${org.name}/idp-sync?tab=groups`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
|
||
const toggle = page.getByRole("switch", { | ||
name: "Auto create missing groups", | ||
}); | ||
await toggle.click(); | ||
|
||
await expect( | ||
page.getByText("IdP Group sync settings updated."), | ||
).toBeVisible(); | ||
|
||
await expect(toggle).toBeChecked(); | ||
}); | ||
|
||
test("export policy button is enabled when sync settings are present", async ({ | ||
page, | ||
}) => { | ||
requiresLicense(); | ||
const org = await createOrganizationWithName(randomName()); | ||
await createGroupSyncSettings(org.id); | ||
await page.goto(`/organizations/${org.name}/idp-sync?tab=groups`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
|
||
const exportButton = page.getByRole("button", { name: /Export Policy/i }); | ||
await expect(exportButton).toBeEnabled(); | ||
await exportButton.click(); | ||
}); | ||
|
||
test("add new IdP group mapping with UI", async ({ page }) => { | ||
requiresLicense(); | ||
const orgName = randomName(); | ||
await createOrganizationWithName(orgName); | ||
|
||
await page.goto(`/organizations/${orgName}/idp-sync?tab=groups`, { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
|
||
const idpOrgInput = page.getByLabel("IdP group name"); | ||
const orgSelector = page.getByPlaceholder("Select group"); | ||
const addButton = page.getByRole("button", { | ||
name: /Add IdP group/i, | ||
}); | ||
|
||
await expect(addButton).toBeDisabled(); | ||
|
||
await idpOrgInput.fill("new-idp-group"); | ||
|
||
// Select Coder organization from combobox | ||
await orgSelector.click(); | ||
await page.getByRole("option", { name: /Everyone/i }).click(); | ||
|
||
// Add button should now be enabled | ||
await expect(addButton).toBeEnabled(); | ||
|
||
await addButton.click(); | ||
|
||
// Verify new mapping appears in table | ||
const newRow = page.getByTestId("group-new-idp-group"); | ||
await expect(newRow).toBeVisible(); | ||
await expect( | ||
newRow.getByRole("cell", { name: "new-idp-group" }), | ||
).toBeVisible(); | ||
await expect(newRow.getByRole("cell", { name: "Everyone" })).toBeVisible(); | ||
|
||
await expect( | ||
page.getByText("IdP Group sync settings updated."), | ||
).toBeVisible(); | ||
|
||
await deleteOrganization(orgName); | ||
}); | ||
}); |
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.
Do we need a test ID selector here? I'm not sure why the row selectors wouldn't work here, but would still work for other test cases