create-allwright 0.1.14 → 0.1.16
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 +1 -1
- package/dist/index.js +48 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,7 +15,7 @@ npm create allwright@latest
|
|
|
15
15
|
The initializer prompts for:
|
|
16
16
|
|
|
17
17
|
- `TypeScript` or `JavaScript`
|
|
18
|
-
- one or more surfaces such as `Web` and `Mobile
|
|
18
|
+
- one or more surfaces such as `Web`, `Mobile Android`, and `Mobile iOS`
|
|
19
19
|
- an optional target directory
|
|
20
20
|
|
|
21
21
|
It scaffolds a Node project with `package.json`, Vitest config, shared allwright config, starter tests, and a short README for the generated app.
|
package/dist/index.js
CHANGED
|
@@ -12,6 +12,7 @@ const ALLWRIGHT_VERSION = `^${PACKAGE_VERSION}`;
|
|
|
12
12
|
const SURFACE_OPTIONS = [
|
|
13
13
|
{ label: "Web", value: "web" },
|
|
14
14
|
{ label: "Mobile Android", value: "mobile-android" },
|
|
15
|
+
{ label: "Mobile iOS", value: "mobile-ios" },
|
|
15
16
|
];
|
|
16
17
|
async function main() {
|
|
17
18
|
const options = parseArgs(process.argv.slice(2));
|
|
@@ -95,6 +96,10 @@ function parseArgs(args) {
|
|
|
95
96
|
case "--mobile-android":
|
|
96
97
|
options.surfaces.push("mobile-android");
|
|
97
98
|
break;
|
|
99
|
+
case "--mobile-ios":
|
|
100
|
+
case "--ios":
|
|
101
|
+
options.surfaces.push("mobile-ios");
|
|
102
|
+
break;
|
|
98
103
|
case "--both":
|
|
99
104
|
options.surfaces.push("web", "mobile-android");
|
|
100
105
|
break;
|
|
@@ -150,7 +155,11 @@ async function selectSurfaces(interactive) {
|
|
|
150
155
|
message: "Which surfaces would you like to test?",
|
|
151
156
|
options: SURFACE_OPTIONS.map((surface) => ({
|
|
152
157
|
...surface,
|
|
153
|
-
hint: surface.value === "web"
|
|
158
|
+
hint: surface.value === "web"
|
|
159
|
+
? "browser automation"
|
|
160
|
+
: surface.value === "mobile-android"
|
|
161
|
+
? "Android app automation"
|
|
162
|
+
: "iOS Simulator automation",
|
|
154
163
|
})),
|
|
155
164
|
required: true,
|
|
156
165
|
});
|
|
@@ -218,7 +227,10 @@ function buildProjectFiles(input) {
|
|
|
218
227
|
files[`tests/web.spec.${extension}`] = webSpecContents(language);
|
|
219
228
|
}
|
|
220
229
|
if (hasSurface(surfaces, "mobile-android")) {
|
|
221
|
-
files[`tests/mobile.spec.${extension}`] =
|
|
230
|
+
files[`tests/mobile.spec.${extension}`] = androidSpecContents(language);
|
|
231
|
+
}
|
|
232
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
233
|
+
files[`tests/ios.spec.${extension}`] = iosSpecContents(language);
|
|
222
234
|
}
|
|
223
235
|
return files;
|
|
224
236
|
}
|
|
@@ -293,14 +305,22 @@ function allwrightConfigContents(surfaces) {
|
|
|
293
305
|
lines.push(" browser:");
|
|
294
306
|
lines.push(" name: chromium");
|
|
295
307
|
}
|
|
296
|
-
if (hasSurface(surfaces, "mobile-android")) {
|
|
308
|
+
if (hasSurface(surfaces, "mobile-android") || hasSurface(surfaces, "mobile-ios")) {
|
|
297
309
|
lines.push("");
|
|
298
310
|
lines.push("mobile:");
|
|
311
|
+
}
|
|
312
|
+
if (hasSurface(surfaces, "mobile-android")) {
|
|
299
313
|
lines.push(" android:");
|
|
300
314
|
lines.push(" app:");
|
|
301
315
|
lines.push(" id: com.example.airticket");
|
|
302
316
|
lines.push(' binary: "https://allwright.dev/Flights-debug.apk"');
|
|
303
317
|
}
|
|
318
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
319
|
+
lines.push(" ios:");
|
|
320
|
+
lines.push(" app:");
|
|
321
|
+
lines.push(" id: com.sedinqa.Flights");
|
|
322
|
+
lines.push(' binary: "https://allwright.dev/Flights-simulator.ipa"');
|
|
323
|
+
}
|
|
304
324
|
lines.push("");
|
|
305
325
|
lines.push("expect:");
|
|
306
326
|
lines.push(" timeoutMs: 7000");
|
|
@@ -325,7 +345,7 @@ test("opens the Form Inputs page", { timeout: 30_000 }, async ({ page }) => {
|
|
|
325
345
|
});
|
|
326
346
|
`;
|
|
327
347
|
}
|
|
328
|
-
function
|
|
348
|
+
function androidSpecContents(language) {
|
|
329
349
|
const importLine = language === "ts"
|
|
330
350
|
? 'import { test } from "@allwright.dev/vitest";'
|
|
331
351
|
: 'import { test } from "@allwright.dev/vitest";';
|
|
@@ -338,16 +358,32 @@ test("opens the Android demo app and navigates to sign up", { timeout: 180_000 }
|
|
|
338
358
|
});
|
|
339
359
|
`;
|
|
340
360
|
}
|
|
361
|
+
function iosSpecContents(language) {
|
|
362
|
+
const importLine = language === "ts"
|
|
363
|
+
? 'import { expect, test } from "@allwright.dev/vitest";'
|
|
364
|
+
: 'import { expect, test } from "@allwright.dev/vitest";';
|
|
365
|
+
return `${importLine}
|
|
366
|
+
|
|
367
|
+
test("opens the iOS Flights demo app", { timeout: 180_000 }, async ({ iosApp }) => {
|
|
368
|
+
await iosApp.locator("text=Login").click();
|
|
369
|
+
await expect(iosApp.locator("text=Welcome back")).toBeVisible();
|
|
370
|
+
});
|
|
371
|
+
`;
|
|
372
|
+
}
|
|
341
373
|
function generatedReadmeContents(surfaces) {
|
|
342
374
|
const nextSteps = [
|
|
343
375
|
"## Next steps",
|
|
344
376
|
"",
|
|
345
377
|
"1. Run `npm install`.",
|
|
346
|
-
"2. Run `npm test`.",
|
|
347
378
|
];
|
|
379
|
+
let step = 2;
|
|
348
380
|
if (hasSurface(surfaces, "mobile-android")) {
|
|
349
|
-
nextSteps.push(
|
|
381
|
+
nextSteps.push(`${step++}. Start an Android emulator or connect a device with USB debugging enabled.`, `${step++}. Confirm it is visible with \`adb devices -l\`.`, `${step++}. The first Android run downloads and installs the Airticket demo app configured in \`allwright.config.yaml\`.`);
|
|
382
|
+
}
|
|
383
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
384
|
+
nextSteps.push(`${step++}. Start an iOS Simulator.`, `${step++}. The first iOS run downloads and installs the Flights simulator IPA configured in \`allwright.config.yaml\`; no manual app or agent installation is needed.`);
|
|
350
385
|
}
|
|
386
|
+
nextSteps.push(`${step}. Run \`npm test\`.`);
|
|
351
387
|
return `# allwright project
|
|
352
388
|
|
|
353
389
|
Scaffolded with \`npm init allwright\`.
|
|
@@ -376,6 +412,9 @@ function parseSurfaceId(input) {
|
|
|
376
412
|
if (normalized === "mobile" || normalized === "mobile-android" || normalized === "android") {
|
|
377
413
|
return "mobile-android";
|
|
378
414
|
}
|
|
415
|
+
if (normalized === "mobile-ios" || normalized === "ios") {
|
|
416
|
+
return "mobile-ios";
|
|
417
|
+
}
|
|
379
418
|
throw new Error(`Unknown surface: ${input}`);
|
|
380
419
|
}
|
|
381
420
|
function parsePackageManager(input) {
|
|
@@ -459,6 +498,9 @@ function printSummary(absoluteTargetDir, relativeTargetDir, language, surfaces,
|
|
|
459
498
|
if (hasSurface(surfaces, "mobile-android")) {
|
|
460
499
|
console.log(" adb devices -l");
|
|
461
500
|
}
|
|
501
|
+
if (hasSurface(surfaces, "mobile-ios")) {
|
|
502
|
+
console.log(" xcrun simctl list devices available");
|
|
503
|
+
}
|
|
462
504
|
console.log(`${packageManager === "npm" ? " npm test" : ` ${packageManager} test`}`);
|
|
463
505
|
}
|
|
464
506
|
function formatSurfaceLabel(surface) {
|