Files
alighasami 3d5eaf9445
Security: Sync from Public / sync-from-public (push) Has been cancelled
Test: Benchmark Nightly / build (push) Has been cancelled
Test: Benchmark Nightly / Notify Cats on failure (push) Has been cancelled
CI: Python / Checks (push) Has been cancelled
Test: Evals Python / Workflow Comparison Python (push) Has been cancelled
Util: Check Docs URLs / check-docs-urls (push) Has been cancelled
Test: Visual Storybook / Cloudflare Pages (push) Has been cancelled
Test: E2E Performance / build-and-test-performance (push) Has been cancelled
Test: Workflows Nightly / Run Workflow Tests (push) Has been cancelled
Util: Cleanup CI Docker Images / Delete stale CI images (push) Has been cancelled
Test: Benchmark Destroy Env / build (push) Has been cancelled
Util: Update Node Popularity / update-popularity (push) Has been cancelled
Test: E2E Coverage Weekly / Coverage Tests (push) Has been cancelled
first commit
2026-03-17 16:22:57 +03:30

83 lines
2.3 KiB
TypeScript

import type { Locator } from '@playwright/test';
import { BasePage } from './BasePage';
export class SettingsSsoPage extends BasePage {
async goto(): Promise<void> {
await this.page.goto('/settings/sso');
}
getProtocolSelect(): Locator {
return this.page.getByTestId('sso-auth-protocol-select');
}
async selectOidcProtocol(): Promise<void> {
await this.getProtocolSelect().locator('.el-select').click();
await this.page.locator('.el-select-dropdown__item').filter({ hasText: 'OIDC' }).click();
}
getOidcDiscoveryEndpointInput(): Locator {
return this.page.getByTestId('oidc-discovery-endpoint');
}
getOidcClientIdInput(): Locator {
return this.page.getByTestId('oidc-client-id');
}
getOidcClientSecretInput(): Locator {
return this.page.getByTestId('oidc-client-secret');
}
getOidcLoginToggle(): Locator {
return this.page.getByTestId('sso-oidc-toggle');
}
getOidcSaveButton(): Locator {
return this.page.getByTestId('sso-oidc-save');
}
async isOidcLoginEnabled(): Promise<boolean> {
return await this.getOidcLoginToggle().isChecked();
}
async enableOidcLogin(): Promise<void> {
const isEnabled = await this.isOidcLoginEnabled();
if (!isEnabled) {
await this.getOidcLoginToggle().click();
}
}
/** Fill the OIDC form. Discovery endpoint default value is cleared first. */
async fillOidcForm(config: {
discoveryEndpoint: string;
clientId: string;
clientSecret: string;
enableLogin?: boolean;
}): Promise<void> {
const discoveryInput = this.getOidcDiscoveryEndpointInput();
await discoveryInput.click();
await this.page.keyboard.press('ControlOrMeta+a');
await discoveryInput.pressSequentially(config.discoveryEndpoint, { delay: 10 });
await this.getOidcClientIdInput().fill(config.clientId);
await this.getOidcClientSecretInput().fill(config.clientSecret);
if (config.enableLogin !== false) {
await this.enableOidcLogin();
}
}
/** Save the OIDC configuration and wait for API response. */
async saveOidcConfig(): Promise<void> {
const responsePromise = this.page.waitForResponse(
(res) => res.url().includes('/rest/sso/oidc') && res.request().method() === 'POST',
);
await this.getOidcSaveButton().click();
const response = await responsePromise;
if (!response.ok()) {
const body = await response.text();
throw new Error(`OIDC config save failed: ${response.status()} - ${body}`);
}
}
}