@autifyhq/autify-cli-integration-test 0.5.0 → 0.7.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.
Files changed (52) hide show
  1. package/__recordings__/mobile%20build%20upload%20--json%20--workspace-id%3DnYmF1n%20android.apk/polly-proxy_3343057686/recording.har +59 -0
  2. package/__recordings__/mobile%20build%20upload%20--workspace-id%3DnYmF1n%20android.apk/polly-proxy_3343057686/recording.har +59 -0
  3. package/__recordings__/mobile%20test%20run%20--build-id%3D8DuzpG%20--wait%20https%3A%2F%2Fmobile-app.autify.com%2Fprojects%2FnYmF1n%2Ftest_plans%2FDEWt9g/polly-proxy_3343057686/recording.har +675 -0
  4. package/__recordings__/mobile%20test%20run%20--build-id%3D8DuzpG%20https%3A%2F%2Fmobile-app.autify.com%2Fprojects%2FnYmF1n%2Ftest_plans%2FDEWt9g/polly-proxy_3343057686/recording.har +60 -0
  5. package/__recordings__/mobile%20test%20run%20--build-path%3Dandroid.apk%20--wait%20https%3A%2F%2Fmobile-app.autify.com%2Fprojects%2FnYmF1n%2Ftest_plans%2FDEWt9g/polly-proxy_3343057686/recording.har +679 -0
  6. package/__recordings__/mobile%20test%20run%20--build-path%3Dandroid.apk%20https%3A%2F%2Fmobile-app.autify.com%2Fprojects%2FnYmF1n%2Ftest_plans%2FDEWt9g/polly-proxy_3343057686/recording.har +105 -0
  7. package/__recordings__/mobile%20test%20run%20--build-path%3Dios.app%20--wait%20https%3A%2F%2Fmobile-app.autify.com%2Fprojects%2FnYmF1n%2Ftest_plans%2FDPjteo/polly-proxy_3343057686/recording.har +6050 -0
  8. package/__recordings__/mobile%20test%20run%20--build-path%3Dios.app%20https%3A%2F%2Fmobile-app.autify.com%2Fprojects%2FnYmF1n%2Ftest_plans%2FDPjteo/polly-proxy_3343057686/recording.har +105 -0
  9. package/__recordings__/web%20test%20run%20--wait%20https%3A%2F%2Fapp.autify.com%2Fprojects%2F743%2Fscenarios%2F91437/polly-proxy_3343057686/recording.har +561 -0
  10. package/__recordings__/web%20test%20run%20https%3A%2F%2Fapp.autify.com%2Fprojects%2F743%2Fscenarios%2F91437/polly-proxy_3343057686/recording.har +17 -17
  11. package/__snapshots__/golden/mobileBuildUpload.test.js.snap +12 -0
  12. package/__snapshots__/golden/mobileBuildUploadJson.test.js.snap +14 -0
  13. package/__snapshots__/golden/mobileTestRun.test.js.snap +14 -0
  14. package/__snapshots__/golden/mobileTestRunAndroid.test.js.snap +15 -0
  15. package/__snapshots__/golden/mobileTestRunAndroidWait.test.js.snap +31 -0
  16. package/__snapshots__/golden/mobileTestRunIos.test.js.snap +15 -0
  17. package/__snapshots__/golden/mobileTestRunIosWait.test.js.snap +162 -0
  18. package/__snapshots__/golden/mobileTestRunWait.test.js.snap +31 -0
  19. package/__snapshots__/golden/webTestRun.test.js.snap +14 -0
  20. package/__snapshots__/golden/{cli.test.js.snap → webTestRunWait.test.js.snap} +6 -17
  21. package/dist/bin/autify-cli-integration-test.js +5 -1
  22. package/dist/bin/autify-with-proxy.js +9 -1
  23. package/dist/commands.d.ts +3 -0
  24. package/dist/commands.js +84 -0
  25. package/dist/test/golden/{cli.test.d.ts → mobileBuildUpload.test.d.ts} +0 -0
  26. package/dist/test/golden/mobileBuildUpload.test.js +5 -0
  27. package/dist/test/golden/mobileBuildUploadJson.test.d.ts +1 -0
  28. package/dist/test/golden/mobileBuildUploadJson.test.js +5 -0
  29. package/dist/test/golden/mobileTestRun.test.d.ts +1 -0
  30. package/dist/test/golden/mobileTestRun.test.js +5 -0
  31. package/dist/test/golden/mobileTestRunAndroid.test.d.ts +1 -0
  32. package/dist/test/golden/mobileTestRunAndroid.test.js +5 -0
  33. package/dist/test/golden/mobileTestRunAndroidWait.test.d.ts +1 -0
  34. package/dist/test/golden/mobileTestRunAndroidWait.test.js +5 -0
  35. package/dist/test/golden/mobileTestRunIos.test.d.ts +1 -0
  36. package/dist/test/golden/mobileTestRunIos.test.js +5 -0
  37. package/dist/test/golden/mobileTestRunIosWait.test.d.ts +1 -0
  38. package/dist/test/golden/mobileTestRunIosWait.test.js +5 -0
  39. package/dist/test/golden/mobileTestRunWait.test.d.ts +1 -0
  40. package/dist/test/golden/mobileTestRunWait.test.js +5 -0
  41. package/dist/test/golden/webTestRun.test.d.ts +1 -0
  42. package/dist/test/golden/webTestRun.test.js +5 -0
  43. package/dist/test/golden/webTestRunWait.test.d.ts +1 -0
  44. package/dist/test/golden/webTestRunWait.test.js +5 -0
  45. package/dist/test/helpers/execAutifyCli.js +4 -2
  46. package/dist/test/helpers/generateFakeApp.d.ts +1 -0
  47. package/dist/test/helpers/generateFakeApp.js +23 -0
  48. package/dist/test/helpers/testAutifyCliSnapshot.d.ts +1 -0
  49. package/dist/test/helpers/testAutifyCliSnapshot.js +11 -0
  50. package/package.json +8 -5
  51. package/__recordings__/web%20test%20run%20https%3A%2F%2Fapp.autify.com%2Fprojects%2F743%2Fscenarios%2F91437%20--wait/polly-proxy_3343057686/recording.har +0 -479
  52. package/dist/test/golden/cli.test.js +0 -12
@@ -0,0 +1,84 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.normalizeCommand = exports.androidBuildPath = exports.iosBuildPath = void 0;
4
+ exports.iosBuildPath = "ios.app";
5
+ exports.androidBuildPath = "android.apk";
6
+ const webTestScenarioUrl = "https://app.autify.com/projects/743/scenarios/91437";
7
+ const mobileAndroidTestPlanUrl = "https://mobile-app.autify.com/projects/nYmF1n/test_plans/DEWt9g";
8
+ const mobileIosTestPlanUrl = "https://mobile-app.autify.com/projects/nYmF1n/test_plans/DPjteo";
9
+ const mobileWorkspaceId = "nYmF1n";
10
+ const mobileAndroidBuildId = "8DuzpG";
11
+ const concatFlagAndValue = (args) => {
12
+ const newArgs = [];
13
+ let flag = null;
14
+ for (const arg of args) {
15
+ if (flag !== null) {
16
+ if (arg.startsWith("--")) {
17
+ newArgs.push(flag);
18
+ flag = arg;
19
+ continue;
20
+ }
21
+ else {
22
+ newArgs.push(`${flag}=${arg}`);
23
+ flag = null;
24
+ continue;
25
+ }
26
+ }
27
+ if (arg.startsWith("--")) {
28
+ flag = arg;
29
+ continue;
30
+ }
31
+ newArgs.push(arg);
32
+ }
33
+ if (flag !== null)
34
+ newArgs.push(flag);
35
+ return newArgs;
36
+ };
37
+ const replaceWebTestScenarioUrl = (arg) => {
38
+ const regExp = /^https:\/\/app.autify.com\/projects\/\d+\/scenarios\/\d+\/?$/;
39
+ return regExp.test(arg) ? webTestScenarioUrl : arg;
40
+ };
41
+ const replaceMobileTetsPlanUrl = (arg, os) => {
42
+ const regExp = /^https:\/\/mobile-app.autify.com\/projects\/[^/]+\/test_plans\/[^/]+\/?$/;
43
+ if (regExp.test(arg)) {
44
+ if (os === "android")
45
+ return mobileAndroidTestPlanUrl;
46
+ if (os === "ios")
47
+ return mobileIosTestPlanUrl;
48
+ }
49
+ return arg;
50
+ };
51
+ const replaceMobileWorkspaceId = (arg) => arg.startsWith("--workspace-id=")
52
+ ? `--workspace-id=${mobileWorkspaceId}`
53
+ : arg;
54
+ const replaceMobileAndroidBuildId = (arg) => arg.startsWith("--build-id=") ? `--build-id=${mobileAndroidBuildId}` : arg;
55
+ const replaceMobileAndroidBuildPath = (arg) => arg.replace(/^(--[^=]+=)?.+\.apk$/, `$1${exports.androidBuildPath}`);
56
+ const replaceMobileIosBuildPath = (arg) => arg.replace(/^(--[^=]+=)?.+\.app$/, `$1${exports.iosBuildPath}`);
57
+ const sortParameters = (args) => {
58
+ // Currently assuming the first three arguments are for command and the rest are parameters.
59
+ const command = args.slice(0, 3);
60
+ const parameters = args.slice(3);
61
+ return [...command, ...parameters.sort()];
62
+ };
63
+ // Assuming ios command contains .app
64
+ const isIos = (args) => args.some((a) => a.endsWith(".app"));
65
+ const replaceConstants = (args) => {
66
+ if (args[0] === "web") {
67
+ return args.map((a) => replaceWebTestScenarioUrl(a));
68
+ }
69
+ if (args[0] === "mobile") {
70
+ return isIos(args)
71
+ ? args
72
+ .map((a) => replaceMobileWorkspaceId(a))
73
+ .map((a) => replaceMobileTetsPlanUrl(a, "ios"))
74
+ .map((a) => replaceMobileIosBuildPath(a))
75
+ : args
76
+ .map((a) => replaceMobileWorkspaceId(a))
77
+ .map((a) => replaceMobileTetsPlanUrl(a, "android"))
78
+ .map((a) => replaceMobileAndroidBuildId(a))
79
+ .map((a) => replaceMobileAndroidBuildPath(a));
80
+ }
81
+ return args;
82
+ };
83
+ const normalizeCommand = (args) => replaceConstants(sortParameters(concatFlagAndValue(args)));
84
+ exports.normalizeCommand = normalizeCommand;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile build upload /path/to/app-debug.apk --workspace-id AAA");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile build upload /path/to/app-debug.apk --workspace-id AAA --json");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-id CCC");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/app-debug.apk");
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/app-debug.apk --wait");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/MyApp.app");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-path /path/to/MyApp.app --wait");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("mobile test run https://mobile-app.autify.com/projects/AAA/test_plans/BBB --build-id CCC --wait");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("web test run https://app.autify.com/projects/0000/scenarios/0000");
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const testAutifyCliSnapshot_1 = require("../helpers/testAutifyCliSnapshot");
5
+ (0, testAutifyCliSnapshot_1.testAutifyCliSnapshot)("web test run https://app.autify.com/projects/0000/scenarios/0000 --wait");
@@ -1,15 +1,17 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.execAutifyCli = void 0;
4
+ const tslib_1 = require("tslib");
4
5
  /* eslint-disable unicorn/filename-case */
5
6
  const node_util_1 = require("node:util");
6
7
  const node_child_process_1 = require("node:child_process");
8
+ const strip_ansi_1 = tslib_1.__importDefault(require("strip-ansi"));
7
9
  const execAutifyCli = async (args) => {
8
10
  const command = `autify-with-proxy ${args}`;
9
11
  const { stdout, stderr } = await (0, node_util_1.promisify)(node_child_process_1.exec)(command);
10
12
  return {
11
- stdout: stdout.replace(/\d{2}:\d{2}:\d{2}/g, "HH:MM:SS"),
12
- stderr: stderr,
13
+ stdout: (0, strip_ansi_1.default)(stdout).replace(/\d{2}:\d{2}:\d{2}/g, "HH:MM:SS"),
14
+ stderr: (0, strip_ansi_1.default)(stderr),
13
15
  };
14
16
  };
15
17
  exports.execAutifyCli = execAutifyCli;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ /* eslint-disable unicorn/filename-case */
4
+ const node_fs_1 = require("node:fs");
5
+ const node_path_1 = require("node:path");
6
+ const commands_1 = require("../../commands");
7
+ // https://commons.wikimedia.org/wiki/File:Transparent.gif
8
+ const tinyBinary = Buffer.from("R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7", "base64");
9
+ // Generate fake build files if not exiting.
10
+ // For recording, you should setup the real files on the same paths.
11
+ if ((0, node_fs_1.existsSync)(commands_1.iosBuildPath)) {
12
+ console.log(`${commands_1.iosBuildPath} already exists.`);
13
+ }
14
+ else {
15
+ (0, node_fs_1.mkdirSync)(commands_1.iosBuildPath); // *.app is a directory
16
+ (0, node_fs_1.writeFileSync)((0, node_path_1.join)(commands_1.iosBuildPath, "ios"), tinyBinary); // Add a fake binary file
17
+ }
18
+ if ((0, node_fs_1.existsSync)(commands_1.androidBuildPath)) {
19
+ console.log(`${commands_1.androidBuildPath} already exists.`);
20
+ }
21
+ else {
22
+ (0, node_fs_1.writeFileSync)(commands_1.androidBuildPath, tinyBinary); // Create a fake binary file
23
+ }
@@ -0,0 +1 @@
1
+ export declare const testAutifyCliSnapshot: (command: string) => void;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.testAutifyCliSnapshot = void 0;
4
+ /* eslint-disable unicorn/filename-case */
5
+ const execAutifyCli_1 = require("../helpers/execAutifyCli");
6
+ const testAutifyCliSnapshot = (command) => {
7
+ test(`autify ${command}`, async () => {
8
+ expect(await (0, execAutifyCli_1.execAutifyCli)(command)).toMatchSnapshot();
9
+ }, 300000);
10
+ };
11
+ exports.testAutifyCliSnapshot = testAutifyCliSnapshot;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autifyhq/autify-cli-integration-test",
3
- "version": "0.5.0",
3
+ "version": "0.7.0",
4
4
  "description": "Autify Command Line Interface (CLI) Integration Test",
5
5
  "author": "Autify",
6
6
  "bin": {
@@ -25,16 +25,18 @@
25
25
  "@pollyjs/adapter-node-http": "^6.0.5",
26
26
  "@pollyjs/core": "^6.0.5",
27
27
  "@pollyjs/persister-fs": "^6.0.5",
28
+ "cross-env": "^7.0.3",
28
29
  "express": "^4.18.1",
29
30
  "http-proxy-middleware": "^2.0.6",
30
31
  "jest": "^28.1.3",
32
+ "strip-ansi": "^6.0.0",
31
33
  "tslib": "^2.4.0",
32
34
  "which": "^2.0.2"
33
35
  },
34
36
  "devDependencies": {
35
37
  "@types/express": "^4.17.13",
36
- "@types/jest": "^28.1.6",
37
- "@types/node": "^16.11.47",
38
+ "@types/jest": "^28.1.7",
39
+ "@types/node": "^16.11.52",
38
40
  "@types/which": "^2.0.1",
39
41
  "shx": "^0.3.4",
40
42
  "ts-node": "^10.9.1",
@@ -43,8 +45,9 @@
43
45
  "scripts": {
44
46
  "build": "shx rm -rf dist && tsc -b",
45
47
  "prepack": "npm run build",
46
- "test": "jest dist/test",
47
- "test:record": "AUTIFY_POLLY_RECORD=1 npm run test -- --updateSnapshot"
48
+ "generate-fake-app": "node dist/test/helpers/generateFakeApp.js",
49
+ "test": "npm run generate-fake-app && cross-env AUTIFY_TEST_WAIT_INTERVAL_SECOND=0 jest dist/test",
50
+ "test:record": "AUTIFY_POLLY_RECORD=1 jest dist/test --updateSnapshot"
48
51
  },
49
52
  "engines": {
50
53
  "node": ">=12.0.0"