Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.
TypeScript boardcollaborationdocdocxexceloffce365officepdfpptpptxpresentationsdksheetslidesspreadsheetuniverwordwordprocessorworkspacexlsx
test: add visual comparison tests (#3652)
Wenzhao Huf85d8008935f
diff --git a/.github/actions/update-snapshots/action.yml b/.github/actions/update-snapshots/action.ymlnew file mode 100644index 0000000000..4443aebecf--- /dev/null+++ b/.github/actions/update-snapshots/action.yml@@ -0,0 +1,27 @@+name: 📸 Update Snapshots+description: Update snapshots and push a new commit.++runs:+ using: composite+ steps:+ - name: Install Playwright Browsers+ shell: bash+ run: pnpm exec playwright install --with-deps chromium++ - name: Build E2E Client+ shell: bash+ run: pnpm build:e2e++ - name: Update Snapshots+ shell: bash+ run: pnpm exec playwright test e2e/visual-comparison --update-snapshots++ - name: Commit Updated Snapshots+ shell: bash+ run: |+ git config --global user.email "[email protected]"+ git config --global user.name "GitHub Actions"++ git add -A+ git commit -m "chore(snapshots): update snapshots" || exit 0+ git pushdiff --git a/.github/workflows/playwright.yml b/.github/workflows/playwright.ymlindex 7f1934c18a..55c1067f9b 100644--- a/.github/workflows/playwright.yml+++ b/.github/workflows/playwright.yml@@ -42,19 +42,3 @@ jobs:with:report-file: playwright-report.jsoncustom-info: 'For more information, [see full report](${{ steps.vercel-e2e-report.outputs.preview-url }})'-- # - name: Set Label- # uses: actions/github-script@v6- # if: failure()- # with:- # script: |- # const { owner, repo } = context.repo;- # const prNumber = context.payload.pull_request.number;- # const labelsToAdd = ['qa:rejected'];-- # await github.rest.issues.addLabels({- # owner,- # repo,- # issue_number: prNumber,- # labels: labelsToAdd,- # });diff --git a/.github/workflows/update-snapshots-manually.yml b/.github/workflows/update-snapshots-manually.ymlnew file mode 100644index 0000000000..ecd8c2b152--- /dev/null+++ b/.github/workflows/update-snapshots-manually.yml@@ -0,0 +1,21 @@+name: 📸 Manually Update Snapshots++# manual trigger+on:+ workflow_dispatch:++jobs:+ udpate-snapshots:+ runs-on: ubuntu-latest+ env:+ GH_TOKEN: ${{ github.token }}++ steps:+ - name: Checkout+ uses: actions/checkout@v4++ - name: Setup Node.js+ uses: ./.github/actions/setup-node++ - name: Update Snapshots+ uses: ./.github/actions/update-snapshotsdiff --git a/.github/workflows/update-snapshots-on-comment.yml b/.github/workflows/update-snapshots-on-comment.ymlnew file mode 100644index 0000000000..63363dfbc5--- /dev/null+++ b/.github/workflows/update-snapshots-on-comment.yml@@ -0,0 +1,22 @@+name: 📸 Update Snapshots on Comment++on:+ issue_comment:+ types: [created]++jobs:+ udpate-snapshots:+ if: contains(github.event.comment.body, '/update-snapshots')+ runs-on: ubuntu-latest+ env:+ GH_TOKEN: ${{ github.token }}++ steps:+ - name: Checkout+ uses: actions/checkout@v4++ - name: Setup Node.js+ uses: ./.github/actions/setup-node++ - name: Update Snapshots+ uses: ./.github/actions/udpate-snapshotsdiff --git a/e2e-experimental/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/diff-default-doc-content-1-chromium-linux.png b/e2e-experimental/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/diff-default-doc-content-1-chromium-linux.pngdeleted file mode 100644index 294213e3ce..0000000000Binary files a/e2e-experimental/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/diff-default-doc-content-1-chromium-linux.png and /dev/null differdiff --git a/e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-linux.png b/e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-linux.pngdeleted file mode 100644index 51b6abb346..0000000000Binary files a/e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-linux.png and /dev/null differdiff --git a/e2e/README.md b/e2e/README.mddeleted file mode 100644index e69de29bb2..0000000000diff --git a/e2e/mockdata/emptysheet.ts b/e2e/__testing__/emptysheet.tssimilarity index 100%rename from e2e/mockdata/emptysheet.tsrename to e2e/__testing__/emptysheet.tsdiff --git a/e2e/mockdata/freezesheet.ts b/e2e/__testing__/freezesheet.tssimilarity index 100%rename from e2e/mockdata/freezesheet.tsrename to e2e/__testing__/freezesheet.tsdiff --git a/e2e/mockdata/mergecell.ts b/e2e/__testing__/mergecell.tssimilarity index 100%rename from e2e/mockdata/mergecell.tsrename to e2e/__testing__/mergecell.tsdiff --git a/e2e/mockdata/overflow.ts b/e2e/__testing__/overflow.tssimilarity index 100%rename from e2e/mockdata/overflow.tsrename to e2e/__testing__/overflow.tsdiff --git a/e2e/memory/memory.spec.ts b/e2e/memory/memory.spec.tsindex 6c483da578..8a91832247 100644--- a/e2e/memory/memory.spec.ts+++ b/e2e/memory/memory.spec.ts@@ -16,8 +16,8 @@/* eslint-disable no-console */-import { expect, test } from '@playwright/test';import type { Page } from '@playwright/test';+import { expect, test } from '@playwright/test';const MAX_MEMORY_OVERFLOW = 5_000_000; // 5MBdiff --git a/e2e/perf/scroll.spec.ts b/e2e/perf/scroll.spec.tsindex 3131159bce..5b8cce7bb8 100644--- a/e2e/perf/scroll.spec.ts+++ b/e2e/perf/scroll.spec.ts@@ -17,10 +17,10 @@import { chromium, expect, test } from '@playwright/test';/* eslint-disable no-console */import type { Page } from '@playwright/test';-import { sheetData as emptySheetData } from '../mockdata/emptysheet';-import { sheetData as freezeData } from '../mockdata/freezesheet';-import { sheetData as mergeCellData } from '../mockdata/mergecell';-import { sheetData as overflowData } from '../mockdata/overflow';+import { sheetData as emptySheetData } from '../__testing__/emptysheet';+import { sheetData as freezeData } from '../__testing__/freezesheet';+import { sheetData as mergeCellData } from '../__testing__/mergecell';+import { sheetData as overflowData } from '../__testing__/overflow';export interface IFPSData {fpsData: number[];diff --git a/e2e-experimental/visual-comparison/README.md b/e2e/visual-comparison/README.mdsimilarity index 100%rename from e2e-experimental/visual-comparison/README.mdrename to e2e/visual-comparison/README.mddiff --git a/e2e-experimental/visual-comparison/docs/docs-visual-comparison.spec.ts b/e2e/visual-comparison/docs/docs-visual-comparison.spec.tssimilarity index 100%rename from e2e-experimental/visual-comparison/docs/docs-visual-comparison.spec.tsrename to e2e/visual-comparison/docs/docs-visual-comparison.spec.tsdiff --git a/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/diff-default-doc-content-1-chromium-linux.png b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/diff-default-doc-content-1-chromium-linux.pngnew file mode 100644index 0000000000..5010402b62Binary files /dev/null and b/e2e/visual-comparison/docs/docs-visual-comparison.spec.ts-snapshots/diff-default-doc-content-1-chromium-linux.png differdiff --git a/e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.ts b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.tssimilarity index 93%rename from e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.tsrename to e2e/visual-comparison/sheet/sheets-visual-comparison.spec.tsindex f3bb3674ac..0e98b9ca93 100644--- a/e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.ts+++ b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts@@ -23,6 +23,5 @@ test('diff default sheet content', async ({ page }) => {await page.evaluate(() => window.E2EControllerAPI.loadDefaultSheet());await page.waitForTimeout(5000);- await expect(page).toHaveScreenshot({ maxDiffPixels: 0 });+ await expect(page).toHaveScreenshot({ maxDiffPixels: 5 });});-diff --git a/e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-darwin.png b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-darwin.pngsimilarity index 100%rename from e2e-experimental/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-darwin.pngrename to e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-darwin.pngdiff --git a/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-linux.png b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-linux.pngnew file mode 100644index 0000000000..85e8c788d0Binary files /dev/null and b/e2e/visual-comparison/sheet/sheets-visual-comparison.spec.ts-snapshots/diff-default-sheet-content-1-chromium-linux.png differ