0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00

fix(test): fix cloud UI test create new account idling URL mismatch error (#4037)

This commit is contained in:
Darcy Ye 2023-06-15 14:46:05 +08:00 committed by GitHub
parent 5c3c8434f3
commit 9fa2bc9235
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 12 deletions

View file

@ -1,7 +1,8 @@
import { useLogto } from '@logto/react'; import { useLogto } from '@logto/react';
import { type TenantInfo } from '@logto/schemas/models';
import { conditional, yes } from '@silverhand/essentials'; import { conditional, yes } from '@silverhand/essentials';
import { HTTPError } from 'ky'; import { HTTPError } from 'ky';
import { useContext, useEffect, useState } from 'react'; import { useCallback, useContext, useEffect, useState } from 'react';
import { useHref, useSearchParams } from 'react-router-dom'; import { useHref, useSearchParams } from 'react-router-dom';
import { useCloudApi } from '@/cloud/hooks/use-cloud-api'; import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
@ -36,6 +37,13 @@ function Protected() {
} }
}, [api, setTenants, tenants]); }, [api, setTenants, tenants]);
const onAdd = useCallback(
(tenant: TenantInfo) => {
setTenants([...(tenants ?? []), tenant]);
},
[setTenants, tenants]
);
if (error) { if (error) {
if (error instanceof HTTPError && error.response.status === 401) { if (error instanceof HTTPError && error.response.status === 401) {
return <SessionExpired error={error} />; return <SessionExpired error={error} />;
@ -49,14 +57,7 @@ function Protected() {
return <Redirect tenants={tenants} toTenantId={currentTenantId} />; return <Redirect tenants={tenants} toTenantId={currentTenantId} />;
} }
return ( return <Tenants data={tenants} onAdd={onAdd} />;
<Tenants
data={tenants}
onAdd={(tenant) => {
setTenants([...tenants, tenant]);
}}
/>
);
} }
return <AppLoading />; return <AppLoading />;

View file

@ -169,9 +169,7 @@ describe('smoke testing for cloud', () => {
}); });
await expect(page).toClick('button[name=submit]'); await expect(page).toClick('button[name=submit]');
await page.waitForNavigation({ waitUntil: 'networkidle0' }); await page.waitForNavigation({ waitUntil: 'networkidle0', timeout: 5000 });
console.log('???', page.url());
expect(page.url().startsWith(logtoCloudUrl.href)).toBeTruthy(); expect(page.url().startsWith(logtoCloudUrl.href)).toBeTruthy();
expect(new URL(page.url()).pathname.endsWith('/onboarding/welcome')).toBeTruthy(); expect(new URL(page.url()).pathname.endsWith('/onboarding/welcome')).toBeTruthy();