mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-09-23 20:18:42 +08:00
test(core): enable no-floating-promises rule for tests (#11915)
Sometimes, missing `await` in the test code can cause timing issues, leading to test failures. This PR enables the `no-floating-promises` rule for the test code to ensure that such errors do not occur.
This commit is contained in:
@@ -178,7 +178,7 @@ test('add mindmap into frame, then drag root node of mindmap out.', async ({
|
||||
// drag out
|
||||
{
|
||||
const mindmapBound = await getSelectedBound(page);
|
||||
pressEscape(page);
|
||||
await pressEscape(page);
|
||||
await clickView(page, [
|
||||
mindmapBound[0] + 10,
|
||||
mindmapBound[1] + 0.5 * mindmapBound[3],
|
||||
|
||||
@@ -290,8 +290,8 @@ test.describe('lock', () => {
|
||||
await selectAllByKeyboard(page);
|
||||
await dragBetweenViewCoords(page, [100, 100], [150, 150]);
|
||||
|
||||
assertEdgelessElementBound(page, frame, [100, 100, 200, 200]);
|
||||
assertEdgelessElementBound(page, shape, [150, 150, 50, 50]);
|
||||
await assertEdgelessElementBound(page, frame, [100, 100, 200, 200]);
|
||||
await assertEdgelessElementBound(page, shape, [150, 150, 50, 50]);
|
||||
});
|
||||
|
||||
test('locked element should not be scalable and rotatable. unlocking will recover', async ({
|
||||
|
||||
@@ -196,7 +196,7 @@ test.describe('Embed synced doc in edgeless mode', () => {
|
||||
await expect(edgelessNotes).toHaveCount(2);
|
||||
expect(await getSelectedIds(page)).toHaveLength(1);
|
||||
expect(await getSelectedIds(page)).not.toContain(prevIds);
|
||||
expect(edgelessNotes.last()).toBeVisible();
|
||||
await expect(edgelessNotes.last()).toBeVisible();
|
||||
|
||||
const noteBound = await getSelectedBound(page);
|
||||
expect(isIntersected(embedDocBound, noteBound)).toBe(false);
|
||||
|
||||
@@ -27,7 +27,7 @@ export async function initEmbedSyncedDocState(
|
||||
}
|
||||
|
||||
return await page.evaluate(
|
||||
({ data, option }) => {
|
||||
async ({ data, option }) => {
|
||||
const createDoc = async (
|
||||
docId: string,
|
||||
title: string,
|
||||
@@ -69,11 +69,13 @@ export async function initEmbedSyncedDocState(
|
||||
return note ?? null;
|
||||
};
|
||||
|
||||
const docIds = data.map(({ title, content }, index) => {
|
||||
const id = index === 0 ? window.doc.id : `embed-doc-${index}`;
|
||||
createDoc(id, title, content);
|
||||
return id;
|
||||
});
|
||||
const docIds = await Promise.all(
|
||||
data.map(async ({ title, content }, index) => {
|
||||
const id = index === 0 ? window.doc.id : `embed-doc-${index}`;
|
||||
await createDoc(id, title, content);
|
||||
return id;
|
||||
})
|
||||
);
|
||||
|
||||
const { NoteBlockModel, NoteDisplayMode } =
|
||||
window.$blocksuite.affineModel;
|
||||
|
||||
Reference in New Issue
Block a user