@autifyhq/autify-cli 0.28.0 → 0.29.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/README.md CHANGED
@@ -723,7 +723,7 @@ ARGUMENTS
723
723
 
724
724
  FLAGS
725
725
  -n, --name=<value> [Only for test scenario] Name of the test execution.
726
- -r, --url-replacements=<value>... URL replacements. Example: http://example.com=http://example.net
726
+ -r, --url-replacements=<value>... URL replacements. Example: "http://example.com http://example.net"
727
727
  -t, --timeout=<value> [default: 300] Timeout seconds when waiting for the finish of the
728
728
  test execution.
729
729
  -v, --verbose Verbose output
@@ -766,8 +766,8 @@ EXAMPLES
766
766
 
767
767
  With URL replacements:
768
768
 
769
- $ autify web test run https://app.autify.com/projects/0000/scenarios/0000 -r \
770
- http://example.com=http://example.net -r http://example.org=http://example.net
769
+ $ autify web test run https://app.autify.com/projects/0000/scenarios/0000 -r "http://example.com \
770
+ http://example.net" -r "http://example.org http://example.net"
771
771
 
772
772
  Run a test with specifying the execution name:
773
773
 
package/bin/dev CHANGED
@@ -6,12 +6,16 @@ const path = require("path");
6
6
  const project = path.join(__dirname, "..", "tsconfig.json");
7
7
 
8
8
  // In dev mode -> use ts-node and dev plugins
9
- process.env.NODE_ENV = "development";
9
+ // When `bin/dev` is invoked in integration-test it'll be "test"
10
+ process.env.NODE_ENV ||= "development";
10
11
 
11
12
  require("ts-node").register({ project });
12
13
 
13
14
  // In dev mode, always show stack traces
14
- oclif.settings.debug = true;
15
+ // In test mode, stack traces shouldn't appeared in snapshot
16
+ if (process.env.NODE_ENV === "development") {
17
+ oclif.settings.debug = true;
18
+ }
15
19
 
16
20
  // Start the CLI
17
21
  oclif
@@ -25,4 +25,5 @@ export default class WebTestRun extends Command {
25
25
  "scenario-or-test-plan-url": import("@oclif/core/lib/interfaces/parser").Arg<string, Record<string, unknown>>;
26
26
  };
27
27
  run(): Promise<void>;
28
+ private parseUrlReplacements;
28
29
  }
@@ -10,14 +10,6 @@ const errors_1 = require("@oclif/errors");
10
10
  const parseAutifyTestUrl_1 = require("../../../autify/web/parseAutifyTestUrl");
11
11
  const ClientManager_1 = require("../../../autify/connect/client-manager/ClientManager");
12
12
  const getWebClient_1 = require("../../../autify/web/getWebClient");
