@gravity-ui/playwright-tools 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/README.md +1 -0
  2. package/actions/expect-request/matchers/compare/DiffPrinter.js +16 -11
  3. package/component-tests/fixtures/index.d.ts +2 -0
  4. package/component-tests/fixtures/index.js +6 -0
  5. package/component-tests/index.d.ts +4 -0
  6. package/component-tests/index.js +8 -0
  7. package/{storybook → component-tests/utils/create-smoke-scenarios}/create-smoke-scenarios.js +4 -2
  8. package/component-tests/utils/index.d.ts +2 -0
  9. package/component-tests/utils/index.js +5 -0
  10. package/fixtures/index.d.ts +0 -2
  11. package/fixtures/index.js +1 -4
  12. package/har/addFlushTransform.js +1 -0
  13. package/package.json +11 -9
  14. /package/{fixtures → component-tests/fixtures}/mount/constants.d.ts +0 -0
  15. /package/{fixtures → component-tests/fixtures}/mount/constants.js +0 -0
  16. /package/{fixtures → component-tests/fixtures}/mount/index.d.ts +0 -0
  17. /package/{fixtures → component-tests/fixtures}/mount/index.js +0 -0
  18. /package/{fixtures → component-tests/fixtures}/mount/mount-fixture.d.ts +0 -0
  19. /package/{fixtures → component-tests/fixtures}/mount/mount-fixture.js +0 -0
  20. /package/{fixtures → component-tests/fixtures}/mount/types.d.ts +0 -0
  21. /package/{fixtures → component-tests/fixtures}/mount/types.js +0 -0
  22. /package/{storybook → component-tests/utils/create-smoke-scenarios}/create-smoke-scenarios.d.ts +0 -0
  23. /package/{storybook → component-tests/utils/create-smoke-scenarios}/index.d.ts +0 -0
  24. /package/{storybook → component-tests/utils/create-smoke-scenarios}/index.js +0 -0
  25. /package/{storybook → component-tests/utils/create-smoke-scenarios}/types.d.ts +0 -0
  26. /package/{storybook → component-tests/utils/create-smoke-scenarios}/types.js +0 -0
package/README.md CHANGED
@@ -14,6 +14,7 @@ import { matchScreenshot } from 'playwright-tools/actions';
14
14
 
15
15
  - [actions](./actions/README.md) — Browser actions.
16
16
  - [auth/storage](./auth/storage/README.md) — Authentication functions for saving and restoring browser storage snapshots.
17
+ - [component-tests](./component-tests/README.md) — Utilities and fixtures for Playwright Component Testing.
17
18
  - [fixtures](./fixtures/README.md) — Fixtures for passing values into tests.
18
19
  - [har](./har/README.md) — Functions for working with HAR request dumps.
19
20
  - [config](./config/README.md) — Base configuration.
@@ -34,34 +34,39 @@ class DiffPrinter {
34
34
  const pathAnnotations = filteredLog.reduce((acc, logItem) => {
35
35
  const { context, type } = logItem;
36
36
  const path = this.makePathFromContext(context);
37
- if (!acc[path]) {
38
- acc[path] = [];
39
- }
37
+ const existingAnnotations = acc[path] ?? [];
38
+ let newAnnotation;
40
39
  if (type === constants_1.DiffType.ValueMismatch) {
41
40
  if (logItem.expected === undefined && logItem.received !== undefined) {
42
- acc[path].push({ type: constants_1.PathAnnotationType.ObjectExtraProperty });
41
+ newAnnotation = { type: constants_1.PathAnnotationType.ObjectExtraProperty };
43
42
  }
44
43
  else {
45
- acc[path].push({
44
+ newAnnotation = {
46
45
  type: constants_1.PathAnnotationType.ValueMismatch,
47
46
  expected: logItem.expected,
48
47
  received: logItem.received,
49
- });
48
+ };
50
49
  }
51
50
  }
52
51
  else if (type === constants_1.DiffType.ObjectMissingProperty) {
53
- acc[path].push({
52
+ newAnnotation = {
54
53
  type: constants_1.PathAnnotationType.ObjectMissingProperty,
55
54
  expected: logItem.expected,
56
- });
55
+ };
57
56
  }
58
57
  else if (type === constants_1.DiffType.ArrayMissingValue) {
59
- acc[path].push({
58
+ newAnnotation = {
60
59
  type: constants_1.PathAnnotationType.ArrayMissingValue,
61
60
  expected: logItem.expected,
62
- });
61
+ };
63
62
  }
64
- return acc;
63
+ if (!newAnnotation) {
64
+ return acc;
65
+ }
66
+ return {
67
+ ...acc,
68
+ [path]: [...existingAnnotations, newAnnotation],
69
+ };
65
70
  }, {});
66
71
  return (0, print_json_diff_1.printJsonDiff)({ json: side === 'left' ? this.left : this.right, pathAnnotations });
67
72
  }
@@ -0,0 +1,2 @@
1
+ export type { MountFn, MountTestArgs } from './mount';
2
+ export { mountFixture, TEST_WRAPPER_CLASS } from './mount';
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEST_WRAPPER_CLASS = exports.mountFixture = void 0;
4
+ var mount_1 = require("./mount");
5
+ Object.defineProperty(exports, "mountFixture", { enumerable: true, get: function () { return mount_1.mountFixture; } });
6
+ Object.defineProperty(exports, "TEST_WRAPPER_CLASS", { enumerable: true, get: function () { return mount_1.TEST_WRAPPER_CLASS; } });
@@ -0,0 +1,4 @@
1
+ export type { Cases, CasesWithName, Scenario, ScenarioName } from './utils';
2
+ export { createSmokeScenarios } from './utils';
3
+ export type { MountFn, MountTestArgs } from './fixtures';
4
+ export { mountFixture, TEST_WRAPPER_CLASS } from './fixtures';
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TEST_WRAPPER_CLASS = exports.mountFixture = exports.createSmokeScenarios = void 0;
4
+ var utils_1 = require("./utils");
5
+ Object.defineProperty(exports, "createSmokeScenarios", { enumerable: true, get: function () { return utils_1.createSmokeScenarios; } });
6
+ var fixtures_1 = require("./fixtures");
7
+ Object.defineProperty(exports, "mountFixture", { enumerable: true, get: function () { return fixtures_1.mountFixture; } });
8
+ Object.defineProperty(exports, "TEST_WRAPPER_CLASS", { enumerable: true, get: function () { return fixtures_1.TEST_WRAPPER_CLASS; } });
@@ -35,12 +35,14 @@ const createSmokeScenarios = (baseProps, propsCases, options) => {
35
35
  }
