diff --git a/package-lock.json b/package-lock.json index a3bf11fcbc21ed..cc3e2c0c276a2f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "routes/*", "storybook", "test/e2e", + "test/integration", "test/performance", "test/storybook-playwright", "test/unit", @@ -42,7 +43,6 @@ "@wordpress/build": "file:./packages/wp-build", "@wordpress/eslint-tools": "file:./tools/eslint", "@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", @@ -20792,6 +20792,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 @@ -63541,6 +63545,25 @@ "filenamify": "^4.2.0" } }, + "test/integration": { + "name": "@wordpress/integration-tests", + "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" + } + }, "test/performance": { "name": "@wordpress/performance-tests", "version": "0.0.0", diff --git a/package.json b/package.json index ba53b20fc66065..e2143fbc38bfac 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,6 @@ "@wordpress/build": "file:./packages/wp-build", "@wordpress/eslint-tools": "file:./tools/eslint", "@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", @@ -243,6 +242,7 @@ "routes/*", "storybook", "test/e2e", + "test/integration", "test/performance", "test/storybook-playwright", "test/unit", diff --git a/test/integration/README.md b/test/integration/README.md new file mode 100644 index 00000000000000..0cfd38d75a3b9b --- /dev/null +++ b/test/integration/README.md @@ -0,0 +1,59 @@ +# Integration Tests + +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? + +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 new file mode 100644 index 00000000000000..2e8c07142bdc06 --- /dev/null +++ b/test/integration/package.json @@ -0,0 +1,39 @@ +{ + "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": { + "@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" + }, + "publishConfig": { + "access": "public" + } +}