From 94cf32ead2cb4f44d7163ba3e7f5bae84171d002 Mon Sep 17 00:00:00 2001 From: DarkSky <25152247+darkskygit@users.noreply.github.com> Date: Thu, 7 Aug 2025 17:37:22 +0800 Subject: [PATCH] fix(server): unstable test (#13436) ## Summary by CodeRabbit * **Tests** * Improved test reliability by automatically cleaning up workspace snapshots during embedding status checks in end-to-end tests. --- .../e2e/utils/settings-panel-utils.ts | 2 ++ tests/kit/src/utils/cloud.ts | 9 +++++++++ 2 files changed, 11 insertions(+) diff --git a/tests/affine-cloud-copilot/e2e/utils/settings-panel-utils.ts b/tests/affine-cloud-copilot/e2e/utils/settings-panel-utils.ts index e6e47585c..b13e50bf5 100644 --- a/tests/affine-cloud-copilot/e2e/utils/settings-panel-utils.ts +++ b/tests/affine-cloud-copilot/e2e/utils/settings-panel-utils.ts @@ -1,3 +1,4 @@ +import { cleanupWorkspace } from '@affine-test/kit/utils/cloud'; import { expect, type Page } from '@playwright/test'; const WORKSPACE_EMBEDDING_SWITCH_TEST_ID = 'workspace-embedding-setting-switch'; @@ -214,6 +215,7 @@ export class SettingsPanelUtils { status = 'synced' ) { await expect(async () => { + await cleanupWorkspace(page.url().split('/').slice(-2)[0] || ''); await this.openSettingsPanel(page); const title = page.getByTestId('embedding-progress-title'); // oxlint-disable-next-line prefer-dom-node-dataset diff --git a/tests/kit/src/utils/cloud.ts b/tests/kit/src/utils/cloud.ts index 4ef207dcf..edeb942da 100644 --- a/tests/kit/src/utils/cloud.ts +++ b/tests/kit/src/utils/cloud.ts @@ -152,6 +152,15 @@ export async function createRandomUser(): Promise<{ } as any; } +export async function cleanupWorkspace(workspaceId: string): Promise { + await runPrisma(async client => { + const ret = await client.snapshot.deleteMany({ + where: { workspaceId, id: { not: workspaceId } }, + }); + console.error(ret); + }); +} + export async function switchDefaultChatModel(model: string) { await runPrisma(async client => { const promptId = await client.aiPrompt