diff --git a/.github/workflows/update-snapshots.yml b/.github/workflows/update-snapshots.yml index 759fc5b..6ffe056 100644 --- a/.github/workflows/update-snapshots.yml +++ b/.github/workflows/update-snapshots.yml @@ -16,7 +16,7 @@ on: default: 18 node: type: number - description: 'Node.js version (default: 16)' + description: 'Node.js version (default: 20)' skip-tools: description: 'Skip tools build' type: boolean @@ -36,6 +36,10 @@ on: description: 'Rete Kit (@ or /#)' type: string default: 'rete-kit@latest' + deps: + description: 'List of dependencies (/#, comma separated)' + type: string + default: '' workflow_dispatch: inputs: name: @@ -57,7 +61,7 @@ on: default: 18 node: type: number - description: 'Node.js version (default: 16)' + description: 'Node.js version (default: 20)' branch: description: 'Branch' default: main @@ -69,6 +73,10 @@ on: description: 'Rete Kit (@ or /#)' type: string default: 'rete-kit@latest' + deps: + description: 'List of dependencies (/#, comma separated)' + type: string + default: '' jobs: @@ -81,11 +89,19 @@ jobs: qa: ${{ inputs.qa }} kit: ${{ inputs.kit }} + deps: + name: Prepare alias deps + if: inputs.deps + uses: ./.github/workflows/prepare-deps.yml + secrets: inherit + with: + repos: ${{ inputs.deps }} + update: timeout-minutes: 30 runs-on: ubuntu-latest - if: ${{ always() }} - needs: tools + if: ${{ always() && !contains(needs.*.result, 'failure') && !contains(needs.*.result, 'cancelled') }} + needs: [tools, deps] # TODO reuse steps from regression.yml steps: - name: Download artifact with Rete QA @@ -100,6 +116,12 @@ jobs: with: name: ${{ needs.tools.outputs.kit-artifact || inputs.kit }} path: . + - name: Download deps + uses: actions/download-artifact@v4 + if: inputs.deps + with: + name: deps + path: . - name: Install fonts run: | sudo apt-get -qqy update @@ -117,13 +139,13 @@ jobs: sudo apt-get -qyy clean - uses: actions/setup-node@v3 with: - node-version: ${{ inputs.node || 16 }} + node-version: ${{ inputs.node || 20 }} - name: Install Rete QA run: npm i -g ${{ inputs.qa-path || needs.tools.outputs.qa-path }} ${{ inputs.kit-path || needs.tools.outputs.kit-path }} - name: Install Playwright Browsers run: npx playwright install --with-deps - name: Init application - run: rete-qa init -s ${{ inputs.name }} -sv ${{ inputs.version }} + run: rete-qa init -s ${{ inputs.name }} -sv ${{ inputs.version }} ${{ inputs.deps && '--deps-alias deps.json' || '' }} env: CI: "" - name: Update snapshots diff --git a/package-lock.json b/package-lock.json index 90cb0e1..859f8f4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -25,11 +25,16 @@ "globals": "^15.9.0", "nodemon": "^2.0.20", "rete-cli": "~2.0.1", - "rete-kit": "^1.20.0", + "rete-kit": "^1.21.0", "typescript": "^4.9.5" }, "peerDependencies": { - "rete-kit": "^1.20.0" + "rete-kit": "^1.21.0" + }, + "peerDependenciesMeta": { + "rete-kit": { + "optional": true + } } }, "node_modules/@ampproject/remapping": { @@ -8748,9 +8753,9 @@ } }, "node_modules/rete-kit": { - "version": "1.20.0", - "resolved": "https://registry.npmjs.org/rete-kit/-/rete-kit-1.20.0.tgz", - "integrity": "sha512-Um+yBgFdaersGf1bIwI9DNRvhkqYvEAZgplIVPUchGhlbmLpxEkmamwNG8l23EJoWybvXUp2gj7XyTfipWYhPA==", + "version": "1.21.0", + "resolved": "https://registry.npmjs.org/rete-kit/-/rete-kit-1.21.0.tgz", + "integrity": "sha512-xhNIY9E053UhKvNAqfDMReeddxWU4kZDmvb0hBggNfrphqB0XeDMXGbT2ZtL8ApUSCshojF4iDdbCff3nqpnPA==", "dev": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 3fe6702..0d7a1d1 100644 --- a/package.json +++ b/package.json @@ -32,11 +32,11 @@ "globals": "^15.9.0", "nodemon": "^2.0.20", "rete-cli": "~2.0.1", - "rete-kit": "^1.20.0", + "rete-kit": "^1.21.0", "typescript": "^4.9.5" }, "peerDependencies": { - "rete-kit": "^1.20.0" + "rete-kit": "^1.21.0" }, "dependencies": { "@playwright/test": "1.61.1", diff --git a/snapshots/chromium/comment-frame-dragged.png b/snapshots/chromium/comment-frame-dragged.png new file mode 100644 index 0000000..8bf5267 Binary files /dev/null and b/snapshots/chromium/comment-frame-dragged.png differ diff --git a/snapshots/chromium/comment-inline-drag-undone.png b/snapshots/chromium/comment-inline-drag-undone.png new file mode 100644 index 0000000..cf21b23 Binary files /dev/null and b/snapshots/chromium/comment-inline-drag-undone.png differ diff --git a/snapshots/chromium/comment-inline-dragged-before-undo.png b/snapshots/chromium/comment-inline-dragged-before-undo.png new file mode 100644 index 0000000..56d7d8e Binary files /dev/null and b/snapshots/chromium/comment-inline-dragged-before-undo.png differ diff --git a/snapshots/chromium/comment-inline-dragged.png b/snapshots/chromium/comment-inline-dragged.png new file mode 100644 index 0000000..3e8f721 Binary files /dev/null and b/snapshots/chromium/comment-inline-dragged.png differ diff --git a/snapshots/chromium/comment-inline-edit-redone.png b/snapshots/chromium/comment-inline-edit-redone.png new file mode 100644 index 0000000..8662594 Binary files /dev/null and b/snapshots/chromium/comment-inline-edit-redone.png differ diff --git a/snapshots/chromium/comment-inline-edit-undone.png b/snapshots/chromium/comment-inline-edit-undone.png new file mode 100644 index 0000000..cf21b23 Binary files /dev/null and b/snapshots/chromium/comment-inline-edit-undone.png differ diff --git a/snapshots/chromium/comment-inline-edited.png b/snapshots/chromium/comment-inline-edited.png new file mode 100644 index 0000000..2d7a744 Binary files /dev/null and b/snapshots/chromium/comment-inline-edited.png differ diff --git a/snapshots/chromium/comment-membership-out.png b/snapshots/chromium/comment-membership-out.png new file mode 100644 index 0000000..9c64670 Binary files /dev/null and b/snapshots/chromium/comment-membership-out.png differ diff --git a/snapshots/chromium/comments-initial.png b/snapshots/chromium/comments-initial.png new file mode 100644 index 0000000..7e3ebf8 Binary files /dev/null and b/snapshots/chromium/comments-initial.png differ diff --git a/snapshots/chromium/history-connection-add-redone.png b/snapshots/chromium/history-connection-add-redone.png new file mode 100644 index 0000000..5d939f1 Binary files /dev/null and b/snapshots/chromium/history-connection-add-redone.png differ diff --git a/snapshots/chromium/history-connection-add-undone.png b/snapshots/chromium/history-connection-add-undone.png new file mode 100644 index 0000000..607e3f9 Binary files /dev/null and b/snapshots/chromium/history-connection-add-undone.png differ diff --git a/snapshots/chromium/history-connection-added.png b/snapshots/chromium/history-connection-added.png new file mode 100644 index 0000000..f36aa5e Binary files /dev/null and b/snapshots/chromium/history-connection-added.png differ diff --git a/snapshots/chromium/history-connection-remove-redone.png b/snapshots/chromium/history-connection-remove-redone.png new file mode 100644 index 0000000..134ee37 Binary files /dev/null and b/snapshots/chromium/history-connection-remove-redone.png differ diff --git a/snapshots/chromium/history-connection-remove-undone.png b/snapshots/chromium/history-connection-remove-undone.png new file mode 100644 index 0000000..df5bfa5 Binary files /dev/null and b/snapshots/chromium/history-connection-remove-undone.png differ diff --git a/snapshots/chromium/history-connection-removed.png b/snapshots/chromium/history-connection-removed.png new file mode 100644 index 0000000..df7fa02 Binary files /dev/null and b/snapshots/chromium/history-connection-removed.png differ diff --git a/snapshots/chromium/history-node-add-redone.png b/snapshots/chromium/history-node-add-redone.png new file mode 100644 index 0000000..5f4e62b Binary files /dev/null and b/snapshots/chromium/history-node-add-redone.png differ diff --git a/snapshots/chromium/history-node-add-undone.png b/snapshots/chromium/history-node-add-undone.png new file mode 100644 index 0000000..df5bfa5 Binary files /dev/null and b/snapshots/chromium/history-node-add-undone.png differ diff --git a/snapshots/chromium/history-node-added.png b/snapshots/chromium/history-node-added.png new file mode 100644 index 0000000..b80c695 Binary files /dev/null and b/snapshots/chromium/history-node-added.png differ diff --git a/snapshots/chromium/history-node-delete-redone.png b/snapshots/chromium/history-node-delete-redone.png new file mode 100644 index 0000000..9a0f855 Binary files /dev/null and b/snapshots/chromium/history-node-delete-redone.png differ diff --git a/snapshots/chromium/history-node-delete-undone.png b/snapshots/chromium/history-node-delete-undone.png new file mode 100644 index 0000000..98e3b50 Binary files /dev/null and b/snapshots/chromium/history-node-delete-undone.png differ diff --git a/snapshots/chromium/history-node-deleted.png b/snapshots/chromium/history-node-deleted.png new file mode 100644 index 0000000..7c18834 Binary files /dev/null and b/snapshots/chromium/history-node-deleted.png differ diff --git a/snapshots/chromium/history-node-redo.png b/snapshots/chromium/history-node-redo.png new file mode 100644 index 0000000..fc74e29 Binary files /dev/null and b/snapshots/chromium/history-node-redo.png differ diff --git a/snapshots/chromium/history-node-translated.png b/snapshots/chromium/history-node-translated.png new file mode 100644 index 0000000..5400785 Binary files /dev/null and b/snapshots/chromium/history-node-translated.png differ diff --git a/snapshots/chromium/history-node-undo.png b/snapshots/chromium/history-node-undo.png new file mode 100644 index 0000000..0a2ed00 Binary files /dev/null and b/snapshots/chromium/history-node-undo.png differ diff --git a/snapshots/firefox/comment-frame-dragged.png b/snapshots/firefox/comment-frame-dragged.png new file mode 100644 index 0000000..37e0fd5 Binary files /dev/null and b/snapshots/firefox/comment-frame-dragged.png differ diff --git a/snapshots/firefox/comment-inline-drag-undone.png b/snapshots/firefox/comment-inline-drag-undone.png new file mode 100644 index 0000000..a498d08 Binary files /dev/null and b/snapshots/firefox/comment-inline-drag-undone.png differ diff --git a/snapshots/firefox/comment-inline-dragged-before-undo.png b/snapshots/firefox/comment-inline-dragged-before-undo.png new file mode 100644 index 0000000..6ae9ae4 Binary files /dev/null and b/snapshots/firefox/comment-inline-dragged-before-undo.png differ diff --git a/snapshots/firefox/comment-inline-dragged.png b/snapshots/firefox/comment-inline-dragged.png new file mode 100644 index 0000000..fb2bf7f Binary files /dev/null and b/snapshots/firefox/comment-inline-dragged.png differ diff --git a/snapshots/firefox/comment-inline-edit-redone.png b/snapshots/firefox/comment-inline-edit-redone.png new file mode 100644 index 0000000..846d0e7 Binary files /dev/null and b/snapshots/firefox/comment-inline-edit-redone.png differ diff --git a/snapshots/firefox/comment-inline-edit-undone.png b/snapshots/firefox/comment-inline-edit-undone.png new file mode 100644 index 0000000..a498d08 Binary files /dev/null and b/snapshots/firefox/comment-inline-edit-undone.png differ diff --git a/snapshots/firefox/comment-inline-edited.png b/snapshots/firefox/comment-inline-edited.png new file mode 100644 index 0000000..846d0e7 Binary files /dev/null and b/snapshots/firefox/comment-inline-edited.png differ diff --git a/snapshots/firefox/comment-membership-out.png b/snapshots/firefox/comment-membership-out.png new file mode 100644 index 0000000..187f57a Binary files /dev/null and b/snapshots/firefox/comment-membership-out.png differ diff --git a/snapshots/firefox/comments-initial.png b/snapshots/firefox/comments-initial.png new file mode 100644 index 0000000..b80750c Binary files /dev/null and b/snapshots/firefox/comments-initial.png differ diff --git a/snapshots/firefox/history-connection-add-redone.png b/snapshots/firefox/history-connection-add-redone.png new file mode 100644 index 0000000..10d48ff Binary files /dev/null and b/snapshots/firefox/history-connection-add-redone.png differ diff --git a/snapshots/firefox/history-connection-add-undone.png b/snapshots/firefox/history-connection-add-undone.png new file mode 100644 index 0000000..2755c5d Binary files /dev/null and b/snapshots/firefox/history-connection-add-undone.png differ diff --git a/snapshots/firefox/history-connection-added.png b/snapshots/firefox/history-connection-added.png new file mode 100644 index 0000000..10d48ff Binary files /dev/null and b/snapshots/firefox/history-connection-added.png differ diff --git a/snapshots/firefox/history-connection-remove-redone.png b/snapshots/firefox/history-connection-remove-redone.png new file mode 100644 index 0000000..e6b9ed0 Binary files /dev/null and b/snapshots/firefox/history-connection-remove-redone.png differ diff --git a/snapshots/firefox/history-connection-remove-undone.png b/snapshots/firefox/history-connection-remove-undone.png new file mode 100644 index 0000000..fedf21b Binary files /dev/null and b/snapshots/firefox/history-connection-remove-undone.png differ diff --git a/snapshots/firefox/history-connection-removed.png b/snapshots/firefox/history-connection-removed.png new file mode 100644 index 0000000..e6b9ed0 Binary files /dev/null and b/snapshots/firefox/history-connection-removed.png differ diff --git a/snapshots/firefox/history-node-add-redone.png b/snapshots/firefox/history-node-add-redone.png new file mode 100644 index 0000000..a7b154f Binary files /dev/null and b/snapshots/firefox/history-node-add-redone.png differ diff --git a/snapshots/firefox/history-node-add-undone.png b/snapshots/firefox/history-node-add-undone.png new file mode 100644 index 0000000..fedf21b Binary files /dev/null and b/snapshots/firefox/history-node-add-undone.png differ diff --git a/snapshots/firefox/history-node-added.png b/snapshots/firefox/history-node-added.png new file mode 100644 index 0000000..a7b154f Binary files /dev/null and b/snapshots/firefox/history-node-added.png differ diff --git a/snapshots/firefox/history-node-delete-redone.png b/snapshots/firefox/history-node-delete-redone.png new file mode 100644 index 0000000..961b532 Binary files /dev/null and b/snapshots/firefox/history-node-delete-redone.png differ diff --git a/snapshots/firefox/history-node-delete-undone.png b/snapshots/firefox/history-node-delete-undone.png new file mode 100644 index 0000000..fedf21b Binary files /dev/null and b/snapshots/firefox/history-node-delete-undone.png differ diff --git a/snapshots/firefox/history-node-deleted.png b/snapshots/firefox/history-node-deleted.png new file mode 100644 index 0000000..961b532 Binary files /dev/null and b/snapshots/firefox/history-node-deleted.png differ diff --git a/snapshots/firefox/history-node-redo.png b/snapshots/firefox/history-node-redo.png new file mode 100644 index 0000000..23259e4 Binary files /dev/null and b/snapshots/firefox/history-node-redo.png differ diff --git a/snapshots/firefox/history-node-translated.png b/snapshots/firefox/history-node-translated.png new file mode 100644 index 0000000..23259e4 Binary files /dev/null and b/snapshots/firefox/history-node-translated.png differ diff --git a/snapshots/firefox/history-node-undo.png b/snapshots/firefox/history-node-undo.png new file mode 100644 index 0000000..9d6b5f4 Binary files /dev/null and b/snapshots/firefox/history-node-undo.png differ diff --git a/snapshots/webkit/comment-frame-dragged.png b/snapshots/webkit/comment-frame-dragged.png new file mode 100644 index 0000000..c82edc1 Binary files /dev/null and b/snapshots/webkit/comment-frame-dragged.png differ diff --git a/snapshots/webkit/comment-inline-drag-undone.png b/snapshots/webkit/comment-inline-drag-undone.png new file mode 100644 index 0000000..079de18 Binary files /dev/null and b/snapshots/webkit/comment-inline-drag-undone.png differ diff --git a/snapshots/webkit/comment-inline-dragged-before-undo.png b/snapshots/webkit/comment-inline-dragged-before-undo.png new file mode 100644 index 0000000..53b1282 Binary files /dev/null and b/snapshots/webkit/comment-inline-dragged-before-undo.png differ diff --git a/snapshots/webkit/comment-inline-dragged.png b/snapshots/webkit/comment-inline-dragged.png new file mode 100644 index 0000000..7cfc4a3 Binary files /dev/null and b/snapshots/webkit/comment-inline-dragged.png differ diff --git a/snapshots/webkit/comment-inline-edit-redone.png b/snapshots/webkit/comment-inline-edit-redone.png new file mode 100644 index 0000000..d9ebfad Binary files /dev/null and b/snapshots/webkit/comment-inline-edit-redone.png differ diff --git a/snapshots/webkit/comment-inline-edit-undone.png b/snapshots/webkit/comment-inline-edit-undone.png new file mode 100644 index 0000000..079de18 Binary files /dev/null and b/snapshots/webkit/comment-inline-edit-undone.png differ diff --git a/snapshots/webkit/comment-inline-edited.png b/snapshots/webkit/comment-inline-edited.png new file mode 100644 index 0000000..d9ebfad Binary files /dev/null and b/snapshots/webkit/comment-inline-edited.png differ diff --git a/snapshots/webkit/comment-membership-out.png b/snapshots/webkit/comment-membership-out.png new file mode 100644 index 0000000..281ccd0 Binary files /dev/null and b/snapshots/webkit/comment-membership-out.png differ diff --git a/snapshots/webkit/comments-initial.png b/snapshots/webkit/comments-initial.png new file mode 100644 index 0000000..ad92024 Binary files /dev/null and b/snapshots/webkit/comments-initial.png differ diff --git a/snapshots/webkit/history-connection-add-redone.png b/snapshots/webkit/history-connection-add-redone.png new file mode 100644 index 0000000..cf8931f Binary files /dev/null and b/snapshots/webkit/history-connection-add-redone.png differ diff --git a/snapshots/webkit/history-connection-add-undone.png b/snapshots/webkit/history-connection-add-undone.png new file mode 100644 index 0000000..89cd1d9 Binary files /dev/null and b/snapshots/webkit/history-connection-add-undone.png differ diff --git a/snapshots/webkit/history-connection-added.png b/snapshots/webkit/history-connection-added.png new file mode 100644 index 0000000..cf8931f Binary files /dev/null and b/snapshots/webkit/history-connection-added.png differ diff --git a/snapshots/webkit/history-connection-remove-redone.png b/snapshots/webkit/history-connection-remove-redone.png new file mode 100644 index 0000000..89cd1d9 Binary files /dev/null and b/snapshots/webkit/history-connection-remove-redone.png differ diff --git a/snapshots/webkit/history-connection-remove-undone.png b/snapshots/webkit/history-connection-remove-undone.png new file mode 100644 index 0000000..cf8931f Binary files /dev/null and b/snapshots/webkit/history-connection-remove-undone.png differ diff --git a/snapshots/webkit/history-connection-removed.png b/snapshots/webkit/history-connection-removed.png new file mode 100644 index 0000000..89cd1d9 Binary files /dev/null and b/snapshots/webkit/history-connection-removed.png differ diff --git a/snapshots/webkit/history-node-add-redone.png b/snapshots/webkit/history-node-add-redone.png new file mode 100644 index 0000000..b36c7d2 Binary files /dev/null and b/snapshots/webkit/history-node-add-redone.png differ diff --git a/snapshots/webkit/history-node-add-undone.png b/snapshots/webkit/history-node-add-undone.png new file mode 100644 index 0000000..cf8931f Binary files /dev/null and b/snapshots/webkit/history-node-add-undone.png differ diff --git a/snapshots/webkit/history-node-added.png b/snapshots/webkit/history-node-added.png new file mode 100644 index 0000000..b36c7d2 Binary files /dev/null and b/snapshots/webkit/history-node-added.png differ diff --git a/snapshots/webkit/history-node-delete-redone.png b/snapshots/webkit/history-node-delete-redone.png new file mode 100644 index 0000000..7d9b2bb Binary files /dev/null and b/snapshots/webkit/history-node-delete-redone.png differ diff --git a/snapshots/webkit/history-node-delete-undone.png b/snapshots/webkit/history-node-delete-undone.png new file mode 100644 index 0000000..cf8931f Binary files /dev/null and b/snapshots/webkit/history-node-delete-undone.png differ diff --git a/snapshots/webkit/history-node-deleted.png b/snapshots/webkit/history-node-deleted.png new file mode 100644 index 0000000..7d9b2bb Binary files /dev/null and b/snapshots/webkit/history-node-deleted.png differ diff --git a/snapshots/webkit/history-node-redo.png b/snapshots/webkit/history-node-redo.png new file mode 100644 index 0000000..be64506 Binary files /dev/null and b/snapshots/webkit/history-node-redo.png differ diff --git a/snapshots/webkit/history-node-translated.png b/snapshots/webkit/history-node-translated.png new file mode 100644 index 0000000..be64506 Binary files /dev/null and b/snapshots/webkit/history-node-translated.png differ diff --git a/snapshots/webkit/history-node-undo.png b/snapshots/webkit/history-node-undo.png new file mode 100644 index 0000000..0981c13 Binary files /dev/null and b/snapshots/webkit/history-node-undo.png differ diff --git a/src/commands/init/index.test.ts b/src/commands/init/index.test.ts index 7b1df26..d20dab0 100644 --- a/src/commands/init/index.test.ts +++ b/src/commands/init/index.test.ts @@ -24,9 +24,11 @@ describe('Features', () => { expect(baseFeatures).not.toContainEqual(expect.any(App.Features.Minimap)) expect(baseFeatures).not.toContainEqual(expect.any(App.Features.Reroute)) expect(baseFeatures).not.toContainEqual(expect.any(App.Features.Readonly)) + expect(baseFeatures).not.toContainEqual(expect.any(App.Features.Comments)) + expect(baseFeatures).not.toContainEqual(expect.any(App.Features.History)) }) - it('puts minimap, reroute and readonly into features object', () => { + it('puts optional plugins into features object extras', () => { expect(Array.isArray(features)).toBe(false) if (Array.isArray(features)) return @@ -43,6 +45,24 @@ describe('Features', () => { from: 'default', features: expect.arrayContaining(['Readonly']) }) + expect(features.comments).toEqual({ + from: 'default', + features: expect.arrayContaining(['Comments']) + }) + expect(features.history).toEqual({ + from: 'default', + features: expect.arrayContaining(['History', 'Context menu']) + }) + expect(features['comments-history']).toEqual({ + from: 'default', + features: expect.arrayContaining(['Comments', 'History']) + }) + if (typeof features.comments === 'object' && !Array.isArray(features.comments)) { + expect(features.comments.features).not.toContain('History') + } + if (typeof features.history === 'object' && !Array.isArray(features.history)) { + expect(features.history.features).not.toContain('Comments') + } if (typeof features.minimap === 'object' && !Array.isArray(features.minimap)) { expect(features.minimap.features).not.toContain('Reroute') expect(features.minimap.features).not.toContain('Readonly') diff --git a/src/commands/init/index.ts b/src/commands/init/index.ts index 5fc0a07..aa8f7ee 100644 --- a/src/commands/init/index.ts +++ b/src/commands/init/index.ts @@ -56,6 +56,19 @@ export function getFeatures( readonly: { from: 'default', features: [...base, 'Readonly'] + }, + comments: { + from: 'default', + features: [...base, 'Comments'] + }, + history: { + from: 'default', + // Context menu provides Delete for nodes/connections in e2e + features: [...base, 'History', 'Context menu'] + }, + 'comments-history': { + from: 'default', + features: [...base, 'Comments', 'History'] } } } diff --git a/src/commands/test/index.ts b/src/commands/test/index.ts index 7a9931f..aa85889 100644 --- a/src/commands/test/index.ts +++ b/src/commands/test/index.ts @@ -15,17 +15,24 @@ export async function validateTestRun(app: string, dist: string): Promise<{ erro return { error: null } } +const snapshotStack = 'react-vite' + export function validateSnapshotsUpdate(targetFixtures: typeof fixtures) { const fixture = targetFixtures[0] const numberOfFixtures = targetFixtures.length - const target = targets[0] + const target = targets.find(({ stack }) => stack === snapshotStack) + + if (!target) { + return { error: `Snapshot stack "${snapshotStack}" is not configured` } + } + const latestVersion = target.versions[target.versions.length - 1] const canUpdateSnashots = numberOfFixtures === 1 - && fixture.stack === target.stack - && fixture.version === target.versions[target.versions.length - 1] + && fixture.stack === snapshotStack + && fixture.version === latestVersion if (!canUpdateSnashots) { - return { error: 'You can update snapshots only for the latest version of React' } + return { error: `You can update snapshots only for the latest version of ${snapshotStack} (v${latestVersion})` } } return { error: null } diff --git a/src/tests/comments-history.spec.ts b/src/tests/comments-history.spec.ts new file mode 100644 index 0000000..3215c7d --- /dev/null +++ b/src/tests/comments-history.spec.ts @@ -0,0 +1,71 @@ +import { expect, test } from '@playwright/test' + +import { + editCommentViaContextMenu, + findInlineComment, + getCommentText, + move, + redo, + takeBeforeEach, + undo +} from './helper' + +const INLINE_ORIGINAL = 'Inline comment — try Ctrl+Z after edit/delete' +const INLINE_UPDATED = 'Updated inline comment' + +// Integration: Comments + History (comment actions in the undo stack) +test.describe('Comments + History', () => { + const { getContainer: _getContainer } = takeBeforeEach('?template=comments-history', 500, 500) + + test('edit inline comment undo/redo', async ({ page }) => { + const inline = await findInlineComment(page) + + expect(await getCommentText(inline)).toContain('Inline comment') + + await editCommentViaContextMenu(page, inline, INLINE_UPDATED) + await page.waitForTimeout(300) + + expect(await getCommentText(inline)).toBe(INLINE_UPDATED) + expect(await page.screenshot()).toMatchSnapshot('comment-inline-edited.png') + + await undo(page) + await page.waitForTimeout(300) + + expect(await getCommentText(inline)).toBe(INLINE_ORIGINAL) + expect(await page.screenshot()).toMatchSnapshot('comment-inline-edit-undone.png') + + await redo(page) + await page.waitForTimeout(300) + + expect(await getCommentText(inline)).toBe(INLINE_UPDATED) + expect(await page.screenshot()).toMatchSnapshot('comment-inline-edit-redone.png') + }) + + test('undo comment drag', async ({ page }) => { + const inline = await findInlineComment(page) + const before = await inline.boundingBox() + + if (!before) throw new Error('inline comment box') + + await move(page, inline, 60, 40) + await page.waitForTimeout(300) + + const dragged = await inline.boundingBox() + + if (!dragged) throw new Error('inline comment box after drag') + + expect(dragged.x - before.x).toBeGreaterThan(40) + expect(await page.screenshot()).toMatchSnapshot('comment-inline-dragged-before-undo.png') + + await undo(page) + await page.waitForTimeout(300) + + const restored = await inline.boundingBox() + + if (!restored) throw new Error('inline comment box after undo') + + expect(restored.x).toBeCloseTo(before.x, 1) + expect(restored.y).toBeCloseTo(before.y, 1) + expect(await page.screenshot()).toMatchSnapshot('comment-inline-drag-undone.png') + }) +}) diff --git a/src/tests/comments.spec.ts b/src/tests/comments.spec.ts new file mode 100644 index 0000000..b51f6ae --- /dev/null +++ b/src/tests/comments.spec.ts @@ -0,0 +1,81 @@ +import { expect, test } from '@playwright/test' + +import { + boundingBox, + findFrameComment, + findInlineComment, + getCommentText, + getGraphView, + isInside, + move, + takeBeforeEach, + toRect +} from './helper' + +test.describe('Comments', () => { + const { getContainer } = takeBeforeEach('?template=comments', 500, 500) + + test('seeded on load', async ({ page }) => { + const frame = await findFrameComment(page) + const inline = await findInlineComment(page) + + expect(await getCommentText(frame)).toContain('Frame comment') + expect(await getCommentText(inline)).toContain('Inline comment') + expect(await page.locator('.frame-comment')).toHaveCount(1) + expect(await page.locator('.inline-comment')).toHaveCount(1) + expect(await page.screenshot()).toMatchSnapshot('comments-initial.png') + }) + + test('drag inline comment', async ({ page }) => { + const inline = await findInlineComment(page) + const { before, after } = await move(page, inline, 50, 30) + + expect(after.x - before.x).toBeCloseTo(50, 1) + expect(after.y - before.y).toBeCloseTo(30, 1) + expect(await page.screenshot()).toMatchSnapshot('comment-inline-dragged.png') + }) + + test('drag frame comment moves linked nodes', async ({ page }) => { + const { findNodes } = await getGraphView(getContainer()) + const [number1, number2] = await findNodes('Number') + const frame = await findFrameComment(page) + const dx = 40 + const dy = 25 + + const before1 = await boundingBox(number1) + const before2 = await boundingBox(number2) + + await move(page, frame, dx, dy) + + const after1 = await boundingBox(number1) + const after2 = await boundingBox(number2) + + expect(after1.x - before1.x).toBeCloseTo(dx, 5) + expect(after1.y - before1.y).toBeCloseTo(dy, 5) + expect(after2.x - before2.x).toBeCloseTo(dx, 5) + expect(after2.y - before2.y).toBeCloseTo(dy, 5) + expect(await page.screenshot()).toMatchSnapshot('comment-frame-dragged.png') + }) + + test('frame membership — drag node out of frame', async ({ page }) => { + const { findNodes } = await getGraphView(getContainer()) + const frame = await findFrameComment(page) + const [numberNode] = await findNodes('Number') + const frameRect = toRect(await boundingBox(frame)) + const nodeRectBefore = toRect(await boundingBox(numberNode)) + + expect(isInside(nodeRectBefore, frameRect)).toBe(true) + + await move(page, numberNode, 250, 0, 'corner', { + async down() { + await page.mouse.down({ button: 'left' }) + await page.waitForTimeout(1500) + } + }) + + const nodeRectAfter = toRect(await boundingBox(numberNode)) + + expect(isInside(nodeRectAfter, frameRect)).toBe(false) + expect(await page.screenshot()).toMatchSnapshot('comment-membership-out.png') + }) +}) diff --git a/src/tests/helper.ts b/src/tests/helper.ts index 9cff9d7..0bd05b8 100644 --- a/src/tests/helper.ts +++ b/src/tests/helper.ts @@ -204,3 +204,99 @@ export function isOutside(inner: Rect, outer: Rect) { || inner.bottom <= outer.top ) } + +export async function findInlineComment(page: Page) { + const el = await page.$('.inline-comment') + + if (!el) throw new Error('cannot find inline comment') + + return el +} + +export async function findFrameComment(page: Page) { + const el = await page.$('.frame-comment') + + if (!el) throw new Error('cannot find frame comment') + + return el +} + +export async function getCommentText(comment: Selector) { + return comment.evaluate(el => el.textContent ?? '') +} + +export async function editCommentViaContextMenu(page: Page, comment: Selector, text: string) { + page.once('dialog', async dialog => { + await dialog.accept(text) + }) + await clickCenter(page, comment, 'right') +} + +export async function undo(page: Page) { + await page.keyboard.press('Control+KeyZ') +} + +export async function redo(page: Page) { + await page.keyboard.press('Control+KeyY') +} + +export async function deleteViaContextMenu(page: Page, target: Selector) { + await clickCenter(page, target, 'right') + const item = page.locator('[data-testid="context-menu-item"]', { hasText: 'Delete' }) + + await item.click() +} + +export async function disconnectInput(page: Page, node: Node, inputKey: string) { + const el = await node.$(`[data-testid="input-${inputKey}"] [data-testid="input-socket"]`) + const box = await el?.boundingBox() + + if (!box) throw new Error(`Cannot find bounding box for input socket "${inputKey}"`) + + const socketCenter = { + x: box.x + box.width / 2, + y: box.y + box.height / 2 + } + + await page.mouse.move(socketCenter.x, socketCenter.y) + await page.mouse.down() + await page.mouse.move(socketCenter.x - 50, socketCenter.y - 30) + await page.mouse.up() +} + +async function socketCenter(node: Node, side: 'input' | 'output', key: string) { + const el = await node.$(`[data-testid="${side}-${key}"] [data-testid="${side}-socket"]`) + const box = await el?.boundingBox() + + if (!box) throw new Error(`Cannot find bounding box for ${side} socket "${key}"`) + + return { + x: box.x + box.width / 2, + y: box.y + box.height / 2 + } +} + +export async function connectSockets( + page: Page, + source: Node, + outputKey: string, + target: Node, + inputKey: string +) { + const from = await socketCenter(source, 'output', outputKey) + const to = await socketCenter(target, 'input', inputKey) + + await page.mouse.move(from.x, from.y) + await page.mouse.down() + await page.mouse.move(to.x, to.y) + await page.mouse.up() +} + +export async function addNodeViaContextMenu(page: Page, container: Element, label: string) { + const box = await boundingBox(container) + + await page.mouse.click(box.x + 16, box.y + 16, { button: 'right' }) + const item = page.locator('[data-testid="context-menu-item"]', { hasText: label }) + + await item.click() +} diff --git a/src/tests/history.spec.ts b/src/tests/history.spec.ts new file mode 100644 index 0000000..309bcca --- /dev/null +++ b/src/tests/history.spec.ts @@ -0,0 +1,173 @@ +import { expect, test } from '@playwright/test' + +import { + addNodeViaContextMenu, + connectSockets, + deleteViaContextMenu, + disconnectInput, + getGraphView, + move, + redo, + takeBeforeEach, + undo +} from './helper' + +test.describe('History', () => { + const { getContainer } = takeBeforeEach('?template=history', 500, 500) + + test('undo/redo node translate', async ({ page }) => { + const { findNodes } = await getGraphView(getContainer()) + const [numberNode] = await findNodes('Number') + const before = await numberNode.boundingBox() + + if (!before) throw new Error('number node box') + + await move(page, numberNode, 80, 50) + await page.waitForTimeout(300) + + const moved = await numberNode.boundingBox() + + if (!moved) throw new Error('number node box after move') + + expect(moved.x - before.x).toBeGreaterThan(50) + expect(await page.screenshot()).toMatchSnapshot('history-node-translated.png') + + await undo(page) + await page.waitForTimeout(300) + + const restored = await numberNode.boundingBox() + + if (!restored) throw new Error('number node box after undo') + + expect(restored.x).toBeCloseTo(before.x, 1) + expect(restored.y).toBeCloseTo(before.y, 1) + expect(await page.screenshot()).toMatchSnapshot('history-node-undo.png') + + await redo(page) + await page.waitForTimeout(300) + + const redone = await numberNode.boundingBox() + + if (!redone) throw new Error('number node box after redo') + + expect(redone.x).toBeCloseTo(moved.x, 1) + expect(redone.y).toBeCloseTo(moved.y, 1) + expect(await page.screenshot()).toMatchSnapshot('history-node-redo.png') + }) + + test('undo/redo node delete', async ({ page }) => { + const { connections, findNodes, nodes } = await getGraphView(getContainer()) + + expect(await nodes()).toHaveLength(3) + expect(await connections()).toHaveLength(2) + + const [numberNode] = await findNodes('Number') + + await deleteViaContextMenu(page, numberNode) + await page.waitForTimeout(300) + + expect(await findNodes('Number')).toHaveLength(1) + expect(await nodes()).toHaveLength(2) + expect(await connections()).toHaveLength(1) + expect(await page.screenshot()).toMatchSnapshot('history-node-deleted.png') + + await undo(page) + await page.waitForTimeout(300) + + expect(await findNodes('Number')).toHaveLength(2) + expect(await nodes()).toHaveLength(3) + expect(await connections()).toHaveLength(2) + expect(await page.screenshot()).toMatchSnapshot('history-node-delete-undone.png') + + await redo(page) + await page.waitForTimeout(300) + + expect(await findNodes('Number')).toHaveLength(1) + expect(await nodes()).toHaveLength(2) + expect(await connections()).toHaveLength(1) + expect(await page.screenshot()).toMatchSnapshot('history-node-delete-redone.png') + }) + + test('undo/redo connection remove', async ({ page }) => { + const { connections, findNodes } = await getGraphView(getContainer()) + const [addNode] = await findNodes('Add') + + expect(await connections()).toHaveLength(2) + + await disconnectInput(page, addNode, 'a') + await page.waitForTimeout(500) + + expect(await connections()).toHaveLength(1) + expect(await page.screenshot()).toMatchSnapshot('history-connection-removed.png') + + await undo(page) + await page.waitForTimeout(300) + + expect(await connections()).toHaveLength(2) + expect(await page.screenshot()).toMatchSnapshot('history-connection-remove-undone.png') + + await redo(page) + await page.waitForTimeout(300) + + expect(await connections()).toHaveLength(1) + expect(await page.screenshot()).toMatchSnapshot('history-connection-remove-redone.png') + }) + + test('undo/redo node add', async ({ page }) => { + const { findNodes, nodes } = await getGraphView(getContainer()) + + expect(await nodes()).toHaveLength(3) + expect(await findNodes('Number')).toHaveLength(2) + + await addNodeViaContextMenu(page, getContainer(), 'Number') + await page.waitForTimeout(300) + + expect(await findNodes('Number')).toHaveLength(3) + expect(await nodes()).toHaveLength(4) + expect(await page.screenshot()).toMatchSnapshot('history-node-added.png') + + await undo(page) + await page.waitForTimeout(300) + + expect(await findNodes('Number')).toHaveLength(2) + expect(await nodes()).toHaveLength(3) + expect(await page.screenshot()).toMatchSnapshot('history-node-add-undone.png') + + await redo(page) + await page.waitForTimeout(300) + + expect(await findNodes('Number')).toHaveLength(3) + expect(await nodes()).toHaveLength(4) + expect(await page.screenshot()).toMatchSnapshot('history-node-add-redone.png') + }) + + test('undo/redo connection add', async ({ page }) => { + const { connections, findNodes } = await getGraphView(getContainer()) + const [numberNode] = await findNodes('Number') + const [addNode] = await findNodes('Add') + + expect(await connections()).toHaveLength(2) + + await disconnectInput(page, addNode, 'a') + await page.waitForTimeout(500) + expect(await connections()).toHaveLength(1) + + await connectSockets(page, numberNode, 'value', addNode, 'a') + await page.waitForTimeout(500) + + expect(await connections()).toHaveLength(2) + expect(await page.screenshot()).toMatchSnapshot('history-connection-added.png') + + await undo(page) + await page.waitForTimeout(300) + + expect(await connections()).toHaveLength(1) + expect(await page.screenshot()).toMatchSnapshot('history-connection-add-undone.png') + + await redo(page) + await page.waitForTimeout(300) + + expect(await connections()).toHaveLength(2) + expect(await page.screenshot()).toMatchSnapshot('history-connection-add-redone.png') + }) +})