mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-12 12:28:42 +00:00
fix: infinite loading when no workspaces (#1679)
This commit is contained in:
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user