fix(core): sign out jump to 404 (#4204)

This commit is contained in:
Alex Yang 2023-09-05 23:58:05 -07:00 committed by GitHub
parent d8c9f10bc1
commit b3d902e33f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 39 additions and 2 deletions

View File

@ -15,6 +15,7 @@ import { type FC, Suspense, useCallback, useState } from 'react';
import { authAtom } from '../../../../atoms';
import { useCurrentUser } from '../../../../hooks/affine/use-current-user';
import { useNavigateHelper } from '../../../../hooks/use-navigate-helper';
import { signOutCloud } from '../../../../utils/cloud-utils';
import { Upload } from '../../../pure/file-upload';
import * as style from './style.css';
@ -137,6 +138,7 @@ const StoragePanel = () => {
export const AccountSetting: FC = () => {
const t = useAFFiNEI18N();
const user = useCurrentUser();
const { jumpToIndex } = useNavigateHelper();
const setAuthModal = useSetAtom(authAtom);
const onChangeEmail = useCallback(() => {
@ -187,9 +189,14 @@ export const AccountSetting: FC = () => {
name={t[`Sign out`]()}
desc={t['com.affine.setting.sign.out.message']()}
style={{ cursor: 'pointer' }}
data-testid="sign-out-button"
onClick={useCallback(() => {
signOutCloud().catch(console.error);
}, [])}
signOutCloud()
.then(() => {
jumpToIndex();
})
.catch(console.error);
}, [jumpToIndex])}
>
<ArrowRightSmallIcon />
</SettingRow>

View File

@ -10,6 +10,11 @@ import {
getBlockSuiteEditorTitle,
waitForEditorLoad,
} from '@affine-test/kit/utils/page-logic';
import { clickUserInfoCard } from '@affine-test/kit/utils/setting';
import {
clickSideBarAllPageButton,
clickSideBarSettingButton,
} from '@affine-test/kit/utils/sidebar';
import { createLocalWorkspace } from '@affine-test/kit/utils/workspace';
import { expect } from '@playwright/test';
@ -100,4 +105,23 @@ test.describe('collaboration', () => {
expect(await title.innerText()).toBe('TEST TITLE');
}
});
test('exit successfully and re-login', async ({ page }) => {
await page.reload();
await clickSideBarAllPageButton(page);
await page.waitForTimeout(200);
const url = page.url();
await createLocalWorkspace(
{
name: 'test',
},
page
);
await enableCloudWorkspace(page);
await clickSideBarSettingButton(page);
await clickUserInfoCard(page);
await page.getByTestId('sign-out-button').click();
await page.waitForTimeout(5000);
expect(page.url()).toBe(url);
});
});

View File

@ -33,3 +33,9 @@ export async function openWorkspaceSettingPanel(
) {
await page.getByTestId('settings-sidebar').getByText(workspaceName).click();
}
export async function clickUserInfoCard(page: Page) {
await page.getByTestId('user-info-card').click({
delay: 50,
});
}