mirror of
https://github.com/toeverything/AFFiNE.git
synced 2024-12-31 18:04:42 +03:00
fix: infinite loading when no workspaces (#1679)
This commit is contained in:
parent
9eec8d0f1e
commit
3e299b97c3
@ -67,6 +67,10 @@ const App = function App({
|
||||
>
|
||||
<Head>
|
||||
<title>AFFiNE</title>
|
||||
<meta
|
||||
name="viewport"
|
||||
content="initial-scale=1, width=device-width"
|
||||
/>
|
||||
</Head>
|
||||
{getLayout(<Component {...pageProps} />)}
|
||||
</ProviderComposer>
|
||||
|
@ -51,7 +51,6 @@ export default class AppDocument extends Document<{
|
||||
/>
|
||||
<link rel="icon" sizes="192x192" href="/chrome-192x192.png" />
|
||||
<meta name="emotion-insertion-point" content="" />
|
||||
<meta name="viewport" content="initial-scale=1, width=device-width" />
|
||||
<meta name="twitter:card" content="summary_large_image" />
|
||||
<meta name="twitter:url" content="https://app.affine.pro/" />
|
||||
<meta
|
||||
|
@ -49,10 +49,13 @@ const IndexPageInner = () => {
|
||||
dispose.dispose();
|
||||
};
|
||||
}
|
||||
} else {
|
||||
// fixme: should create new workspace
|
||||
jumpToSubPath('ERROR', WorkspaceSubPath.ALL, RouteLogic.REPLACE);
|
||||
}
|
||||
}, [jumpToPage, jumpToSubPath, lastWorkspaceId, router, workspaces]);
|
||||
|
||||
return <PageLoading />;
|
||||
return <PageLoading key="IndexPageInfinitePageLoading" />;
|
||||
};
|
||||
|
||||
const IndexPage: NextPage = () => {
|
||||
|
@ -4,15 +4,23 @@
|
||||
import 'fake-indexeddb/auto';
|
||||
|
||||
import userA from '@affine-test/fixtures/userA.json';
|
||||
import { assertExists } from '@blocksuite/global/utils';
|
||||
import { Workspace } from '@blocksuite/store';
|
||||
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
||||
|
||||
import { createWorkspaceApis, createWorkspaceResponseSchema } from '../api';
|
||||
import { loginResponseSchema, setLoginStorage } from '../login';
|
||||
import {
|
||||
createAffineAuth,
|
||||
getLoginStorage,
|
||||
loginResponseSchema,
|
||||
setLoginStorage,
|
||||
} from '../login';
|
||||
|
||||
let workspaceApis: ReturnType<typeof createWorkspaceApis>;
|
||||
let affineAuth: ReturnType<typeof createAffineAuth>;
|
||||
|
||||
beforeAll(() => {
|
||||
affineAuth = createAffineAuth('http://localhost:3000/');
|
||||
workspaceApis = createWorkspaceApis('http://localhost:3000/');
|
||||
});
|
||||
|
||||
@ -49,6 +57,12 @@ beforeEach(async () => {
|
||||
});
|
||||
|
||||
describe('api', () => {
|
||||
test('refresh token', async () => {
|
||||
const storage = getLoginStorage();
|
||||
assertExists(storage);
|
||||
loginResponseSchema.parse(await affineAuth.refreshToken(storage));
|
||||
});
|
||||
|
||||
test(
|
||||
'create workspace',
|
||||
async () => {
|
||||
|
@ -85,7 +85,7 @@ declare global {
|
||||
var firebaseAuthEmulatorStarted: boolean | undefined;
|
||||
}
|
||||
|
||||
export function createAffineAuth() {
|
||||
export function createAffineAuth(prefix = '/') {
|
||||
let _firebaseAuth: FirebaseAuth | null = null;
|
||||
const getAuth = (): FirebaseAuth | null => {
|
||||
try {
|
||||
@ -138,7 +138,7 @@ export function createAffineAuth() {
|
||||
const response = await signInWithPopup(auth, provider);
|
||||
const idToken = await response.user.getIdToken();
|
||||
logger.debug(idToken);
|
||||
return fetch('/api/user/token', {
|
||||
return fetch(prefix + 'api/user/token', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -161,7 +161,7 @@ export function createAffineAuth() {
|
||||
refreshToken: async (
|
||||
loginResponse: LoginResponse
|
||||
): Promise<LoginResponse | null> => {
|
||||
return fetch('/api/user/token', {
|
||||
return fetch(prefix + 'api/user/token', {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
@ -9,6 +9,7 @@ test.describe('Local first default workspace', () => {
|
||||
test('preset workspace name', async ({ page }) => {
|
||||
await openHomePage(page);
|
||||
const workspaceName = page.getByTestId('workspace-name');
|
||||
await page.waitForTimeout(1000);
|
||||
expect(await workspaceName.textContent()).toBe('Demo Workspace');
|
||||
await assertCurrentWorkspaceFlavour('local', page);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user