test: search api

This commit is contained in:
DarkSky
2023-01-03 22:43:04 +08:00
parent 765c39b5d2
commit ebdb3172e5
5 changed files with 29 additions and 7 deletions

View File

@@ -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 () => {});

View File

@@ -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 () => {});
});

View File

@@ -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 () => {});
});

View File

@@ -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']])
);
});
});

View File

@@ -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 = <T>(signal: Signal<T>) =>
new Promise<T>(resolve => signal.once(val => resolve(val)));