diff --git a/end-to-end-tests/fixtures/modDefinitions.ts b/end-to-end-tests/fixtures/modDefinitions.ts index dc447d9942..4736abab3c 100644 --- a/end-to-end-tests/fixtures/modDefinitions.ts +++ b/end-to-end-tests/fixtures/modDefinitions.ts @@ -18,8 +18,8 @@ import { expect } from "@playwright/test"; import { test as pageContextFixture } from "./pageContext"; import { WorkshopPage } from "../pageObjects/extensionConsole/workshop/workshopPage"; -import diff from "deep-diff"; -import { loadBrickYaml } from "@/runtime/brickYaml"; +import { createPatch } from "diff"; +import { dumpBrickYaml, loadBrickYaml } from "@/runtime/brickYaml"; // The mod definitions are a map of mod names to their test metadata type ModDefinitions = Record< @@ -141,14 +141,27 @@ export const test = pageContextFixture.extend<{ currentModDefinitionYaml, ); const parsedLastModDefinitionYaml = loadBrickYaml(lastModDefinition); - const yamlDiff = - diff(parsedLastModDefinitionYaml, parsedCurrentModDefinitionYaml) || - []; - - expect(JSON.stringify(yamlDiff, undefined, 2) + "\n").toMatchSnapshot( - snapshotName + ".json", + const yamlDiff = createPatch( + snapshotName, + normalizeUUIDs( + dumpBrickYaml(parsedLastModDefinitionYaml, { + indent: 2, + sortKeys: true, + }), + ), + normalizeUUIDs( + dumpBrickYaml(parsedCurrentModDefinitionYaml, { + indent: 2, + sortKeys: true, + }), + ), + undefined, + undefined, + { context: 40 }, ); + expect(yamlDiff).toMatchSnapshot(snapshotName + ".diff"); + // Update the mod definition to the last known state modDefinitionsMap[modDefinitionName] = { id: modId, diff --git a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/description-change.diff b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/description-change.diff new file mode 100644 index 0000000000..e09667bb23 --- /dev/null +++ b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/description-change.diff @@ -0,0 +1,58 @@ +Index: description-change +=================================================================== +--- description-change ++++ description-change +@@ -23,52 +23,52 @@ + body: + - config: + body: + - children: + - children: + - children: + - config: + heading: h1 + title: !nunjucks Simple Sidebar Panel + type: header + config: {} + type: column + config: {} + type: row + - children: + - children: + - config: + enableMarkdown: true + text: !nunjucks >- + Simple sidebar panel for testing sidepanel + open/close behavior + type: text + config: {} + type: column + config: {} + type: row + config: {} + type: container + id: '@pixiebrix/document' + root: null + rootMode: document + heading: Simple Sidebar Panel + id: extensionPoint + label: Simple Sidebar Panel + permissions: + origins: [] + permissions: [] + services: {} + kind: recipe + metadata: +- description: Created with the PixieBrix Page Editor ++ description: Created in end to end tests + id: >- + @extension-e2e-test-unaffiliated/simple-sidebar-panel-00000000-0000-0000-0000-000000000000 + name: Simple Sidebar Panel + version: 1.0.0 + options: + schema: + properties: {} + type: object + uiSchema: + ui:order: + - '*' diff --git a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/description-change.json b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/description-change.json deleted file mode 100644 index 7cc1173481..0000000000 --- a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/description-change.json +++ /dev/null @@ -1,11 +0,0 @@ -[ - { - "kind": "E", - "path": [ - "metadata", - "description" - ], - "lhs": "Created with the PixieBrix Page Editor", - "rhs": "Created in end to end tests" - } -] diff --git a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/heading-change.diff b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/heading-change.diff new file mode 100644 index 0000000000..7a1bd03362 --- /dev/null +++ b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/heading-change.diff @@ -0,0 +1,67 @@ +Index: heading-change +=================================================================== +--- heading-change ++++ heading-change +@@ -14,61 +14,61 @@ + urlPatterns: [] + reader: + - '@pixiebrix/document-metadata' + - '@pixiebrix/document-context' + trigger: load + type: actionPanel + kind: extensionPoint + extensionPoints: + - config: + body: + - config: + body: + - children: + - children: + - children: + - config: + heading: h1 + title: !nunjucks Simple Sidebar Panel + type: header + config: {} + type: column + config: {} + type: row + - children: + - children: + - config: + enableMarkdown: true + text: !nunjucks >- + Simple sidebar panel for testing sidepanel + open/close behavior + type: text + config: {} + type: column + config: {} + type: row + config: {} + type: container + id: '@pixiebrix/document' + root: null + rootMode: document +- heading: Simple Sidebar Panel ++ heading: Simple Sidebar Panel -- Updated + id: extensionPoint + label: Simple Sidebar Panel + permissions: + origins: [] + permissions: [] + services: {} + kind: recipe + metadata: + description: Created in end to end tests + id: >- + @extension-e2e-test-unaffiliated/simple-sidebar-panel-00000000-0000-0000-0000-000000000000 + name: Simple Sidebar Panel + version: 1.0.0 + options: + schema: + properties: {} + type: object + uiSchema: + ui:order: + - '*' diff --git a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/heading-change.json b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/heading-change.json deleted file mode 100644 index 0032fb9049..0000000000 --- a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/heading-change.json +++ /dev/null @@ -1,13 +0,0 @@ -[ - { - "kind": "E", - "path": [ - "extensionPoints", - 0, - "config", - "heading" - ], - "lhs": "Simple Sidebar Panel", - "rhs": "Simple Sidebar Panel -- Updated" - } -] diff --git a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/no-changes.diff b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/no-changes.diff new file mode 100644 index 0000000000..ac8294f06a --- /dev/null +++ b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/no-changes.diff @@ -0,0 +1,4 @@ +Index: no-changes +=================================================================== +--- no-changes ++++ no-changes diff --git a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/no-changes.json b/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/no-changes.json deleted file mode 100644 index fe51488c70..0000000000 --- a/end-to-end-tests/tests/workshop/createMod.spec.ts-snapshots/can-create-a-new-mod-from-a-yaml-definition-and-update-it/no-changes.json +++ /dev/null @@ -1 +0,0 @@ -[] diff --git a/package-lock.json b/package-lock.json index 4c04789237..661763cace 100644 --- a/package-lock.json +++ b/package-lock.json @@ -176,7 +176,7 @@ "@testing-library/user-event": "^14.5.2", "@total-typescript/ts-reset": "^0.5.1", "@types/chrome": "^0.0.268", - "@types/deep-diff": "^1.0.5", + "@types/diff": "^5.2.1", "@types/dom-navigation": "^1.0.3", "@types/dompurify": "^3.0.5", "@types/downloadjs": "^1.4.6", @@ -232,7 +232,7 @@ "csp-parse": "0.0.2", "css-loader": "^6.11.0", "css-minimizer-webpack-plugin": "^7.0.0", - "deep-diff": "^1.0.2", + "diff": "^5.2.0", "dotenv": "^16.4.5", "eslint": "^8.57.0", "eslint-config-pixiebrix": "^0.39.0", @@ -8151,18 +8151,18 @@ "@types/ms": "*" } }, - "node_modules/@types/deep-diff": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/@types/deep-diff/-/deep-diff-1.0.5.tgz", - "integrity": "sha512-PQyNSy1YMZU1hgZA5tTYfHPpUAo9Dorn1PZho2/budQLfqLu3JIP37JAavnwYpR1S2yFZTXa3hxaE4ifGW5jaA==", - "dev": true - }, "node_modules/@types/detect-port": { "version": "1.3.5", "resolved": "https://registry.npmjs.org/@types/detect-port/-/detect-port-1.3.5.tgz", "integrity": "sha512-Rf3/lB9WkDfIL9eEKaSYKc+1L/rNVYBjThk22JTqQw0YozXarX8YljFAz+HCoC6h4B4KwCMsBPZHaFezwT4BNA==", "dev": true }, + "node_modules/@types/diff": { + "version": "5.2.1", + "resolved": "https://registry.npmjs.org/@types/diff/-/diff-5.2.1.tgz", + "integrity": "sha512-uxpcuwWJGhe2AR1g8hD9F5OYGCqjqWnBUQFD8gMZsDbv8oPHzxJF6iMO6n8Tk0AdzlxoaaoQhOYlIg/PukVU8g==", + "dev": true + }, "node_modules/@types/doctrine": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/@types/doctrine/-/doctrine-0.0.3.tgz", @@ -13149,12 +13149,6 @@ "integrity": "sha512-Q6fKUPqnAHAyhiUgFU7BUzLiv0kd8saH9al7tnu5Q/okj6dnupxyTgFIBjVzJATdfIAm9NAsvXNzjaKa+bxVyA==", "dev": true }, - "node_modules/deep-diff": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/deep-diff/-/deep-diff-1.0.2.tgz", - "integrity": "sha512-aWS3UIVH+NPGCD1kki+DCU9Dua032iSsO43LqQpcs4R3+dVv7tX0qBGjiVHJHjplsoUM2XRO/KB92glqc68awg==", - "dev": true - }, "node_modules/deep-is": { "version": "0.1.4", "integrity": "sha512-oIPzksmTg4/MriiaYGO+okXDT7ztn/w3Eptv/+gSIdMdKsJo0u4CfYNFJPy+4SKMuCqGw2wxnA+URMg3t8a/bQ==", @@ -13494,6 +13488,15 @@ "detect-port": "bin/detect-port.js" } }, + "node_modules/diff": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/diff/-/diff-5.2.0.tgz", + "integrity": "sha512-uIFDxqpRZGZ6ThOk84hEfqWoHx2devRFvpTZcTHur85vImfaxUbTW9Ryh4CpCuDnToOP1CEtXKIgytHBPVff5A==", + "dev": true, + "engines": { + "node": ">=0.3.1" + } + }, "node_modules/diff-match-patch": { "version": "1.0.5", "integrity": "sha512-IayShXAgj/QMXgB0IWmKx+rOPuGMhqm5w6jvFxmVenXKIzRqTAAsbBPT3kWQeGANj3jGgvcvv4yK6SxqYmikgw==" diff --git a/package.json b/package.json index b1af8970a3..ef9b0e505e 100644 --- a/package.json +++ b/package.json @@ -202,7 +202,7 @@ "@testing-library/user-event": "^14.5.2", "@total-typescript/ts-reset": "^0.5.1", "@types/chrome": "^0.0.268", - "@types/deep-diff": "^1.0.5", + "@types/diff": "^5.2.1", "@types/dom-navigation": "^1.0.3", "@types/dompurify": "^3.0.5", "@types/downloadjs": "^1.4.6", @@ -258,7 +258,7 @@ "csp-parse": "0.0.2", "css-loader": "^6.11.0", "css-minimizer-webpack-plugin": "^7.0.0", - "deep-diff": "^1.0.2", + "diff": "^5.2.0", "dotenv": "^16.4.5", "eslint": "^8.57.0", "eslint-config-pixiebrix": "^0.39.0",