mirror of
https://github.com/logto-io/logto.git
synced 2025-01-13 21:30:30 -05:00
fix(console): direct to new created tenant and clear create modal on open (#4051)
This commit is contained in:
parent
ad44f0875a
commit
013022d24f
3 changed files with 6 additions and 19 deletions
|
@ -46,6 +46,7 @@ function CreateTenantModal({ isOpen, onClose }: Props) {
|
||||||
defaultValues: { tag: TenantTag.Development },
|
defaultValues: { tag: TenantTag.Development },
|
||||||
});
|
});
|
||||||
const {
|
const {
|
||||||
|
reset,
|
||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
formState: { errors, isSubmitting },
|
formState: { errors, isSubmitting },
|
||||||
|
@ -58,7 +59,7 @@ function CreateTenantModal({ isOpen, onClose }: Props) {
|
||||||
try {
|
try {
|
||||||
const { name, tag } = data;
|
const { name, tag } = data;
|
||||||
const newTenant = await cloudApi.post('/api/tenants', { body: { name, tag } });
|
const newTenant = await cloudApi.post('/api/tenants', { body: { name, tag } });
|
||||||
|
reset();
|
||||||
onClose(newTenant);
|
onClose(newTenant);
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
toast.error(error instanceof Error ? error.message : String(error));
|
toast.error(error instanceof Error ? error.message : String(error));
|
||||||
|
|
|
@ -115,6 +115,7 @@ function TenantSelector() {
|
||||||
if (tenant) {
|
if (tenant) {
|
||||||
toast.success(t('tenants.tenant_created', { name: tenant.name }));
|
toast.success(t('tenants.tenant_created', { name: tenant.name }));
|
||||||
void mutate();
|
void mutate();
|
||||||
|
window.location.assign(new URL(`/${tenant.id}`, window.location.origin).toString());
|
||||||
}
|
}
|
||||||
setShowCreateTenantModal(false);
|
setShowCreateTenantModal(false);
|
||||||
}}
|
}}
|
||||||
|
|
|
@ -154,10 +154,10 @@ describe('smoke testing for cloud', () => {
|
||||||
'div[class$=ReactModalPortal] div[class*=card][class$=medium] div[class$=footer] button[type=submit]'
|
'div[class$=ReactModalPortal] div[class*=card][class$=medium] div[class$=footer] button[type=submit]'
|
||||||
);
|
);
|
||||||
|
|
||||||
expect(new URL(page.url()).pathname.endsWith(`${defaultTenantId}/get-started`)).toBeTruthy();
|
expect(new URL(page.url()).pathname.endsWith(`/get-started`)).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('check current tenant list and switch to new tenant', async () => {
|
it('should navigate to the new tenant', async () => {
|
||||||
// Wait for toast to disappear.
|
// Wait for toast to disappear.
|
||||||
await page.waitForTimeout(5000);
|
await page.waitForTimeout(5000);
|
||||||
|
|
||||||
|
@ -165,25 +165,10 @@ describe('smoke testing for cloud', () => {
|
||||||
const currentTenantCard = await page.waitForSelector(
|
const currentTenantCard = await page.waitForSelector(
|
||||||
'div[class$=topbar] > div[class$=currentTenantCard][role=button]:has(div[class$=name])'
|
'div[class$=topbar] > div[class$=currentTenantCard][role=button]:has(div[class$=name])'
|
||||||
);
|
);
|
||||||
await expect(currentTenantCard).toMatchElement('div[class$=name]', { text: 'My Project' });
|
await expect(currentTenantCard).toMatchElement('div[class$=name]', { text: createTenantName });
|
||||||
await currentTenantCard.click();
|
|
||||||
|
|
||||||
const newTenant = await page.waitForSelector(
|
|
||||||
'div[class$=ReactModalPortal] div[class$=dropdownContainer] div[class$=dropdownItem]:first-child'
|
|
||||||
);
|
|
||||||
await expect(newTenant).toMatchElement('div[class$=dropdownName]', { text: createTenantName });
|
|
||||||
await newTenant.click();
|
|
||||||
|
|
||||||
await page.waitForNavigation({ waitUntil: 'networkidle0' });
|
|
||||||
});
|
});
|
||||||
|
|
||||||
it('can sign out of admin console', async () => {
|
it('can sign out of admin console', async () => {
|
||||||
// Check if the current tenant is switched to new tenant.
|
|
||||||
const currentTenantCard = await page.waitForSelector(
|
|
||||||
'div[class$=topbar] > div[class$=currentTenantCard][role=button]:has(div[class$=name])'
|
|
||||||
);
|
|
||||||
await expect(currentTenantCard).toMatchElement('div[class$=name]', { text: createTenantName });
|
|
||||||
|
|
||||||
const userInfoButton = await page.waitForSelector('div[class$=topbar] > div[class$=container]');
|
const userInfoButton = await page.waitForSelector('div[class$=topbar] > div[class$=container]');
|
||||||
await userInfoButton.click();
|
await userInfoButton.click();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue