@atomicsmash/init-testing 1.1.0-beta.5 → 2.0.0-beta.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/cli.js CHANGED
@@ -5,16 +5,12 @@ import { resolve as pathResolve, relative as pathRelative } from "node:path";
5
5
  import yargs from "yargs";
6
6
  import { hideBin } from "yargs/helpers";
7
7
  import { PackageManager } from "./utils.js";
8
- const packageManager = new PackageManager(await import(`${process.cwd()}/package.json`, {
9
- with: { type: "json" },
10
- })
8
+ const packageManager = new PackageManager(await import(`${process.cwd()}/package.json`, { with: { type: "json" } })
11
9
  .then((module) => module.default)
12
10
  .catch((error) => {
13
11
  console.log({ error });
14
12
  throw new Error("Unable to find package.json in your cwd. Make sure you're running this command in the right folder.");
15
- }), await import(`${process.cwd()}/package-lock.json`, {
16
- with: { type: "json" },
17
- })
13
+ }), await import(`${process.cwd()}/package-lock.json`, { with: { type: "json" } })
18
14
  .then((module) => module.default)
19
15
  .catch((error) => {
20
16
  console.log({ error });
@@ -82,10 +78,7 @@ for (const dirent of copyFiles) {
82
78
  await mkdir(`${process.cwd()}/${relativePath}`.slice(0, -1), {
83
79
  recursive: true,
84
80
  });
85
- await writeFile(`${process.cwd()}/${relativePath}${dirent.name}`, data, {
86
- encoding: "utf8",
87
- flag: argv.overwriteFiles ? "w" : "wx",
88
- });
81
+ await writeFile(`${process.cwd()}/${relativePath}${dirent.name}`, data, { encoding: "utf8", flag: argv.overwriteFiles ? "w" : "wx" });
89
82
  return `${relativePath}${dirent.name} copied successfully.`;
90
83
  })
91
84
  .catch((error) => `${relativePath}${dirent.name} failed to copy. Error: ${error}`));
@@ -93,9 +86,10 @@ for (const dirent of copyFiles) {
93
86
  await Promise.all([
94
87
  Promise.allSettled([
95
88
  packageManager.ensurePackageIsInstalled("@atomicsmash/test-utils", {
96
- packageConstraint: "^1.0.0",
89
+ packageConstraint: "^4.0.0",
97
90
  type: "dev",
98
91
  }),
92
+ packageManager.ensurePackageIsInstalled("@atomicsmash/wordpress-tests-helper", { packageConstraint: "^1.0.0", type: "dev" }),
99
93
  packageManager.ensurePackageIsInstalled("@playwright/test", {
100
94
  packageConstraint: "^1.0.0",
101
95
  type: "dev",
@@ -121,7 +115,7 @@ await Promise.all([
121
115
  },
122
116
  !hasRootTSConfig
123
117
  ? packageManager.ensurePackageIsInstalled("typescript", {
124
- packageConstraint: "^5.4.0",
118
+ packageConstraint: "~5.8.0",
125
119
  type: "dev",
126
120
  })
127
121
  : false,
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAqBA,qBAAa,cAAc;IAC1B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,eAAe,CAAkB;IACzC,QAAQ;QACP;;WAEG;;QAEH;;WAEG;;QAEH;;WAEG;;MAEF;gBAEU,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IAK1D;;OAEG;IACH,WAAW;IA2BX;;;;OAIG;IACH,iBAAiB,CAAC,WAAW,EAAE,MAAM;;;;;;;;;IA2BrC;;;;;;;;OAQG;IACG,wBAAwB,CAC7B,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACT,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;KACxB;CAkGF"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAqBA,qBAAa,cAAc;IAC1B,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,eAAe,CAAkB;IACzC,QAAQ;QACP;;WAEG;eACU,MAAM,EAAE;QACrB;;WAEG;iBACY,MAAM,EAAE;QACvB;;WAEG;oBACe,MAAM,EAAE;MACzB;gBAEU,WAAW,EAAE,OAAO,EAAE,eAAe,EAAE,OAAO;IAK1D;;OAEG;IACH,WAAW;IA2BX;;;;OAIG;IACH,iBAAiB,CAAC,WAAW,EAAE,MAAM;;;;;;;;;IA2BrC;;;;;;;;OAQG;IACG,wBAAwB,CAC7B,WAAW,EAAE,MAAM,EACnB,OAAO,CAAC,EAAE;QACT,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,IAAI,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;KACxB;CAkGF"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@atomicsmash/init-testing",
3
3
  "type": "module",
4
- "version": "1.1.0-beta.5",
4
+ "version": "2.0.0-beta.0",
5
5
  "description": "Allow us to easily add automated testing setup to any npm setup.",
6
6
  "keywords": [
7
7
  "atomic",
@@ -1,9 +1,10 @@
1
1
  import {
2
2
  doLighthouseTest,
3
+ lighthouseTest,
3
4
  checkPrivilegedPages,
4
5
  checkForLoremIpsum,
5
6
  } from "@atomicsmash/test-utils";
6
- import { test, lighthouseTest, pagesToTest } from "../playwright-utils.mjs";
7
+ import { test, pagesToTest } from "../playwright-utils.mjs";
7
8
 
8
9
  test(
9
10
  "privileged pages of the site to ensure non-logged in users can't access them",
@@ -1,25 +1,9 @@
1
- import type {
2
- AuthenticatePageFunction,
3
- PageList,
4
- } from "@atomicsmash/test-utils";
5
- import type { Page } from "@playwright/test";
6
- import { getLighthouseTest } from "@atomicsmash/test-utils";
1
+ import type { PageList } from "@atomicsmash/test-utils";
2
+ import type { WordPressAdminInteraction } from "@atomicsmash/wordpress-tests-helper";
7
3
  import { test as base } from "@playwright/test";
8
4
  import { testData } from "./fixtures/testData.mjs";
9
5
 
10
- /**
11
- * Fixtures
12
- */
13
- const logInUser: AuthenticatePageFunction = async function ({ page }, use) {
14
- // Do any actions here to log a user in so you can access logged in areas of the site.
15
- // This is useful for testing my account pages, etc.
16
- await use(page);
17
- };
18
-
19
- type CustomFixtures = {
20
- testData: typeof testData;
21
- authenticatedPage: Page;
22
- };
6
+ type CustomFixtures = { testData: typeof testData };
23
7
 
24
8
  export const test = base.extend<CustomFixtures>({
25
9
  testData: async (
@@ -30,13 +14,16 @@ export const test = base.extend<CustomFixtures>({
30
14
  // Use the fixture value in the test.
31
15
  await use(testData);
32
16
  },
33
- authenticatedPage: [logInUser, { scope: "test" }],
34
17
  });
35
18
 
36
- export const lighthouseTest = getLighthouseTest(logInUser);
37
- export const { expect } = test; // re-export expect to cleanup imports in tests
19
+ export type TestFunctionType = Parameters<typeof base>[2];
38
20
  export { checkAccessibility } from "@atomicsmash/test-utils";
39
21
 
40
22
  export const pagesToTest = [
41
23
  // hover over PageList to see the format required for each page
42
24
  ] satisfies PageList;
25
+
26
+ // Used to set the WP version for WordPressAdminInteraction. Supports major dot minor syntax, or "latest"
27
+ export const CURRENT_WORDPRESS_VERSION: ConstructorParameters<
28
+ typeof WordPressAdminInteraction
29
+ >[2] = "6.7";