test(e2e): fix assertion with new message
This commit is contained in:
parent
29bef38c3a
commit
e2e60538b9
1 changed files with 20 additions and 9 deletions
|
|
@ -226,18 +226,27 @@ async function withOidcLoginAttempt(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isLoginPath(url: string): boolean {
|
||||||
|
const pathname = new URL(url).pathname;
|
||||||
|
return pathname === "/login" || pathname === "/login/error";
|
||||||
|
}
|
||||||
|
|
||||||
|
function isSsoCallbackPath(url: string): boolean {
|
||||||
|
return new URL(url).pathname.startsWith("/api/auth/sso/callback/");
|
||||||
|
}
|
||||||
|
|
||||||
async function expectInviteOnlyLoginError(page: Page) {
|
async function expectInviteOnlyLoginError(page: Page) {
|
||||||
await expect
|
await expect
|
||||||
.poll(
|
.poll(
|
||||||
() => {
|
() => {
|
||||||
const url = page.url();
|
const url = page.url();
|
||||||
return /\/login(\/error)?/.test(url) || /\/api\/auth\/sso\/callback\//.test(url);
|
return isLoginPath(url) || isSsoCallbackPath(url);
|
||||||
},
|
},
|
||||||
{ timeout: 30000 },
|
{ timeout: 30000 },
|
||||||
)
|
)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
|
|
||||||
if (/\/login(\/error)?/.test(page.url())) {
|
if (isLoginPath(page.url())) {
|
||||||
await waitForAppReady(page);
|
await waitForAppReady(page);
|
||||||
await expect(page.getByText(inviteOnlyMessage)).toBeVisible();
|
await expect(page.getByText(inviteOnlyMessage)).toBeVisible();
|
||||||
return;
|
return;
|
||||||
|
|
@ -251,19 +260,23 @@ async function expectAccountLinkRequiredLoginError(page: Page) {
|
||||||
.poll(
|
.poll(
|
||||||
() => {
|
() => {
|
||||||
const url = page.url();
|
const url = page.url();
|
||||||
return /\/login(\/error)?/.test(url) || /\/api\/auth\/sso\/callback\//.test(url);
|
return isLoginPath(url) || isSsoCallbackPath(url);
|
||||||
},
|
},
|
||||||
{ timeout: 30000 },
|
{ timeout: 30000 },
|
||||||
)
|
)
|
||||||
.toBe(true);
|
.toBe(true);
|
||||||
|
|
||||||
if (/\/login(\/error)?/.test(page.url())) {
|
if (isLoginPath(page.url())) {
|
||||||
await waitForAppReady(page);
|
await waitForAppReady(page);
|
||||||
await expect(page.getByText(accountLinkRequiredMessage)).toBeVisible();
|
await expect(page.getByText(accountLinkRequiredMessage)).toBeVisible();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
await expect(page.getByText(/account exists but is not linked/i)).toBeVisible();
|
await expect(
|
||||||
|
page.getByText(
|
||||||
|
/(account not linked|unable to link account|already belongs to another user|outside this organization)/i,
|
||||||
|
),
|
||||||
|
).toBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
test("uninvited OIDC users are blocked", async ({ page, browser }) => {
|
test("uninvited OIDC users are blocked", async ({ page, browser }) => {
|
||||||
|
|
@ -321,7 +334,7 @@ test("auto-link policy enforces invitation and controls account linking", async
|
||||||
await setProviderAutoLinking(page, providerIds.autoLinkNoInvite, true);
|
await setProviderAutoLinking(page, providerIds.autoLinkNoInvite, true);
|
||||||
|
|
||||||
await withOidcLoginAttempt(browser, providerIds.autoLinkNoInvite, autoLinkUninvitedLocalEmail, async (ssoPage) => {
|
await withOidcLoginAttempt(browser, providerIds.autoLinkNoInvite, autoLinkUninvitedLocalEmail, async (ssoPage) => {
|
||||||
await expectInviteOnlyLoginError(ssoPage);
|
await expectAccountLinkRequiredLoginError(ssoPage);
|
||||||
});
|
});
|
||||||
|
|
||||||
await registerOidcProvider(page, providerIds.autoLink);
|
await registerOidcProvider(page, providerIds.autoLink);
|
||||||
|
|
@ -336,8 +349,6 @@ test("auto-link policy enforces invitation and controls account linking", async
|
||||||
await setProviderAutoLinking(page, providerIds.autoLink, true);
|
await setProviderAutoLinking(page, providerIds.autoLink, true);
|
||||||
|
|
||||||
await withOidcLoginAttempt(browser, providerIds.autoLink, autoLinkTargetEmail, async (ssoPage) => {
|
await withOidcLoginAttempt(browser, providerIds.autoLink, autoLinkTargetEmail, async (ssoPage) => {
|
||||||
await ssoPage.waitForURL(/\/volumes/, { timeout: 30000 });
|
await expectAccountLinkRequiredLoginError(ssoPage);
|
||||||
await waitForAppReady(ssoPage);
|
|
||||||
await expect(ssoPage).toHaveURL(/\/volumes/);
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue