@argos-ci/playwright 3.4.2 → 3.5.0

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.
package/dist/index.d.ts CHANGED
@@ -48,4 +48,8 @@ name: string,
48
48
  * Options for the screenshot.
49
49
  */
50
50
  options?: ArgosScreenshotOptions): Promise<void>;
51
- export { ArgosScreenshotOptions, argosScreenshot };
51
+ /**
52
+ * Get the CSP script hash.
53
+ */
54
+ declare function getCSPScriptHash(): string;
55
+ export { ArgosScreenshotOptions, argosScreenshot, getCSPScriptHash };
package/dist/index.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  import { mkdir } from 'node:fs/promises';
2
2
  import { relative, resolve, dirname } from 'node:path';
3
+ import { createHash } from 'node:crypto';
3
4
  import { resolveViewport, getGlobalScript } from '@argos-ci/browser';
4
5
  import { getGitRepositoryPath, readVersionFromPackage, getScreenshotName, validateThreshold, writeMetadata, getMetadataPath } from '@argos-ci/util';
5
6
  import { createRequire } from 'node:module';
@@ -81,10 +82,11 @@ const screenshotFolder = "./screenshots";
81
82
  * Inject Argos script into the page.
82
83
  */ async function injectArgos(page) {
83
84
  const injected = await page.evaluate(()=>typeof window.__ARGOS__ !== "undefined");
84
- if (injected) return;
85
- await page.addScriptTag({
86
- content: getGlobalScript()
87
- });
85
+ if (!injected) {
86
+ await page.addScriptTag({
87
+ content: getGlobalScript()
88
+ });
89
+ }
88
90
  }
89
91
  async function getTestInfo() {
90
92
  try {
@@ -274,5 +276,11 @@ function getViewportSize(page) {
274
276
  }
275
277
  await teardown();
276
278
  }
279
+ /**
280
+ * Get the CSP script hash.
281
+ */ function getCSPScriptHash() {
282
+ const hash = createHash("sha256").update(getGlobalScript()).digest("base64");
283
+ return `'sha256-${hash}'`;
284
+ }
277
285
 
278
- export { argosScreenshot };
286
+ export { argosScreenshot, getCSPScriptHash };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@argos-ci/playwright",
3
3
  "description": "Visual testing solution to avoid visual regression. Playwright commands and utilities for Argos visual testing.",
4
- "version": "3.4.2",
4
+ "version": "3.5.0",
5
5
  "author": "Smooth Code",
6
6
  "license": "MIT",
7
7
  "repository": {
@@ -61,5 +61,5 @@
61
61
  "test": "pnpm exec -- playwright test",
62
62
  "e2e": "UPLOAD_TO_ARGOS=true pnpm run test"
63
63
  },
64
- "gitHead": "4ca78028dd9d50f8c076ca498ea3a0b284ff4934"
64
+ "gitHead": "7043d16620c7941f85e20ddf8135f72fb61bb42d"
65
65
  }