From 5481f090d2565517f2ff7e081a628f341da38de1 Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Wed, 22 Apr 2026 16:34:08 +0530 Subject: [PATCH 1/6] Add integration test workspace and scripts - Add test/integration workspace with package.json and Jest config - Add integration test scripts to root package.json - Link @wordpress/integration-tests in package-lock.json - Add bin/test-native-args.sh for testing native arg forwarding --- bin/test-native-args.sh | 79 +++++++++++++++++++++++++++++++++ package-lock.json | 15 +++++++ package.json | 4 ++ test/integration/jest.config.js | 20 +++++++++ test/integration/package.json | 35 +++++++++++++++ 5 files changed, 153 insertions(+) create mode 100644 bin/test-native-args.sh create mode 100644 test/integration/jest.config.js create mode 100644 test/integration/package.json diff --git a/bin/test-native-args.sh b/bin/test-native-args.sh new file mode 100644 index 00000000000000..7ba6cfb9180cf3 --- /dev/null +++ b/bin/test-native-args.sh @@ -0,0 +1,79 @@ +#!/usr/bin/env bash + +# Test native arg forwarding cases. +# Only shows the expanded command npm resolves — suppresses actual test output. + +BOLD="\033[1m" +RESET="\033[0m" + +run_case() { + local num="$1" + local desc="$2" + local expected="$3" + shift 3 + + echo "" + echo "--------------------------------------" + echo -e "${BOLD}${num}. ${desc}${RESET}" + echo " Expected: ${expected}" + echo "--------------------------------------" + # Run the command, only show lines npm prints before handing off to jest + # (the "> script" and "> command" lines), suppress everything after + "$@" 2>&1 | grep -E "^>" || true + echo "" +} + +echo "" +echo "======================================" +echo " Native Test Arg Forwarding Test Cases" +echo "======================================" + +run_case 1 \ + "test:native -- --testPathPattern" \ + "jest receives --testPathPattern=" \ + npm run test:native -- --testPathPattern='packages/react-native-editor' --passWithNoTests + +run_case 2 \ + "test:native -- --testNamePattern" \ + "jest receives --testNamePattern=" \ + npm run test:native -- --testNamePattern='should render' --passWithNoTests + +run_case 3 \ + "test:native -- --verbose" \ + "jest receives --verbose" \ + npm run test:native -- --verbose --passWithNoTests + +run_case 4 \ + "test:native -- --runInBand" \ + "jest receives --runInBand" \ + npm run test:native -- --runInBand --passWithNoTests + +run_case 5 \ + "test:native:update -- --testPathPattern (critical: hardcoded + forwarded args)" \ + "jest receives --updateSnapshot AND --testPathPattern" \ + npm run test:native:update -- --testPathPattern='packages/react-native-editor' --passWithNoTests + +run_case 6 \ + "test:native:watch (skipped - interactive)" \ + "jest receives --watch" \ + echo " Skipped (interactive mode)" + +run_case 7 \ + "test:native:clean" \ + "jest --clearCache runs" \ + npm run test:native:clean + +run_case 8 \ + "test:native -- TEST_RN_PLATFORM=ios" \ + "jest config logs: Setting RN platform to: ios" \ + bash -c "TEST_RN_PLATFORM=ios npm run test:native -- --passWithNoTests 2>&1 | grep -E '^>|RN platform'" + +run_case 9 \ + "test:native -- TEST_RN_PLATFORM=android" \ + "jest config logs: Setting RN platform to: android" \ + bash -c "TEST_RN_PLATFORM=android npm run test:native -- --passWithNoTests 2>&1 | grep -E '^>|RN platform'" + +echo "======================================" +echo " Done. Review expanded commands above." +echo "======================================" +echo "" diff --git a/package-lock.json b/package-lock.json index c6a6094bf1992d..cce1bb287945f3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "test/e2e", "test/performance", "test/storybook-playwright", + "test/integration", "test/unit", "tools/api-docs" ], @@ -20646,6 +20647,10 @@ "resolved": "packages/image-cropper", "link": true }, + "node_modules/@wordpress/integration-tests": { + "resolved": "test/integration", + "link": true + }, "node_modules/@wordpress/interactivity": { "resolved": "packages/interactivity", "link": true @@ -63368,6 +63373,16 @@ "filenamify": "^4.2.0" } }, + "test/integration": { + "name": "@wordpress/integration-tests", + "version": "0.0.0", + "license": "GPL-2.0-or-later", + "devDependencies": { + "@wordpress/scripts": "file:../../packages/scripts", + "ajv": "^8.17.1", + "fast-glob": "^3.2.7" + } + }, "test/performance": { "name": "@wordpress/performance-tests", "version": "0.0.0", diff --git a/package.json b/package.json index ca046fbfa0d70f..45e342953509c6 100644 --- a/package.json +++ b/package.json @@ -197,6 +197,9 @@ "test:performance:debug": "npm exec --workspace @wordpress/performance-tests -- wp-scripts test-playwright --config playwright.config.ts --debug", "test:php": "npm-run-all lint:php test:unit:php", "test:php:watch": "wp-env --config .wp-env.test.json run --env-cwd='wp-content/plugins/gutenberg' cli composer run-script test:watch", + "test:integration": "npm run --workspace @wordpress/integration-tests test:integration --", + "test:integration:debug": "npm run --workspace @wordpress/integration-tests test:integration:debug --", + "test:integration:watch": "npm run --workspace @wordpress/integration-tests test:integration:watch --", "test:unit": "npm run --workspace @wordpress/unit-tests test:unit", "test:unit:date": "bash ./bin/unit-test-date.sh", "test:unit:debug": "npm run --workspace @wordpress/unit-tests test:unit:debug", @@ -254,6 +257,7 @@ "test/e2e", "test/performance", "test/storybook-playwright", + "test/integration", "test/unit", "tools/api-docs" ] diff --git a/test/integration/jest.config.js b/test/integration/jest.config.js new file mode 100644 index 00000000000000..573d33aaa4cd91 --- /dev/null +++ b/test/integration/jest.config.js @@ -0,0 +1,20 @@ +/** + * External dependencies + */ +const path = require( 'path' ); + +/** + * Path to root project directory. + */ +const ROOT_DIR = path.resolve( __dirname, '../..' ); + +// Reuse the unit test Jest configuration as the base. +const unitJestConfig = require( '../unit/jest.config.js' ); + +module.exports = { + ...unitJestConfig, + // Scope test discovery to this directory only. + testMatch: [ + path.join( ROOT_DIR, 'test/integration/**/*.test.[jt]s?(x)' ), + ], +}; diff --git a/test/integration/package.json b/test/integration/package.json new file mode 100644 index 00000000000000..c93ac9de96b5bc --- /dev/null +++ b/test/integration/package.json @@ -0,0 +1,35 @@ +{ + "name": "@wordpress/integration-tests", + "version": "0.0.0", + "description": "Integration tests for WordPress Gutenberg.", + "private": true, + "author": "The WordPress Contributors", + "license": "GPL-2.0-or-later", + "keywords": [ + "wordpress", + "gutenberg", + "integration-tests" + ], + "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/test/integration/README.md", + "repository": { + "type": "git", + "url": "git+https://github.com/WordPress/gutenberg.git", + "directory": "test/integration" + }, + "bugs": { + "url": "https://github.com/WordPress/gutenberg/issues" + }, + "devDependencies": { + "@wordpress/scripts": "file:../../packages/scripts", + "ajv": "^8.17.1", + "fast-glob": "^3.2.7" + }, + "publishConfig": { + "access": "public" + }, + "scripts": { + "test:integration": "wp-scripts test-unit-js --config jest.config.js", + "test:integration:watch": "npm run test:integration -- --watch", + "test:integration:debug": "wp-scripts --inspect-brk test-unit-js --runInBand --no-cache --verbose --config jest.config.js" + } +} From 467ef0d10f4adda9f33e422387abe1029e788afd Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Wed, 22 Apr 2026 16:44:54 +0530 Subject: [PATCH 2/6] chore: remove my test script whoops --- bin/test-native-args.sh | 79 ----------------------------------------- 1 file changed, 79 deletions(-) delete mode 100644 bin/test-native-args.sh diff --git a/bin/test-native-args.sh b/bin/test-native-args.sh deleted file mode 100644 index 7ba6cfb9180cf3..00000000000000 --- a/bin/test-native-args.sh +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env bash - -# Test native arg forwarding cases. -# Only shows the expanded command npm resolves — suppresses actual test output. - -BOLD="\033[1m" -RESET="\033[0m" - -run_case() { - local num="$1" - local desc="$2" - local expected="$3" - shift 3 - - echo "" - echo "--------------------------------------" - echo -e "${BOLD}${num}. ${desc}${RESET}" - echo " Expected: ${expected}" - echo "--------------------------------------" - # Run the command, only show lines npm prints before handing off to jest - # (the "> script" and "> command" lines), suppress everything after - "$@" 2>&1 | grep -E "^>" || true - echo "" -} - -echo "" -echo "======================================" -echo " Native Test Arg Forwarding Test Cases" -echo "======================================" - -run_case 1 \ - "test:native -- --testPathPattern" \ - "jest receives --testPathPattern=" \ - npm run test:native -- --testPathPattern='packages/react-native-editor' --passWithNoTests - -run_case 2 \ - "test:native -- --testNamePattern" \ - "jest receives --testNamePattern=" \ - npm run test:native -- --testNamePattern='should render' --passWithNoTests - -run_case 3 \ - "test:native -- --verbose" \ - "jest receives --verbose" \ - npm run test:native -- --verbose --passWithNoTests - -run_case 4 \ - "test:native -- --runInBand" \ - "jest receives --runInBand" \ - npm run test:native -- --runInBand --passWithNoTests - -run_case 5 \ - "test:native:update -- --testPathPattern (critical: hardcoded + forwarded args)" \ - "jest receives --updateSnapshot AND --testPathPattern" \ - npm run test:native:update -- --testPathPattern='packages/react-native-editor' --passWithNoTests - -run_case 6 \ - "test:native:watch (skipped - interactive)" \ - "jest receives --watch" \ - echo " Skipped (interactive mode)" - -run_case 7 \ - "test:native:clean" \ - "jest --clearCache runs" \ - npm run test:native:clean - -run_case 8 \ - "test:native -- TEST_RN_PLATFORM=ios" \ - "jest config logs: Setting RN platform to: ios" \ - bash -c "TEST_RN_PLATFORM=ios npm run test:native -- --passWithNoTests 2>&1 | grep -E '^>|RN platform'" - -run_case 9 \ - "test:native -- TEST_RN_PLATFORM=android" \ - "jest config logs: Setting RN platform to: android" \ - bash -c "TEST_RN_PLATFORM=android npm run test:native -- --passWithNoTests 2>&1 | grep -E '^>|RN platform'" - -echo "======================================" -echo " Done. Review expanded commands above." -echo "======================================" -echo "" From ec831fbd13f7cf9b7f68d623000d531ccfa9b928 Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Wed, 22 Apr 2026 16:48:30 +0530 Subject: [PATCH 3/6] chore: workspaces list is alphabetically ordered --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 45e342953509c6..dbe0c43dd15c97 100644 --- a/package.json +++ b/package.json @@ -255,9 +255,9 @@ "routes/*", "storybook", "test/e2e", + "test/integration", "test/performance", "test/storybook-playwright", - "test/integration", "test/unit", "tools/api-docs" ] From 74a1db4f26adf41de3832eca459401d57d1390b3 Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Wed, 22 Apr 2026 17:10:00 +0530 Subject: [PATCH 4/6] chore: remove not needed files Thought CI has special test unit syntax for integration but they are run with others so these are not needed now --- package-lock.json | 3 +-- package.json | 3 --- test/integration/jest.config.js | 20 -------------------- test/integration/package.json | 6 ------ 4 files changed, 1 insertion(+), 31 deletions(-) delete mode 100644 test/integration/jest.config.js diff --git a/package-lock.json b/package-lock.json index cce1bb287945f3..f0f95265ec5334 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,9 +14,9 @@ "routes/*", "storybook", "test/e2e", + "test/integration", "test/performance", "test/storybook-playwright", - "test/integration", "test/unit", "tools/api-docs" ], @@ -63378,7 +63378,6 @@ "version": "0.0.0", "license": "GPL-2.0-or-later", "devDependencies": { - "@wordpress/scripts": "file:../../packages/scripts", "ajv": "^8.17.1", "fast-glob": "^3.2.7" } diff --git a/package.json b/package.json index dbe0c43dd15c97..10f3107610a806 100644 --- a/package.json +++ b/package.json @@ -197,9 +197,6 @@ "test:performance:debug": "npm exec --workspace @wordpress/performance-tests -- wp-scripts test-playwright --config playwright.config.ts --debug", "test:php": "npm-run-all lint:php test:unit:php", "test:php:watch": "wp-env --config .wp-env.test.json run --env-cwd='wp-content/plugins/gutenberg' cli composer run-script test:watch", - "test:integration": "npm run --workspace @wordpress/integration-tests test:integration --", - "test:integration:debug": "npm run --workspace @wordpress/integration-tests test:integration:debug --", - "test:integration:watch": "npm run --workspace @wordpress/integration-tests test:integration:watch --", "test:unit": "npm run --workspace @wordpress/unit-tests test:unit", "test:unit:date": "bash ./bin/unit-test-date.sh", "test:unit:debug": "npm run --workspace @wordpress/unit-tests test:unit:debug", diff --git a/test/integration/jest.config.js b/test/integration/jest.config.js deleted file mode 100644 index 573d33aaa4cd91..00000000000000 --- a/test/integration/jest.config.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * External dependencies - */ -const path = require( 'path' ); - -/** - * Path to root project directory. - */ -const ROOT_DIR = path.resolve( __dirname, '../..' ); - -// Reuse the unit test Jest configuration as the base. -const unitJestConfig = require( '../unit/jest.config.js' ); - -module.exports = { - ...unitJestConfig, - // Scope test discovery to this directory only. - testMatch: [ - path.join( ROOT_DIR, 'test/integration/**/*.test.[jt]s?(x)' ), - ], -}; diff --git a/test/integration/package.json b/test/integration/package.json index c93ac9de96b5bc..f4675c6fef8d26 100644 --- a/test/integration/package.json +++ b/test/integration/package.json @@ -20,16 +20,10 @@ "url": "https://github.com/WordPress/gutenberg/issues" }, "devDependencies": { - "@wordpress/scripts": "file:../../packages/scripts", "ajv": "^8.17.1", "fast-glob": "^3.2.7" }, "publishConfig": { "access": "public" - }, - "scripts": { - "test:integration": "wp-scripts test-unit-js --config jest.config.js", - "test:integration:watch": "npm run test:integration -- --watch", - "test:integration:debug": "wp-scripts --inspect-brk test-unit-js --runInBand --no-cache --verbose --config jest.config.js" } } From 5ca2575f2119d1dbd65bbd2b35d73b797055f3c4 Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Thu, 23 Apr 2026 18:59:29 +0530 Subject: [PATCH 5/6] chore: update package dependencies and add integration test documentation --- package-lock.json | 11 ++++++- package.json | 1 - test/integration/README.md | 58 +++++++++++++++++++++++++++++++++++ test/integration/package.json | 10 ++++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 test/integration/README.md diff --git a/package-lock.json b/package-lock.json index f0f95265ec5334..b2c476ebc07ddf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,7 +44,6 @@ "@types/uuid": "8.3.1", "@wordpress/build": "file:./packages/wp-build", "@wordpress/vips": "file:./packages/vips", - "ajv": "8.17.1", "babel-jest": "29.7.0", "babel-loader": "9.2.1", "babel-plugin-inline-json-import": "0.3.2", @@ -63378,6 +63377,16 @@ "version": "0.0.0", "license": "GPL-2.0-or-later", "devDependencies": { + "@testing-library/react": "^16.3.2", + "@testing-library/user-event": "^14.6.1", + "@wordpress/block-editor": "file:../../packages/block-editor", + "@wordpress/block-library": "file:../../packages/block-library", + "@wordpress/block-serialization-default-parser": "file:../../packages/block-serialization-default-parser", + "@wordpress/blocks": "file:../../packages/blocks", + "@wordpress/data": "file:../../packages/data", + "@wordpress/element": "file:../../packages/element", + "@wordpress/prettier-config": "file:../../packages/prettier-config", + "@wordpress/rich-text": "file:../../packages/rich-text", "ajv": "^8.17.1", "fast-glob": "^3.2.7" } diff --git a/package.json b/package.json index 10f3107610a806..1bdab52418cdaf 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,6 @@ "@types/uuid": "8.3.1", "@wordpress/build": "file:./packages/wp-build", "@wordpress/vips": "file:./packages/vips", - "ajv": "8.17.1", "babel-jest": "29.7.0", "babel-loader": "9.2.1", "babel-plugin-inline-json-import": "0.3.2", diff --git a/test/integration/README.md b/test/integration/README.md new file mode 100644 index 00000000000000..7c0979bff843ef --- /dev/null +++ b/test/integration/README.md @@ -0,0 +1,58 @@ +# Integration Tests + +This directory contains the integration test suite for the Gutenberg project, published as the `@wordpress/integration-tests` workspace package. + +## What Are Integration Tests? + +Unlike unit tests that test individual functions in isolation, these tests exercise multiple packages working together. They cover: + +| Test file | What it tests | +|---|---| +| `blocks-schema.test.js` | Validates all `block.json` files in the repo against the JSON schema | +| `theme-schema.test.js` | Validates all `theme.json` files in the repo against the JSON schema | +| `wp-env-schema.test.js` | Validates `.wp-env.json` against the JSON schema | +| `blocks-raw-handling.test.js` | Tests raw paste/HTML handling across the full block pipeline | +| `full-content/full-content.test.js` | Tests full block serialization round-trips using fixtures | +| `is-valid-block.test.js` | Tests block validation with editor hooks applied | +| `shortcode-converter.test.js` | Tests shortcode-to-block conversion | +| `non-matched-tags-handling.test.js` | Tests handling of unrecognized HTML tags during paste | + +## Running the Tests + +Integration tests run as part of the standard unit test command: + +```bash +npm run test:unit +``` + +To run only the integration tests: + +```bash +npm run test:unit -- test/integration +``` + +To run a specific integration test file: + +```bash +npm run test:unit -- test/integration/blocks-schema.test.js +``` + +## Fixtures + +The `fixtures/blocks/` directory contains serialized block fixtures used by `full-content.test.js` to verify that blocks serialize and parse correctly. + +To generate missing fixtures: + +```bash +npm run fixtures:generate +``` + +To regenerate all fixtures from scratch: + +```bash +npm run fixtures:regenerate +``` + +## Jest Configuration + +These tests reuse the Jest configuration from `test/unit/jest.config.js`. There is no separate Jest config in this directory — `test/unit`'s config sets `rootDir` to the repo root, which automatically discovers tests in this directory. diff --git a/test/integration/package.json b/test/integration/package.json index f4675c6fef8d26..2e8c07142bdc06 100644 --- a/test/integration/package.json +++ b/test/integration/package.json @@ -20,6 +20,16 @@ "url": "https://github.com/WordPress/gutenberg/issues" }, "devDependencies": { + "@testing-library/react": "^16.3.2", + "@testing-library/user-event": "^14.6.1", + "@wordpress/block-editor": "file:../../packages/block-editor", + "@wordpress/block-library": "file:../../packages/block-library", + "@wordpress/block-serialization-default-parser": "file:../../packages/block-serialization-default-parser", + "@wordpress/blocks": "file:../../packages/blocks", + "@wordpress/data": "file:../../packages/data", + "@wordpress/element": "file:../../packages/element", + "@wordpress/prettier-config": "file:../../packages/prettier-config", + "@wordpress/rich-text": "file:../../packages/rich-text", "ajv": "^8.17.1", "fast-glob": "^3.2.7" }, From 6db2777663caa9288b5ab3812335a5dcae2513bb Mon Sep 17 00:00:00 2001 From: USERSATOSHI Date: Mon, 27 Apr 2026 11:46:51 +0530 Subject: [PATCH 6/6] chore: clarify README about integration test suite and workspace package --- test/integration/README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/integration/README.md b/test/integration/README.md index 7c0979bff843ef..0cfd38d75a3b9b 100644 --- a/test/integration/README.md +++ b/test/integration/README.md @@ -1,6 +1,7 @@ # Integration Tests -This directory contains the integration test suite for the Gutenberg project, published as the `@wordpress/integration-tests` workspace package. +This directory contains the integration test suite for the Gutenberg project. +These tests live in the internal `@wordpress/integration-tests` workspace package, which is private and not published. ## What Are Integration Tests?