13
- const parseUrlReplacements = (urlReplacements) => {
14
- return urlReplacements.map((s) => {
15
- // eslint-disable-next-line camelcase
16
- const [pattern_url, replacement_url] = s.split("=");
17
- // eslint-disable-next-line camelcase
18
- return { pattern_url, replacement_url };
19
- });
20
- };
21
13
  const urlReplacementsToString = (urlReplacements) => {
22
14
  return urlReplacements
23
15
  .map((urlReplacement) => {
@@ -38,7 +30,7 @@ class WebTestRun extends core_1.Command {
38
30
  // eslint-disable-next-line camelcase
39
31
  device_type: flags["device-type"],
40
32
  };
41
- const urlReplacements = parseUrlReplacements((_a = flags["url-replacements"]) !== null && _a !== void 0 ? _a : []);
33
+ const urlReplacements = this.parseUrlReplacements((_a = flags["url-replacements"]) !== null && _a !== void 0 ? _a : []);
42
34
  if (urlReplacements.length > 0)
43
35
  this.log(`${node_emoji_1.default.get("memo")} Using URL replacements: ${urlReplacementsToString(urlReplacements)}`);
44
36
  const { configDir, cacheDir, userAgent } = this.config;
@@ -125,6 +117,33 @@ class WebTestRun extends core_1.Command {
125
117
  throw error;
126
118
  }
127
119
  }
120
+ parseUrlReplacements(urlReplacements) {
121
+ return urlReplacements.map((s) => {
122
+ // eslint-disable-next-line camelcase
123
+ let pattern_url;
124
+ // eslint-disable-next-line camelcase
125
+ let replacement_url;
126
+ let rest;
127
+ if (s.includes(" ")) {
128
+ // eslint-disable-next-line camelcase
129
+ [pattern_url, replacement_url] = s.split(" ");
130
+ }
131
+ else if (s.includes("=")) {
132
+ // eslint-disable-next-line camelcase
133
+ [pattern_url, ...rest] = s.split("=");
134
+ // eslint-disable-next-line camelcase
135
+ replacement_url = rest.join("=");
136
+ this.warn(`Using = as a delimiter for --url-replacements (-r) option is deprecated. ` +
137
+ // eslint-disable-next-line camelcase
138
+ `Use space instead (--url-replacements "${pattern_url} ${replacement_url}").`);
139
+ }
140
+ else {
141
+ throw new errors_1.CLIError(`Can't parse ${s} as --url-replacements option. Please make sure it has a space as a delimiter and surrounded by quotes. (e.g. --url-replacements "https://example.com https://example.net")`);
142
+ }
143
+ // eslint-disable-next-line camelcase
144
+ return { pattern_url, replacement_url };
145
+ });
146
+ }
128
147
  }
129
148
  exports.default = WebTestRun;
130
149
  WebTestRun.description = "Run a scenario or test plan.";
@@ -133,7 +152,7 @@ WebTestRun.examples = [
133
152
  "Run a test plan:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/test_plans/0000",
134
153
  "Run and wait a test scenario:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --wait --timeout 600",
135
154
  'Run a test scenario with a specific capability:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --os "Windows Server" --browser Edge',
136
- "With URL replacements:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 -r http://example.com=http://example.net -r http://example.org=http://example.net",
155
+ 'With URL replacements:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 -r "http://example.com http://example.net" -r "http://example.org http://example.net"',
137
156
  'Run a test with specifying the execution name:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --name "Sample execution"',
138
157
  "Run a test scenario with Autify Connect:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --autify-connect NAME",
139
158
  "Run a test scenario with Autify Connect Client:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --wait --autify-connect-client",
@@ -145,7 +164,7 @@ WebTestRun.flags = {
145
164
  }),
146
165
  "url-replacements": core_1.Flags.string({
147
166
  char: "r",
148
- description: "URL replacements. Example: http://example.com=http://example.net",
167
+ description: 'URL replacements. Example: "http://example.com http://example.net"',
149
168
  multiple: true,
150
169
  }),
151
170
  "autify-connect": core_1.Flags.string({
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "0.28.0",
2
+ "version": "0.29.0",
3
3
  "commands": {
4
4
  "connect:access-point:create": {
5
5
  "id": "connect:access-point:create",
@@ -871,7 +871,7 @@
871
871
  "Run a test plan:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/test_plans/0000",
872
872
  "Run and wait a test scenario:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --wait --timeout 600",
873
873
  "Run a test scenario with a specific capability:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --os \"Windows Server\" --browser Edge",
874
- "With URL replacements:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 -r http://example.com=http://example.net -r http://example.org=http://example.net",
874
+ "With URL replacements:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 -r \"http://example.com http://example.net\" -r \"http://example.org http://example.net\"",
875
875
  "Run a test with specifying the execution name:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --name \"Sample execution\"",
876
876
  "Run a test scenario with Autify Connect:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --autify-connect NAME",
877
877
  "Run a test scenario with Autify Connect Client:\n<%= config.bin %> <%= command.id %> https://app.autify.com/projects/0000/scenarios/0000 --wait --autify-connect-client"
@@ -888,7 +888,7 @@
888
888
  "name": "url-replacements",
889
889
  "type": "option",
890
890
  "char": "r",
891
- "description": "URL replacements. Example: http://example.com=http://example.net",
891
+ "description": "URL replacements. Example: \"http://example.com http://example.net\"",
892
892
  "multiple": true
893
893
  },
894
894
  "autify-connect": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autifyhq/autify-cli",
3
- "version": "0.28.0",
3
+ "version": "0.29.0",
4
4
  "description": "Autify Command Line Interface (CLI)",
5
5
  "author": "Autify",
6
6
  "bin": {