From ecec2d6efe44ee96465795c1fb6599502be033ee Mon Sep 17 00:00:00 2001 From: alt0 Date: Tue, 10 Jan 2023 15:07:50 +0800 Subject: [PATCH] test: fix test case --- .../provider/affine/__tests__/affine.spec.ts | 2 +- .../src/provider/local/local.spec.ts | 28 +++++++++---------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/packages/data-center/src/provider/affine/__tests__/affine.spec.ts b/packages/data-center/src/provider/affine/__tests__/affine.spec.ts index 3208c6d54d..f60af0d139 100644 --- a/packages/data-center/src/provider/affine/__tests__/affine.spec.ts +++ b/packages/data-center/src/provider/affine/__tests__/affine.spec.ts @@ -1,6 +1,6 @@ import { test, expect } from '@playwright/test'; import { AffineProvider } from '../affine.js'; -import { Workspaces } from '../../../workspaces/index.js'; +// import { Workspaces } from '../../../workspaces/index.js'; import { apis } from './mock-apis.js'; import 'fake-indexeddb/auto'; diff --git a/packages/data-center/src/provider/local/local.spec.ts b/packages/data-center/src/provider/local/local.spec.ts index 5d388470a6..eff462ef86 100644 --- a/packages/data-center/src/provider/local/local.spec.ts +++ b/packages/data-center/src/provider/local/local.spec.ts @@ -1,13 +1,13 @@ import { test, expect } from '@playwright/test'; -import { Workspaces } from '../../workspaces/index.js'; +import { WorkspaceMetaCollection } from '../../workspace-meta-collection.js'; import { LocalProvider } from './local.js'; import { createBlocksuiteWorkspace } from '../../utils/index.js'; import 'fake-indexeddb/auto'; test.describe.serial('local provider', () => { - const workspaces = new Workspaces(); + const workspaceMetaCollection = new WorkspaceMetaCollection(); const provider = new LocalProvider({ - workspaces: workspaces.createScope(), + workspaces: workspaceMetaCollection.createScope(), }); const workspaceName = 'workspace-test'; @@ -25,30 +25,30 @@ test.describe.serial('local provider', () => { avatar: 'avatar-url-test', }); - expect(workspaces.workspaces.length).toEqual(1); - expect(workspaces.workspaces[0].name).toEqual(workspaceName); + expect(workspaceMetaCollection.workspaces.length).toEqual(1); + expect(workspaceMetaCollection.workspaces[0].name).toEqual(workspaceName); }); test('workspace list cache', async () => { - const workspaces1 = new Workspaces(); + const workspacesMetaCollection1 = new WorkspaceMetaCollection(); const provider1 = new LocalProvider({ - workspaces: workspaces1.createScope(), + workspaces: workspacesMetaCollection1.createScope(), }); await provider1.loadWorkspaces(); - expect(workspaces1.workspaces.length).toEqual(1); - expect(workspaces1.workspaces[0].name).toEqual(workspaceName); - expect(workspaces1.workspaces[0].id).toEqual(workspaceId); + expect(workspacesMetaCollection1.workspaces.length).toEqual(1); + expect(workspacesMetaCollection1.workspaces[0].name).toEqual(workspaceName); + expect(workspacesMetaCollection1.workspaces[0].id).toEqual(workspaceId); }); test('update workspace', async () => { await provider.updateWorkspaceMeta(workspaceId!, { name: '1111', }); - expect(workspaces.workspaces[0].name).toEqual('1111'); + expect(workspaceMetaCollection.workspaces[0].name).toEqual('1111'); }); test('delete workspace', async () => { - expect(workspaces.workspaces.length).toEqual(1); + expect(workspaceMetaCollection.workspaces.length).toEqual(1); /** * FIXME * If we don't wrap setTimeout, @@ -56,8 +56,8 @@ test.describe.serial('local provider', () => { * InvalidStateError: An operation was called on an object on which it is not allowed or at a time when it is not allowed. Also occurs if a request is made on a source object that has been deleted or removed. Use TransactionInactiveError or ReadOnlyError when possible, as they are more specific variations of InvalidStateError. * */ setTimeout(async () => { - await provider.deleteWorkspace(workspaces.workspaces[0].id); - expect(workspaces.workspaces.length).toEqual(0); + await provider.deleteWorkspace(workspaceMetaCollection.workspaces[0].id); + expect(workspaceMetaCollection.workspaces.length).toEqual(0); }, 10); }); });