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

This commit is contained in:
pengx17
2025-02-07 07:08:55 +00:00
committed by Peng Xiao
parent fc4fe481ef
commit 9fd547d484
10 changed files with 38 additions and 34 deletions

View File

@@ -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 }}

View File

@@ -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',

View File

@@ -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;
}

View File

@@ -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,

View File

@@ -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,

View File

@@ -23,7 +23,7 @@ const config: PlaywrightTestConfig = {
outputDir: testResultDir,
use: {
viewport: { width: 1440, height: 800 },
trace: 'on-first-retry',
trace: 'retain-on-failure',
},
};

View File

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

View File

@@ -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,

View File

@@ -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,

View File

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