diff --git a/packages/data-center/tests/auth.spec.ts b/packages/data-center/tests/auth.spec.ts index fd7e56d78c..a82f0e7b6d 100644 --- a/packages/data-center/tests/auth.spec.ts +++ b/packages/data-center/tests/auth.spec.ts @@ -5,9 +5,9 @@ import { getDataCenter } from './utils.js'; import 'fake-indexeddb/auto'; test.describe('auth', () => { - test('signin', async () => {}); + test('sign in', async () => {}); - test('signout', async () => {}); + test('sign out', async () => {}); test('isLogin', async () => {}); diff --git a/packages/data-center/tests/collaborate.spec.ts b/packages/data-center/tests/collaborate.spec.ts index f28bd9e841..f852aaa6cd 100644 --- a/packages/data-center/tests/collaborate.spec.ts +++ b/packages/data-center/tests/collaborate.spec.ts @@ -9,7 +9,7 @@ test.describe('collaborate', () => { test('collaborate workspace name', async () => {}); - test('collaborate workspace avator', async () => {}); + test('collaborate workspace avatar', async () => {}); test('collaborate workspace list', async () => {}); }); diff --git a/packages/data-center/tests/permission.spec.ts b/packages/data-center/tests/permission.spec.ts index 82cd054483..42cbab7ec0 100644 --- a/packages/data-center/tests/permission.spec.ts +++ b/packages/data-center/tests/permission.spec.ts @@ -11,7 +11,7 @@ test.describe('share', () => { test('make workspace private', async () => {}); - test('unlogin user open the public workspace ', async () => {}); + test('un-login user open the public workspace ', async () => {}); - test('unlogin user open the private workspace ', async () => {}); + test('un-login user open the private workspace ', async () => {}); }); diff --git a/packages/data-center/tests/search.spec.ts b/packages/data-center/tests/search.spec.ts index 5973fb880c..a2bb3cb9a1 100644 --- a/packages/data-center/tests/search.spec.ts +++ b/packages/data-center/tests/search.spec.ts @@ -1,9 +1,26 @@ +import assert from 'assert'; import { test, expect } from '@playwright/test'; -import { getDataCenter } from './utils.js'; +import { getDataCenter, waitOnce } from './utils.js'; import 'fake-indexeddb/auto'; test.describe('search', () => { - test('search service', async () => {}); + test('search service', async () => { + const dc = await getDataCenter(); + const workspace = await dc.load('test'); + + assert(workspace); + workspace.createPage('test'); + await waitOnce(workspace.signals.pageAdded); + const page = workspace.getPage('test'); + assert(page); + + const text = new page.Text(page, 'hello world'); + const blockId = page.addBlock({ flavour: 'affine:paragraph', text }); + + expect(workspace.search('hello')).toStrictEqual( + new Map([[blockId, 'test']]) + ); + }); }); diff --git a/packages/data-center/tests/utils.ts b/packages/data-center/tests/utils.ts index 878ccc57a8..75ba394000 100644 --- a/packages/data-center/tests/utils.ts +++ b/packages/data-center/tests/utils.ts @@ -1,5 +1,10 @@ +import { Signal } from '@blocksuite/store'; + export const getDataCenter = () => { return import('../src/index.js').then(async dataCenter => dataCenter.getDataCenter(false) ); }; + +export const waitOnce = (signal: Signal) => + new Promise(resolve => signal.once(val => resolve(val)));