Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

chore(core): upload flaky test traces (#9974)

pengx179fd547d48465
diff --git a/.github/workflows/build-test.yml b/.github/workflows/build-test.yml
index dde70e06e9..ef03637a19 100644
--- a/.github/workflows/build-test.yml
+++ b/.github/workflows/build-test.yml
@@ -175,7 +175,7 @@ jobs:
run: yarn workspace @blocksuite/legacy-e2e test --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Upload test results
- if: ${{ failure() }}
+ if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-e2e-legacy-bs-${{ matrix.shard }}
@@ -207,7 +207,7 @@ jobs:
run: yarn affine @affine-test/affine-local e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Upload test results
- if: ${{ failure() }}
+ if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-e2e-${{ matrix.shard }}
@@ -239,7 +239,7 @@ jobs:
run: yarn affine @affine-test/affine-mobile e2e --forbid-only --shard=${{ matrix.shard }}/${{ strategy.job-total }}
- name: Upload test results
- if: ${{ failure() }}
+ if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-e2e-mobile-${{ matrix.shard }}
@@ -328,6 +328,7 @@ jobs:
package: '@affine/native'
- name: Upload ${{ steps.filename.outputs.filename }}
uses: actions/upload-artifact@v4
+ if: always()
with:
name: ${{ steps.filename.outputs.filename }}
path: ${{ env.DEV_DRIVE_WORKSPACE || github.workspace }}/packages/frontend/native/${{ steps.filename.outputs.filename }}
@@ -354,6 +355,7 @@ jobs:
package: '@affine/server-native'
- name: Upload server-native.node
uses: actions/upload-artifact@v4
+ if: always()
with:
name: server-native.node
path: ./packages/backend/native/server-native.node
@@ -379,6 +381,7 @@ jobs:
run: tar -czf dist.tar.gz --directory=packages/frontend/apps/electron-renderer/dist .
- name: Upload web artifact
uses: actions/upload-artifact@v4
+ if: always()
with:
name: web
path: dist.tar.gz
@@ -660,12 +663,16 @@ jobs:
matrix:
tests:
- name: 'Server E2E Test 1/3'
+ shard: 1
script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=1/3
- name: 'Server E2E Test 2/3'
+ shard: 2
script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=2/3
- name: 'Server E2E Test 3/3'
+ shard: 3
script: yarn affine @affine-test/affine-cloud e2e --forbid-only --shard=3/3
- name: 'Server Desktop E2E Test'
+ shard: desktop
script: |
yarn affine @affine/electron build:dev
# Workaround for Electron apps failing to initialize on Ubuntu 24.04 due to AppArmor restrictions
@@ -728,10 +735,10 @@ jobs:
COPILOT_PERPLEXITY_API_KEY: 1
- name: Upload test results
- if: ${{ failure() }}
+ if: always()
uses: actions/upload-artifact@v4
with:
- name: test-results-e2e-server
+ name: test-results-e2e-server-${{ matrix.tests.shard }}
path: ./test-results
if-no-files-found: ignore
@@ -853,7 +860,7 @@ jobs:
yarn affine @affine/electron node ./scripts/macos-arm64-output-check.ts
- name: Upload test results
- if: ${{ failure() }}
+ if: always()
uses: actions/upload-artifact@v4
with:
name: test-results-e2e-${{ matrix.spec.os }}-${{ matrix.spec.arch }}
diff --git a/blocksuite/tests-legacy/playwright.config.ts b/blocksuite/tests-legacy/playwright.config.ts
index 15fe0b095d..8b8819ef72 100644
--- a/blocksuite/tests-legacy/playwright.config.ts
+++ b/blocksuite/tests-legacy/playwright.config.ts
@@ -1,10 +1,12 @@
import process from 'node:process';
+import { testResultDir } from '@affine-test/kit/playwright';
import type { PlaywrightWorkerOptions } from '@playwright/test';
import { defineConfig } from '@playwright/test';
export default defineConfig({
testDir: '.',
+ outputDir: testResultDir,
timeout: process.env.CI ? 40000 : 999999,
fullyParallel: true,
snapshotDir: 'snapshots',
diff --git a/blocksuite/tests-legacy/utils/actions/misc.ts b/blocksuite/tests-legacy/utils/actions/misc.ts
index b2a7c3fb89..0755a4eac7 100644
--- a/blocksuite/tests-legacy/utils/actions/misc.ts
+++ b/blocksuite/tests-legacy/utils/actions/misc.ts
@@ -322,7 +322,6 @@ export async function enterPlaygroundRoom(
page.on('console', message => {
if (
[
- '',
// React devtools:
'%cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools font-weight:bold',
// Vite:
@@ -334,7 +333,7 @@ export async function enterPlaygroundRoom(
'Lit is in dev mode. Not recommended for production! See https://lit.dev/msg/dev-mode for more information.',
// Figma embed:
'Running frontend commit',
- ].includes(message.text())
+ ].some(text => message.text().startsWith(text))
) {
return;
}
diff --git a/tests/affine-cloud-copilot/playwright.config.ts b/tests/affine-cloud-copilot/playwright.config.ts
index faff4e14eb..52d6608a57 100644
--- a/tests/affine-cloud-copilot/playwright.config.ts
+++ b/tests/affine-cloud-copilot/playwright.config.ts
@@ -18,8 +18,8 @@ const config: PlaywrightTestConfig = {
viewport: { width: 1440, height: 800 },
actionTimeout: 10 * 1000,
locale: 'en-US',
- trace: 'on',
- video: 'on',
+ trace: 'retain-on-failure',
+ video: 'retain-on-failure',
},
forbidOnly: !!process.env.CI,
workers: 4,
diff --git a/tests/affine-cloud/playwright.config.ts b/tests/affine-cloud/playwright.config.ts
index 59d59729b6..452d8cfe65 100644
--- a/tests/affine-cloud/playwright.config.ts
+++ b/tests/affine-cloud/playwright.config.ts
@@ -18,8 +18,8 @@ const config: PlaywrightTestConfig = {
viewport: { width: 1440, height: 800 },
actionTimeout: 10 * 1000,
locale: 'en-US',
- trace: 'on',
- video: 'on',
+ trace: 'retain-on-failure',
+ video: 'retain-on-failure',
},
forbidOnly: !!process.env.CI,
workers: process.env.CI && !process.env.COPILOT ? 1 : 4,
diff --git a/tests/affine-desktop/playwright.config.ts b/tests/affine-desktop/playwright.config.ts
index e32e938348..e28f551d15 100644
--- a/tests/affine-desktop/playwright.config.ts
+++ b/tests/affine-desktop/playwright.config.ts
@@ -23,7 +23,7 @@ const config: PlaywrightTestConfig = {
outputDir: testResultDir,
use: {
viewport: { width: 1440, height: 800 },
- trace: 'on-first-retry',
+ trace: 'retain-on-failure',
},
};
diff --git a/tests/affine-local/e2e/quick-search.spec.ts b/tests/affine-local/e2e/quick-search.spec.ts
index 23ba53f7a0..73449c864f 100644
--- a/tests/affine-local/e2e/quick-search.spec.ts
+++ b/tests/affine-local/e2e/quick-search.spec.ts
@@ -30,19 +30,11 @@ const insertInputText = async (page: Page, text: string) => {
expect(actual).toBe(text);
};
-const keyboardDownAndSelect = async (page: Page, label: string) => {
- await page.keyboard.press('ArrowDown');
- const selectedEl = page.locator(
- '[cmdk-item][data-selected="true"] [data-testid="cmdk-label"]'
- );
- if (
- !(await selectedEl.isVisible()) ||
- (await selectedEl.innerText()) !== label
- ) {
- await keyboardDownAndSelect(page, label);
- } else {
- await page.keyboard.press('Enter');
- }
+const selectItem = async (page: Page, label: string) => {
+ const selectedEl = page
+ .locator('[cmdk-item] [data-testid="cmdk-label"]')
+ .filter({ hasText: label });
+ await selectedEl.click();
};
const commandsIsVisible = async (page: Page, label: string) => {
@@ -257,7 +249,7 @@ test('can use keyboard down to select goto setting', async ({ page }) => {
await openHomePage(page);
await waitForEditorLoad(page);
await openQuickSearchByShortcut(page);
- await keyboardDownAndSelect(page, 'Go to Settings');
+ await selectItem(page, 'Go to Settings');
await expect(page.getByTestId('setting-modal')).toBeVisible();
});
@@ -351,7 +343,7 @@ test('can use cmdk to export png', async ({ page }) => {
await openQuickSearchByShortcut(page);
const [download] = await Promise.all([
page.waitForEvent('download'),
- keyboardDownAndSelect(page, 'Export to PNG'),
+ selectItem(page, 'Export to PNG'),
]);
expect(download.suggestedFilename()).toBe('this is a new page to export.png');
});
@@ -363,7 +355,7 @@ test('can use cmdk to delete page and restore it', async ({ page }) => {
await getBlockSuiteEditorTitle(page).click();
await getBlockSuiteEditorTitle(page).fill('this is a new page to delete');
await openQuickSearchByShortcut(page);
- await keyboardDownAndSelect(page, 'Move to trash');
+ await selectItem(page, 'Move to trash');
await page.getByTestId('confirm-modal-confirm').click();
const restoreButton = page.getByTestId('page-restore-button');
await expect(restoreButton).toBeVisible();
@@ -371,7 +363,7 @@ test('can use cmdk to delete page and restore it', async ({ page }) => {
await openQuickSearchByShortcut(page);
expect(await commandsIsVisible(page, 'Move to trash')).toBe(false);
expect(await commandsIsVisible(page, 'Restore from trash')).toBe(true);
- await keyboardDownAndSelect(page, 'Restore from trash');
+ await selectItem(page, 'Restore from trash');
await expect(restoreButton).not.toBeVisible();
});
diff --git a/tests/affine-local/playwright.config.ts b/tests/affine-local/playwright.config.ts
index 7f68d6a403..610a857c63 100644
--- a/tests/affine-local/playwright.config.ts
+++ b/tests/affine-local/playwright.config.ts
@@ -31,9 +31,9 @@ const config: PlaywrightTestConfig = {
// Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
// You can open traces locally(`npx playwright show-trace trace.zip`)
// or in your browser on [Playwright Trace Viewer](https://trace.playwright.dev/).
- trace: 'on-first-retry',
+ trace: 'retain-on-failure',
// Record video only when retrying a test for the first time.
- video: 'on-first-retry',
+ video: 'retain-on-failure',
},
forbidOnly: !!process.env.CI,
workers: 4,
diff --git a/tests/affine-mobile/playwright.config.ts b/tests/affine-mobile/playwright.config.ts
index 76b381bc58..6b14373e0d 100644
--- a/tests/affine-mobile/playwright.config.ts
+++ b/tests/affine-mobile/playwright.config.ts
@@ -34,9 +34,9 @@ const config: PlaywrightTestConfig = {
// Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
// You can open traces locally(`npx playwright show-trace trace.zip`)
// or in your browser on [Playwright Trace Viewer](https://trace.playwright.dev/).
- trace: 'on-first-retry',
+ trace: 'retain-on-failure',
// Record video only when retrying a test for the first time.
- video: 'on-first-retry',
+ video: 'retain-on-failure',
},
forbidOnly: !!process.env.CI,
workers: 4,
diff --git a/tests/kit/src/mobile.ts b/tests/kit/src/mobile.ts
index f88228f7b7..96e7f1e3d5 100644
--- a/tests/kit/src/mobile.ts
+++ b/tests/kit/src/mobile.ts
@@ -20,5 +20,9 @@ export const test = baseTest.extend<{
});
await page.goto('/');
await use(page);
+ console.log(
+ 'Browser User Agent:',
+ await page.evaluate(() => navigator.userAgent)
+ );
},
});