36
36
  else {
37
37
  propCases.forEach((propCase) => {
38
- const hasStringifyMethod = propCase?.toString;
38
+ const hasStringifyMethod = propCase !== null &&
39
+ propCase !== undefined &&
40
+ typeof propCase.toString === 'function';
39
41
  if (!hasStringifyMethod) {
40
42
  throw new Error('The case value does not have a method "toString", use case with name.');
41
43
  }
42
44
  scenarios.push([
43
- `${scenarioName}[${propName}: ${propCase?.toString()}]`,
45
+ `${scenarioName}[${propName}: ${String(propCase)}]`,
44
46
  {
45
47
  ...baseProps,
46
48
  [propName]: propCase,
@@ -0,0 +1,2 @@
1
+ export type { Cases, CasesWithName, Scenario, ScenarioName } from './create-smoke-scenarios';
2
+ export { createSmokeScenarios } from './create-smoke-scenarios';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSmokeScenarios = void 0;
4
+ var create_smoke_scenarios_1 = require("./create-smoke-scenarios");
5
+ Object.defineProperty(exports, "createSmokeScenarios", { enumerable: true, get: function () { return create_smoke_scenarios_1.createSmokeScenarios; } });
@@ -8,5 +8,3 @@ export type { ExpectScreenshotFn, ExpectScreenshotTestArgs, ExpectScreenshotFixt
8
8
  export { expectScreenshotFixtureBuilder } from './expect-screenshot';
9
9
  export type { GlobalSettingsFixturesBuilderParams, GlobalSettingsTestArgs, GlobalSettingsWorkerArgs, } from './global-settings';
10
10
  export { globalSettingsFixturesBuilder } from './global-settings';
11
- export type { MountFn, MountTestArgs } from './mount';
12
- export { mountFixture, TEST_WRAPPER_CLASS } from './mount';
package/fixtures/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.TEST_WRAPPER_CLASS = exports.mountFixture = exports.globalSettingsFixturesBuilder = exports.expectScreenshotFixtureBuilder = exports.expectRequest = exports.mockNetworkFixtureBuilder = exports.testSlug = void 0;
3
+ exports.globalSettingsFixturesBuilder = exports.expectScreenshotFixtureBuilder = exports.expectRequest = exports.mockNetworkFixtureBuilder = exports.testSlug = void 0;
4
4
  var testSlug_1 = require("./testSlug");
5
5
  Object.defineProperty(exports, "testSlug", { enumerable: true, get: function () { return testSlug_1.testSlug; } });
6
6
  var mock_network_1 = require("./mock-network");
@@ -11,6 +11,3 @@ var expect_screenshot_1 = require("./expect-screenshot");
11
11
  Object.defineProperty(exports, "expectScreenshotFixtureBuilder", { enumerable: true, get: function () { return expect_screenshot_1.expectScreenshotFixtureBuilder; } });
12
12
  var global_settings_1 = require("./global-settings");
13
13
  Object.defineProperty(exports, "globalSettingsFixturesBuilder", { enumerable: true, get: function () { return global_settings_1.globalSettingsFixturesBuilder; } });
14
- var mount_1 = require("./mount");
15
- Object.defineProperty(exports, "mountFixture", { enumerable: true, get: function () { return mount_1.mountFixture; } });
16
- Object.defineProperty(exports, "TEST_WRAPPER_CLASS", { enumerable: true, get: function () { return mount_1.TEST_WRAPPER_CLASS; } });
@@ -6,6 +6,7 @@ const getPlaywrightCoreModule_1 = require("./getPlaywrightCoreModule");
6
6
  function wrapHarRecorderMethods(HarRecorder, transform) {
7
7
  const originalFlush = HarRecorder.prototype.flush;
8
8
  if (originalFlush) {
9
+ // eslint-disable-next-line no-param-reassign -- intentional prototype monkey-patching
9
10
  HarRecorder.prototype.flush = function flush() {
10
11
  if (transform) {
11
12
  // Transform requests when transform function is present
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/playwright-tools",
3
- "version": "0.9.0",
3
+ "version": "0.9.2",
4
4
  "description": "Tools for Playwright Test",
5
5
  "keywords": [
6
6
  "playwright",
@@ -18,10 +18,10 @@
18
18
  "files": [
19
19
  "/actions/**/*.*(js|d.ts)",
20
20
  "/auth/**/*.*(js|d.ts)",
21
+ "/component-tests/**/*.*(js|d.ts)",
21
22
  "/data/**/*.*(js|d.ts)",
22
23
  "/fixtures/**/*.*(js|d.ts)",
23
24
  "/har/**/*.*(js|d.ts)",
24
- "/storybook/**/*.*(js|d.ts)",
25
25
  "/utils/**/*.*(js|d.ts)",
26
26
  "!/**/__tests__"
27
27
  ],
@@ -36,6 +36,11 @@
36
36
  "import": "./auth/storage/index.js",
37
37
  "require": "./auth/storage/index.js"
38
38
  },
39
+ "./component-tests": {
40
+ "types": "./component-tests/index.d.ts",
41
+ "import": "./component-tests/index.js",
42
+ "require": "./component-tests/index.js"
43
+ },
39
44
  "./data": {
40
45
  "types": "./data/index.d.ts",
41
46
  "import": "./data/index.js",
@@ -51,11 +56,6 @@
51
56
  "import": "./har/index.js",
52
57
  "require": "./har/index.js"
53
58
  },
54
- "./storybook": {
55
- "types": "./storybook/index.d.ts",
56
- "import": "./storybook/index.js",
57
- "require": "./storybook/index.js"
58
- },
59
59
  "./utils": {
60
60
  "types": "./utils/index.d.ts",
61
61
  "import": "./utils/index.js",
@@ -65,7 +65,7 @@
65
65
  "scripts": {
66
66
  "prepare": "husky",
67
67
  "build": "tsc",
68
- "clean": "find actions auth data fixtures har storybook utils -type f ! -name '.eslintrc.js' \\( -name '*.js' -o -name '*.d.ts' \\) -delete",
68
+ "clean": "find actions auth component-tests data fixtures har utils -type f ! -name '.eslintrc.js' \\( -name '*.js' -o -name '*.d.ts' \\) -delete",
69
69
  "typecheck": "tsc --noEmit",
70
70
  "lint": "eslint --ext .ts ./",
71
71
  "test": "jest --colors --config=jest.config.js",
@@ -100,7 +100,9 @@
100
100
  },
101
101
  "peerDependencies": {
102
102
  "@playwright/experimental-ct-react": "^1.22",
103
- "@playwright/test": "^1.22"
103
+ "@playwright/test": "^1.22",
104
+ "react": "^17.0.0 || ^18.0.0 || ^19.0.0",
105
+ "react-dom": "^17.0.0 || ^18.0.0 || ^19.0.0"
104
106
  },
105
107
  "engines": {
106
108
  "node": ">=20"