Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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
jaaydenh merged 3 commits intomainfromjaaydenh/idp-org-sync-settings-e2e-tests
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionsite/e2e/README.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -55,7 +55,7 @@ code .
Enterprise tests require a license key to run.

```shell
exportCODER_E2E_ENTERPRISE_LICENSE=<license key>
exportCODER_E2E_LICENSE=<license key>
```

#Debugging tests
Expand Down
29 changes: 29 additions & 0 deletionssite/e2e/api.ts
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -63,6 +63,35 @@ export const createOrganization = async () => {
returnorg;
};

exportconstdeleteOrganization=async(orgName:string)=>{
awaitAPI.deleteOrganization(orgName);
};

exportconstcreateOrganizationWithName=async(name:string)=>{
constorg=awaitAPI.createOrganization({
name,
display_name:`${name}`,
description:`Org description${name}`,
icon:"/emojis/1f957.png",
});
returnorg;
};

exportconstcreateOrganizationSyncSettings=async()=>{
constsettings=awaitAPI.patchOrganizationIdpSyncSettings({
field:"organization-field-test",
mapping:{
"idp-org-1":[
"fbd2116a-8961-4954-87ae-e4575bd29ce0",
"13de3eb4-9b4f-49e7-b0f8-0c3728a0d2e2",
],
"idp-org-2":["fbd2116a-8961-4954-87ae-e4575bd29ce0"],
},
organization_assign_default:true,
});
returnsettings;
};

exportasyncfunctionverifyConfigFlagBoolean(
page:Page,
config:DeploymentConfig,
Expand Down
157 changes: 157 additions & 0 deletionssite/e2e/tests/deployment/idpOrgSync.spec.ts
View file
Open in desktop
Original file line numberDiff line numberDiff 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})=>awaitbeforeCoderTest(page));

test("add new IdP organization mapping with API",async({ page})=>{
requiresLicense();
awaitsetupApiCalls(page);

awaitcreateOrganizationSyncSettings();

awaitpage.goto("/deployment/idp-org-sync",{
waitUntil:"domcontentloaded",
});

awaitexpect(
page.getByRole("switch",{name:"Assign Default Organization"}),
).toBeChecked();

awaitexpect(page.getByText("idp-org-1")).toBeVisible();
awaitexpect(
page.getByText("fbd2116a-8961-4954-87ae-e4575bd29ce0").first(),
).toBeVisible();

awaitexpect(page.getByText("idp-org-2")).toBeVisible();
awaitexpect(
page.getByText("fbd2116a-8961-4954-87ae-e4575bd29ce0").last(),
).toBeVisible();
});

test("delete a IdP org to coder org mapping row",async({ page})=>{
requiresLicense();
awaitsetupApiCalls(page);
awaitcreateOrganizationSyncSettings();
awaitpage.goto("/deployment/idp-org-sync",{
waitUntil:"domcontentloaded",
});

awaitexpect(page.getByText("idp-org-1")).toBeVisible();
awaitpage
.getByRole("button",{name:/delete/i})
.first()
.click();
awaitexpect(page.getByText("idp-org-1")).not.toBeVisible();
awaitexpect(
page.getByText("Organization sync settings updated."),
).toBeVisible();
});

test("update sync field",async({ page})=>{
requiresLicense();
awaitpage.goto("/deployment/idp-org-sync",{
waitUntil:"domcontentloaded",
});

constsyncField=page.getByRole("textbox",{
name:"Organization sync field",
});
constsaveButton=page.getByRole("button",{name:"Save"}).first();

awaitexpect(saveButton).toBeDisabled();

awaitsyncField.fill("test-field");
awaitexpect(saveButton).toBeEnabled();

awaitpage.getByRole("button",{name:"Save"}).click();

awaitexpect(
page.getByText("Organization sync settings updated."),
).toBeVisible();
});

test("toggle default organization assignment",async({ page})=>{
requiresLicense();
awaitpage.goto("/deployment/idp-org-sync",{
waitUntil:"domcontentloaded",
});

consttoggle=page.getByRole("switch",{
name:"Assign Default Organization",
});
awaittoggle.click();

awaitexpect(
page.getByText("Organization sync settings updated."),
).toBeVisible();

awaitexpect(toggle).not.toBeChecked();
});

test("export policy button is enabled when sync settings are present",async({
page,
})=>{
requiresLicense();
awaitsetupApiCalls(page);

awaitpage.goto("/deployment/idp-org-sync",{
waitUntil:"domcontentloaded",
});

constexportButton=page.getByRole("button",{name:/ExportPolicy/i});
awaitcreateOrganizationSyncSettings();

awaitexpect(exportButton).toBeEnabled();
awaitexportButton.click();
});

test("add new IdP organization mapping with UI",async({ page})=>{
requiresLicense();
awaitsetupApiCalls(page);

awaitcreateOrganizationWithName("developers");

awaitpage.goto("/deployment/idp-org-sync",{
waitUntil:"domcontentloaded",
});

constidpOrgInput=page.getByLabel("IdP organization name");
constorgSelector=page.getByPlaceholder("Select organization");
constaddButton=page.getByRole("button",{
name:/AddIdPorganization/i,
});

awaitexpect(addButton).toBeDisabled();

awaitidpOrgInput.fill("new-idp-org");

// Select Coder organization from combobox
awaitorgSelector.click();
awaitpage.getByRole("option",{name:"developers"}).click();

// Add button should now be enabled
awaitexpect(addButton).toBeEnabled();

awaitaddButton.click();

// Verify new mapping appears in table
constnewRow=page.getByTestId("idp-org-new-idp-org");
awaitexpect(newRow).toBeVisible();
awaitexpect(newRow.getByText("new-idp-org")).toBeVisible();
awaitexpect(newRow.getByText("developers")).toBeVisible();

awaitexpect(
page.getByText("Organization sync settings updated."),
).toBeVisible();

awaitdeleteOrganization("developers");
});
});
Loading

[8]ページ先頭

©2009-2025 Movatter.jp