- Notifications
You must be signed in to change notification settings - Fork1k
feat: create e2e tests for IDP org sync settings page#15767
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Merged
Uh oh!
There was an error while loading.Please reload this page.
Merged
Changes fromall commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
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
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,157 @@ | ||
import { expect, test } from "@playwright/test"; | ||
import { | ||
createOrganizationSyncSettings, | ||
createOrganizationWithName, | ||
deleteOrganization, | ||
setupApiCalls, | ||
} from "../../api"; | ||
import { requiresLicense } from "../../helpers"; | ||
import { beforeCoderTest } from "../../hooks"; | ||
test.describe("IdpOrgSyncPage", () => { | ||
test.beforeEach(async ({ page }) => await beforeCoderTest(page)); | ||
test("add new IdP organization mapping with API", async ({ page }) => { | ||
requiresLicense(); | ||
await setupApiCalls(page); | ||
await createOrganizationSyncSettings(); | ||
await page.goto("/deployment/idp-org-sync", { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
await expect( | ||
page.getByRole("switch", { name: "Assign Default Organization" }), | ||
).toBeChecked(); | ||
await expect(page.getByText("idp-org-1")).toBeVisible(); | ||
await expect( | ||
page.getByText("fbd2116a-8961-4954-87ae-e4575bd29ce0").first(), | ||
).toBeVisible(); | ||
await expect(page.getByText("idp-org-2")).toBeVisible(); | ||
await expect( | ||
page.getByText("fbd2116a-8961-4954-87ae-e4575bd29ce0").last(), | ||
).toBeVisible(); | ||
}); | ||
test("delete a IdP org to coder org mapping row", async ({ page }) => { | ||
requiresLicense(); | ||
await setupApiCalls(page); | ||
await createOrganizationSyncSettings(); | ||
await page.goto("/deployment/idp-org-sync", { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
await expect(page.getByText("idp-org-1")).toBeVisible(); | ||
await page | ||
.getByRole("button", { name: /delete/i }) | ||
.first() | ||
.click(); | ||
await expect(page.getByText("idp-org-1")).not.toBeVisible(); | ||
await expect( | ||
page.getByText("Organization sync settings updated."), | ||
).toBeVisible(); | ||
}); | ||
test("update sync field", async ({ page }) => { | ||
requiresLicense(); | ||
await page.goto("/deployment/idp-org-sync", { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
const syncField = page.getByRole("textbox", { | ||
name: "Organization sync field", | ||
}); | ||
const saveButton = page.getByRole("button", { name: "Save" }).first(); | ||
await expect(saveButton).toBeDisabled(); | ||
await syncField.fill("test-field"); | ||
await expect(saveButton).toBeEnabled(); | ||
await page.getByRole("button", { name: "Save" }).click(); | ||
await expect( | ||
page.getByText("Organization sync settings updated."), | ||
).toBeVisible(); | ||
}); | ||
test("toggle default organization assignment", async ({ page }) => { | ||
requiresLicense(); | ||
await page.goto("/deployment/idp-org-sync", { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
const toggle = page.getByRole("switch", { | ||
name: "Assign Default Organization", | ||
}); | ||
await toggle.click(); | ||
await expect( | ||
page.getByText("Organization sync settings updated."), | ||
).toBeVisible(); | ||
await expect(toggle).not.toBeChecked(); | ||
}); | ||
test("export policy button is enabled when sync settings are present", async ({ | ||
page, | ||
}) => { | ||
requiresLicense(); | ||
await setupApiCalls(page); | ||
await page.goto("/deployment/idp-org-sync", { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
const exportButton = page.getByRole("button", { name: /Export Policy/i }); | ||
await createOrganizationSyncSettings(); | ||
await expect(exportButton).toBeEnabled(); | ||
await exportButton.click(); | ||
}); | ||
test("add new IdP organization mapping with UI", async ({ page }) => { | ||
requiresLicense(); | ||
await setupApiCalls(page); | ||
await createOrganizationWithName("developers"); | ||
await page.goto("/deployment/idp-org-sync", { | ||
waitUntil: "domcontentloaded", | ||
}); | ||
const idpOrgInput = page.getByLabel("IdP organization name"); | ||
const orgSelector = page.getByPlaceholder("Select organization"); | ||
const addButton = page.getByRole("button", { | ||
name: /Add IdP organization/i, | ||
}); | ||
await expect(addButton).toBeDisabled(); | ||
await idpOrgInput.fill("new-idp-org"); | ||
// Select Coder organization from combobox | ||
await orgSelector.click(); | ||
await page.getByRole("option", { name: "developers" }).click(); | ||
// Add button should now be enabled | ||
await expect(addButton).toBeEnabled(); | ||
await addButton.click(); | ||
// Verify new mapping appears in table | ||
const newRow = page.getByTestId("idp-org-new-idp-org"); | ||
await expect(newRow).toBeVisible(); | ||
await expect(newRow.getByText("new-idp-org")).toBeVisible(); | ||
await expect(newRow.getByText("developers")).toBeVisible(); | ||
await expect( | ||
page.getByText("Organization sync settings updated."), | ||
).toBeVisible(); | ||
await deleteOrganization("developers"); | ||
}); | ||
}); |
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
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.