@softure-ai/marketing-kit 0.1.9 → 0.1.11
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/CHANGELOG.md +31 -0
- package/README.md +124 -5
- package/dist/cli/main.js +42 -6
- package/dist/cli/main.js.map +1 -1
- package/dist/config/config.d.ts +2 -0
- package/dist/config/config.d.ts.map +1 -1
- package/dist/config/config.js +1 -0
- package/dist/config/config.js.map +1 -1
- package/dist/config/placeholders.d.ts +32 -0
- package/dist/config/placeholders.d.ts.map +1 -0
- package/dist/config/placeholders.js +41 -0
- package/dist/config/placeholders.js.map +1 -0
- package/dist/config/schema.d.ts +3758 -0
- package/dist/config/schema.d.ts.map +1 -1
- package/dist/config/schema.js +84 -0
- package/dist/config/schema.js.map +1 -1
- package/dist/config/shot-steps.d.ts +1101 -0
- package/dist/config/shot-steps.d.ts.map +1 -0
- package/dist/config/shot-steps.js +65 -0
- package/dist/config/shot-steps.js.map +1 -0
- package/dist/record/actions.d.ts +3 -10
- package/dist/record/actions.d.ts.map +1 -1
- package/dist/record/actions.js +7 -23
- package/dist/record/actions.js.map +1 -1
- package/dist/record/locator.d.ts +10 -0
- package/dist/record/locator.d.ts.map +1 -0
- package/dist/record/locator.js +24 -0
- package/dist/record/locator.js.map +1 -0
- package/dist/screenshot/gates.d.ts +55 -5
- package/dist/screenshot/gates.d.ts.map +1 -1
- package/dist/screenshot/gates.js +58 -5
- package/dist/screenshot/gates.js.map +1 -1
- package/dist/screenshot/prepare.d.ts +18 -0
- package/dist/screenshot/prepare.d.ts.map +1 -0
- package/dist/screenshot/prepare.js +60 -0
- package/dist/screenshot/prepare.js.map +1 -0
- package/dist/screenshot/screenshot.d.ts +9 -2
- package/dist/screenshot/screenshot.d.ts.map +1 -1
- package/dist/screenshot/screenshot.js +140 -8
- package/dist/screenshot/screenshot.js.map +1 -1
- package/dist/screenshot/shot-texts.d.ts +26 -0
- package/dist/screenshot/shot-texts.d.ts.map +1 -0
- package/dist/screenshot/shot-texts.js +55 -0
- package/dist/screenshot/shot-texts.js.map +1 -0
- package/dist/screenshot/sign-in.d.ts +34 -0
- package/dist/screenshot/sign-in.d.ts.map +1 -0
- package/dist/screenshot/sign-in.js +66 -0
- package/dist/screenshot/sign-in.js.map +1 -0
- package/dist/screenshot/steps.d.ts +13 -0
- package/dist/screenshot/steps.d.ts.map +1 -0
- package/dist/screenshot/steps.js +82 -0
- package/dist/screenshot/steps.js.map +1 -0
- package/package.json +2 -2
- package/schema/marketing.schema.json +3080 -10
- package/src/cli/main.ts +40 -6
- package/src/config/config.ts +3 -0
- package/src/config/placeholders.ts +60 -0
- package/src/config/schema.ts +89 -0
- package/src/config/shot-steps.ts +79 -0
- package/src/record/actions.ts +5 -31
- package/src/record/locator.ts +37 -0
- package/src/screenshot/gates.ts +77 -5
- package/src/screenshot/prepare.ts +64 -0
- package/src/screenshot/screenshot.ts +146 -9
- package/src/screenshot/shot-texts.ts +72 -0
- package/src/screenshot/sign-in.ts +91 -0
- package/src/screenshot/steps.ts +85 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shot-steps.d.ts","sourceRoot":"","sources":["../../src/config/shot-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAaxB,2DAA2D;AAC3D,eAAO,MAAM,cAAc,QAAgC,CAAC;AAM5D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AM,CAAC,OAAO,UAAU,CAAC,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { locatorSchema } from "./actions-schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* What a screenshot does on the page before it is judged: the sign-in form (`signIn.steps`) and an entry's own
|
|
5
|
+
* `steps` (open collapsed sections, hide what a still image should not show). Plain Playwright calls on a locator,
|
|
6
|
+
* with no camera and no timing: a screenshot records nothing in between. `crop` frames one element at a fixed aspect
|
|
7
|
+
* ratio instead of the viewport, optionally from the top edge of another one.
|
|
8
|
+
*/
|
|
9
|
+
/** A Playwright key name, modifiers joined with `+`; Playwright itself refuses a name it does not know. */
|
|
10
|
+
const KEY_PATTERN = /^\S+$/;
|
|
11
|
+
/** `W:H` with whole numbers from 1 to 9999, e.g. `4:3`. */
|
|
12
|
+
export const ASPECT_PATTERN = /^[1-9]\d{0,3}:[1-9]\d{0,3}$/;
|
|
13
|
+
/** More columns than a chart ever shows; the cap only keeps a typo from reading as "keep everything". */
|
|
14
|
+
const MAX_KEEP_LAST = 1000;
|
|
15
|
+
const target = locatorSchema.describe("The element, as a locator descriptor with exactly one of role, text, label, testId, css.");
|
|
16
|
+
export const shotStepSchema = z.discriminatedUnion("do", [
|
|
17
|
+
z.strictObject({
|
|
18
|
+
do: z.literal("fill").describe("Replaces the value of an input, e.g. the e-mail of the sign-in form."),
|
|
19
|
+
target,
|
|
20
|
+
value: z.string().describe("The value; {env:NAME} and {data:key} are replaced. Never printed, so a password may go here as {env:NAME}."),
|
|
21
|
+
}),
|
|
22
|
+
z.strictObject({
|
|
23
|
+
do: z.literal("click").describe("Clicks the element, e.g. the submit button or a collapsed section's summary."),
|
|
24
|
+
target,
|
|
25
|
+
}),
|
|
26
|
+
z.strictObject({
|
|
27
|
+
do: z.literal("check").describe("Ticks a checkbox or radio button, e.g. the terms of a sign-up form."),
|
|
28
|
+
target,
|
|
29
|
+
}),
|
|
30
|
+
z.strictObject({
|
|
31
|
+
do: z.literal("press").describe("Presses a key on the focused element, e.g. Enter."),
|
|
32
|
+
key: z.string().regex(KEY_PATTERN, "must be a key name such as Enter or Escape").describe("A Playwright key name; modifiers joined with +."),
|
|
33
|
+
}),
|
|
34
|
+
z.strictObject({
|
|
35
|
+
do: z.literal("open").describe("Opens every matching <details> element (nth picks one), e.g. every disclosure of a card; fails when a match is not a <details> or does not stay open."),
|
|
36
|
+
target: locatorSchema.describe("The <details> elements, as a locator descriptor with exactly one of role, text, label, testId, css; every match is opened."),
|
|
37
|
+
}),
|
|
38
|
+
z.strictObject({
|
|
39
|
+
do: z.literal("hide").describe("Hides every match but the last keepLast (display: none), e.g. all but the last three columns of a horizontally scrolling chart."),
|
|
40
|
+
target: locatorSchema.describe("The elements, as a locator descriptor with exactly one of role, text, label, testId, css; every match counts."),
|
|
41
|
+
keepLast: z
|
|
42
|
+
.number()
|
|
43
|
+
.int()
|
|
44
|
+
.min(0)
|
|
45
|
+
.max(MAX_KEEP_LAST)
|
|
46
|
+
.default(0)
|
|
47
|
+
.describe(`How many of the last matches stay shown (0-${MAX_KEEP_LAST}, default 0); the step fails when there are not more matches than this.`),
|
|
48
|
+
}),
|
|
49
|
+
]);
|
|
50
|
+
export const cropSchema = z.strictObject({
|
|
51
|
+
target: locatorSchema.describe("The element framed: exactly one match (nth picks one of several)."),
|
|
52
|
+
top: locatorSchema
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("An element inside target whose top edge starts the frame instead of target's (e.g. a row of a card); exactly one match. The width stays target's."),
|
|
55
|
+
aspect: z
|
|
56
|
+
.string()
|
|
57
|
+
.regex(ASPECT_PATTERN, "must be W:H with whole numbers, e.g. 4:3")
|
|
58
|
+
.transform((value) => {
|
|
59
|
+
const [width, height] = value.split(":").map(Number);
|
|
60
|
+
return { width: width ?? 1, height: height ?? 1 };
|
|
61
|
+
})
|
|
62
|
+
.describe("The frame's width to height, e.g. 4:3: as wide as the element (plus padding), from its top edge down."),
|
|
63
|
+
padding: z.number().int().min(0).max(200).default(0).describe("CSS pixels of the page around the element on the left, right and top (0-200, default 0)."),
|
|
64
|
+
});
|
|
65
|
+
//# sourceMappingURL=shot-steps.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"shot-steps.js","sourceRoot":"","sources":["../../src/config/shot-steps.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD;;;;;GAKG;AAEH,2GAA2G;AAC3G,MAAM,WAAW,GAAG,OAAO,CAAC;AAC5B,2DAA2D;AAC3D,MAAM,CAAC,MAAM,cAAc,GAAG,6BAA6B,CAAC;AAC5D,yGAAyG;AACzG,MAAM,aAAa,GAAG,IAAI,CAAC;AAE3B,MAAM,MAAM,GAAG,aAAa,CAAC,QAAQ,CAAC,0FAA0F,CAAC,CAAC;AAElI,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,CAAC,kBAAkB,CAAC,IAAI,EAAE;IACvD,CAAC,CAAC,YAAY,CAAC;QACb,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,sEAAsE,CAAC;QACtG,MAAM;QACN,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,4GAA4G,CAAC;KACzI,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACb,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,8EAA8E,CAAC;QAC/G,MAAM;KACP,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACb,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,qEAAqE,CAAC;QACtG,MAAM;KACP,CAAC;IACF,CAAC,CAAC,YAAY,CAAC;QACb,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,Q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C,EAAE,MAAM,EAAE,MAAM,IAAI,CAAC,EAAE,CAAC;IACpD,CAAC,CAAC;SACD,QAAQ,CAAC,uGAAuG,CAAC;IACpH,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,0FAA0F,CAAC;CAC1J,CAAC,CAAC"}
|
package/dist/record/actions.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { LocatorDescriptor, SceneAction } from "../config/actions-schema.js";
|
|
1
|
+
import type { SceneAction } from "../config/actions-schema.js";
|
|
3
2
|
import type { ActionBeat } from "../config/config.js";
|
|
4
3
|
import type { Director, Scene } from "../film.js";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* locator and each action the Director call of the same name. An action that fails names its JSON
|
|
8
|
-
* path, so the author knows which entry of the config to fix.
|
|
9
|
-
*/
|
|
10
|
-
/** The part of a page that builds locators. */
|
|
11
|
-
export type LocatorSource = Pick<Page, "getByRole" | "getByText" | "getByLabel" | "getByTestId" | "locator">;
|
|
12
|
-
export declare function getLocator(page: LocatorSource, descriptor: LocatorDescriptor): Locator;
|
|
4
|
+
import { getLocator, type LocatorSource } from "./locator.js";
|
|
5
|
+
export { getLocator, type LocatorSource };
|
|
13
6
|
/** Plays one action on the Director; options the action leaves out keep the Director's defaults. */
|
|
14
7
|
export declare function runAction(director: Director, action: SceneAction): Promise<void>;
|
|
15
8
|
/** The scene of a video described by beat `actions`; `videoIndex` is its position in `videos`. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/record/actions.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/record/actions.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAqB,WAAW,EAAE,MAAM,6BAA6B,CAAC;AAClF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,MAAM,cAAc,CAAC;AAG9D,OAAO,EAAE,UAAU,EAAE,KAAK,aAAa,EAAE,CAAC;AAY1C,oGAAoG;AACpG,wBAAsB,SAAS,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAyCtF;AASD,kGAAkG;AAClG,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,SAAS,UAAU,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,KAAK,CAkBzF"}
|
package/dist/record/actions.js
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
1
|
import { formatIssuePath } from "../config/issues.js";
|
|
2
|
+
import { getLocator } from "./locator.js";
|
|
2
3
|
import { ScreenGuardError } from "./record.js";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
function buildLocator(page, descriptor) {
|
|
11
|
-
switch (descriptor.kind) {
|
|
12
|
-
case "role":
|
|
13
|
-
return descriptor.name === null
|
|
14
|
-
? page.getByRole(descriptor.role)
|
|
15
|
-
: page.getByRole(descriptor.role, { name: toMatcher(descriptor.name), ...(descriptor.exact ? { exact: true } : {}) });
|
|
16
|
-
case "text":
|
|
17
|
-
return page.getByText(toMatcher(descriptor.text), descriptor.exact ? { exact: true } : undefined);
|
|
18
|
-
case "label":
|
|
19
|
-
return page.getByLabel(toMatcher(descriptor.label), descriptor.exact ? { exact: true } : undefined);
|
|
20
|
-
case "testId":
|
|
21
|
-
return page.getByTestId(descriptor.testId);
|
|
22
|
-
case "css":
|
|
23
|
-
return descriptor.hasText === null ? page.locator(descriptor.css) : page.locator(descriptor.css, { hasText: toMatcher(descriptor.hasText) });
|
|
24
|
-
}
|
|
25
|
-
}
|
|
4
|
+
export { getLocator };
|
|
5
|
+
/**
|
|
6
|
+
* Beat `actions` from `marketing.json`, played on the Director: each descriptor becomes a Playwright
|
|
7
|
+
* locator and each action the Director call of the same name. An action that fails names its JSON
|
|
8
|
+
* path, so the author knows which entry of the config to fix.
|
|
9
|
+
*/
|
|
26
10
|
function getLocators(page, target) {
|
|
27
11
|
return Array.isArray(target) ? target.map((descriptor) => getLocator(page, descriptor)) : getLocator(page, target);
|
|
28
12
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/record/actions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../../src/record/actions.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAsB,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,OAAO,EAAE,UAAU,EAAsB,CAAC;AAE1C;;;;GAIG;AAEH,SAAS,WAAW,CAAC,IAAmB,EAAE,MAA+C;IACvF,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;AACrH,CAAC;AAED,oGAAoG;AACpG,MAAM,CAAC,KAAK,UAAU,SAAS,CAAC,QAAkB,EAAE,MAAmB;IACrE,MAAM,EAAE,IAAI,EAAE,GAAG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Q,EAAE,MAAM,CAAC,CAAC;oBACpC,CAAC;oBAAC,OAAO,KAAK,EAAE,CAAC;wBACf,MAAM,QAAQ,CAAC,KAAK,EAAE,GAAG,eAAe,CAAC,CAAC,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC,KAAK,MAAM,CAAC,EAAE,GAAG,CAAC,CAAC;oBAClI,CAAC;gBACH,CAAC;YACH,CAAC,EACD,IAAI,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI,CAAC,GAAG,EAAE,CAClD,CAAC;QACJ,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Locator, Page } from "playwright";
|
|
2
|
+
import type { LocatorDescriptor } from "../config/actions-schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* A locator descriptor from `marketing.json` as a Playwright locator: the beats' actions and the screenshots'
|
|
5
|
+
* steps and crops find elements the same way.
|
|
6
|
+
*/
|
|
7
|
+
/** The part of a page that builds locators. */
|
|
8
|
+
export type LocatorSource = Pick<Page, "getByRole" | "getByText" | "getByLabel" | "getByTestId" | "locator">;
|
|
9
|
+
export declare function getLocator(page: LocatorSource, descriptor: LocatorDescriptor): Locator;
|
|
10
|
+
//# sourceMappingURL=locator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locator.d.ts","sourceRoot":"","sources":["../../src/record/locator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAEhD,OAAO,KAAK,EAAE,iBAAiB,EAAa,MAAM,6BAA6B,CAAC;AAEhF;;;GAGG;AAEH,+CAA+C;AAC/C,MAAM,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,WAAW,GAAG,WAAW,GAAG,YAAY,GAAG,aAAa,GAAG,SAAS,CAAC,CAAC;AAM7G,wBAAgB,UAAU,CAAC,IAAI,EAAE,aAAa,EAAE,UAAU,EAAE,iBAAiB,GAAG,OAAO,CAGtF"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function toMatcher(match) {
|
|
2
|
+
return typeof match === "string" ? match : new RegExp(match.regex, match.flags);
|
|
3
|
+
}
|
|
4
|
+
export function getLocator(page, descriptor) {
|
|
5
|
+
const locator = buildLocator(page, descriptor);
|
|
6
|
+
return descriptor.nth === null ? locator : locator.nth(descriptor.nth);
|
|
7
|
+
}
|
|
8
|
+
function buildLocator(page, descriptor) {
|
|
9
|
+
switch (descriptor.kind) {
|
|
10
|
+
case "role":
|
|
11
|
+
return descriptor.name === null
|
|
12
|
+
? page.getByRole(descriptor.role)
|
|
13
|
+
: page.getByRole(descriptor.role, { name: toMatcher(descriptor.name), ...(descriptor.exact ? { exact: true } : {}) });
|
|
14
|
+
case "text":
|
|
15
|
+
return page.getByText(toMatcher(descriptor.text), descriptor.exact ? { exact: true } : undefined);
|
|
16
|
+
case "label":
|
|
17
|
+
return page.getByLabel(toMatcher(descriptor.label), descriptor.exact ? { exact: true } : undefined);
|
|
18
|
+
case "testId":
|
|
19
|
+
return page.getByTestId(descriptor.testId);
|
|
20
|
+
case "css":
|
|
21
|
+
return descriptor.hasText === null ? page.locator(descriptor.css) : page.locator(descriptor.css, { hasText: toMatcher(descriptor.hasText) });
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=locator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locator.js","sourceRoot":"","sources":["../../src/record/locator.ts"],"names":[],"mappings":"AAYA,SAAS,SAAS,CAAC,KAAgB;IACjC,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,KAAK,CA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MAAM,CAAC,CAAC;QAC7C,KAAK,KAAK;YACR,OAAO,UAAU,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,GAAG,EAAE,EAAE,OAAO,EAAE,SAAS,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IACjJ,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
+
import type { Aspect } from "../config/shot-steps.js";
|
|
1
2
|
/**
|
|
2
|
-
* The quality gates a screenshot passes before it is kept (
|
|
3
|
-
* answered below HTTP 400, it reached the requested scroll offset, it shows the expected phrase,
|
|
4
|
-
*
|
|
5
|
-
* the
|
|
3
|
+
* The quality gates a screenshot passes before it is kept: the sign-in worked (signed-in entries), the page
|
|
4
|
+
* answered below HTTP 400, its steps ran, it reached the requested scroll offset, it shows the expected phrase, a
|
|
5
|
+
* crop found its one element and fits the page and the file has the frame's size, none of the entry's hidden
|
|
6
|
+
* selectors still shows an element in the frame, the file is not suspiciously small, and no earlier file of the run
|
|
7
|
+
* has the same bytes. A blank page, an error page, a half-loaded one, an
|
|
8
|
+
* empty account or a frame of the wrong place fails at least one of them.
|
|
6
9
|
*/
|
|
7
|
-
export declare const SCREENSHOT_GATES: readonly ["load", "status", "scroll", "phrase", "size"];
|
|
10
|
+
export declare const SCREENSHOT_GATES: readonly ["sign-in", "load", "status", "steps", "scroll", "phrase", "crop", "hide", "size", "duplicate"];
|
|
8
11
|
export type ScreenshotGate = (typeof SCREENSHOT_GATES)[number];
|
|
9
12
|
/** The first status the gate refuses. */
|
|
10
13
|
export declare const MIN_FAILING_STATUS = 400;
|
|
@@ -14,4 +17,51 @@ export declare function findStatusFailure(status: number | null, url: string): s
|
|
|
14
17
|
export declare function findScrollFailure(reached: number, wanted: number): string | null;
|
|
15
18
|
/** Null when the file is large enough; otherwise why it is refused. */
|
|
16
19
|
export declare function findSizeFailure(bytes: number, minBytes: number): string | null;
|
|
20
|
+
/** A rectangle in CSS pixels, in document coordinates (from the page's top-left corner, not the viewport's). */
|
|
21
|
+
export interface Rect {
|
|
22
|
+
x: number;
|
|
23
|
+
y: number;
|
|
24
|
+
width: number;
|
|
25
|
+
height: number;
|
|
26
|
+
}
|
|
27
|
+
export type CropFrameResult = {
|
|
28
|
+
ok: true;
|
|
29
|
+
frame: Rect;
|
|
30
|
+
} | {
|
|
31
|
+
ok: false;
|
|
32
|
+
message: string;
|
|
33
|
+
};
|
|
34
|
+
export interface CropFrameInput {
|
|
35
|
+
/** The element, in document coordinates. */
|
|
36
|
+
element: Rect;
|
|
37
|
+
/** `crop.top`'s top edge in document coordinates: where the frame starts instead of the element's top edge. */
|
|
38
|
+
top?: number;
|
|
39
|
+
/** The page's scrollable size. */
|
|
40
|
+
page: {
|
|
41
|
+
width: number;
|
|
42
|
+
height: number;
|
|
43
|
+
};
|
|
44
|
+
aspect: Aspect;
|
|
45
|
+
padding: number;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* The frame of a crop in whole CSS pixels: as wide as the element plus the padding on each side, from the padding
|
|
49
|
+
* above its top edge (or above `top`), as tall as the aspect asks. Refused when `top` lies outside the element, whose
|
|
50
|
+
* frame would then not show it, and when the frame would run past the page, which would leave part of the file empty
|
|
51
|
+
* or cut it short.
|
|
52
|
+
*/
|
|
53
|
+
export declare function findCropFrame({ element, top, page, aspect, padding }: CropFrameInput): CropFrameResult;
|
|
54
|
+
/** Null when the PNG is the frame at the device scale; otherwise what it is instead. */
|
|
55
|
+
export declare function findDimensionFailure(file: {
|
|
56
|
+
width: number;
|
|
57
|
+
height: number;
|
|
58
|
+
}, frame: {
|
|
59
|
+
width: number;
|
|
60
|
+
height: number;
|
|
61
|
+
}, scale: number): string | null;
|
|
62
|
+
/** Null when no hidden selector shows an element in the frame; otherwise the first that does, and how many. */
|
|
63
|
+
export declare function findHideFailure(counts: readonly {
|
|
64
|
+
selector: string;
|
|
65
|
+
shown: number | null;
|
|
66
|
+
}[]): string | null;
|
|
17
67
|
//# sourceMappingURL=gates.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../src/screenshot/gates.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"gates.d.ts","sourceRoot":"","sources":["../../src/screenshot/gates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,yBAAyB,CAAC;AAEtD;;;;;;;GAOG;AAEH,eAAO,MAAM,gBAAgB,0GAA2G,CAAC;AAEzI,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE/D,yCAAyC;AACzC,eAAO,MAAM,kBAAkB,MAAM,CAAC;AAEtC,6GAA6G;AAC7G,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAInF;AAKD,mGAAmG;AACnG,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAGhF;AAED,uEAAuE;AACvE,wBAAgB,eAAe,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAG9E;AAED,gHAAgH;AAChH,MAAM,WAAW,IAAI;IACnB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,eAAe,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,IAAI,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEzF,MAAM,WAAW,cAAc;IAC7B,4CAA4C;IAC5C,OAAO,EAAE,IAAI,CAAC;IACd,+GAA+G;IAC/G,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,kCAAkC;IAClC,IAAI,EAAE;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,CAAC;IACxC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,EAAE,cAAc,GAAG,eAAe,CAkBtG;AAKD,wFAAwF;AACxF,wBAAgB,oBAAoB,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAMpJ;AAED,+GAA+G;AAC/G,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;CAAE,EAAE,GAAG,MAAM,GAAG,IAAI,CAM5G"}
|
package/dist/screenshot/gates.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The quality gates a screenshot passes before it is kept (
|
|
3
|
-
* answered below HTTP 400, it reached the requested scroll offset, it shows the expected phrase,
|
|
4
|
-
*
|
|
5
|
-
* the
|
|
2
|
+
* The quality gates a screenshot passes before it is kept: the sign-in worked (signed-in entries), the page
|
|
3
|
+
* answered below HTTP 400, its steps ran, it reached the requested scroll offset, it shows the expected phrase, a
|
|
4
|
+
* crop found its one element and fits the page and the file has the frame's size, none of the entry's hidden
|
|
5
|
+
* selectors still shows an element in the frame, the file is not suspiciously small, and no earlier file of the run
|
|
6
|
+
* has the same bytes. A blank page, an error page, a half-loaded one, an
|
|
7
|
+
* empty account or a frame of the wrong place fails at least one of them.
|
|
6
8
|
*/
|
|
7
|
-
export const SCREENSHOT_GATES = ["load", "status", "scroll", "phrase", "size"];
|
|
9
|
+
export const SCREENSHOT_GATES = ["sign-in", "load", "status", "steps", "scroll", "phrase", "crop", "hide", "size", "duplicate"];
|
|
8
10
|
/** The first status the gate refuses. */
|
|
9
11
|
export const MIN_FAILING_STATUS = 400;
|
|
10
12
|
/** Null when the status passes; otherwise why it does not. `null` status: the navigation had no response. */
|
|
@@ -29,4 +31,55 @@ export function findSizeFailure(bytes, minBytes) {
|
|
|
29
31
|
return null;
|
|
30
32
|
return `the file has ${bytes} bytes, below minBytes ${minBytes} (a blank or broken page); deleted`;
|
|
31
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* The frame of a crop in whole CSS pixels: as wide as the element plus the padding on each side, from the padding
|
|
36
|
+
* above its top edge (or above `top`), as tall as the aspect asks. Refused when `top` lies outside the element, whose
|
|
37
|
+
* frame would then not show it, and when the frame would run past the page, which would leave part of the file empty
|
|
38
|
+
* or cut it short.
|
|
39
|
+
*/
|
|
40
|
+
export function findCropFrame({ element, top, page, aspect, padding }) {
|
|
41
|
+
if (top !== undefined && top < element.y)
|
|
42
|
+
return { ok: false, message: `crop.top's top edge lies ${Math.round(element.y - top)} px above crop.target` };
|
|
43
|
+
if (top !== undefined && top >= element.y + element.height) {
|
|
44
|
+
return { ok: false, message: `crop.top's top edge lies ${Math.round(top - element.y - element.height)} px below crop.target's bottom edge` };
|
|
45
|
+
}
|
|
46
|
+
const x = Math.floor(element.x - padding);
|
|
47
|
+
const y = Math.floor((top ?? element.y) - padding);
|
|
48
|
+
const width = Math.round(element.width + 2 * padding);
|
|
49
|
+
const height = Math.round((width * aspect.height) / aspect.width);
|
|
50
|
+
const ratio = `${aspect.width}:${aspect.height}`;
|
|
51
|
+
if (width < 1)
|
|
52
|
+
return { ok: false, message: `the crop's element has no width, so a ${ratio} frame has nothing to show` };
|
|
53
|
+
if (x < 0)
|
|
54
|
+
return { ok: false, message: `the ${ratio} frame starts ${-x} px left of the page; lower crop.padding` };
|
|
55
|
+
if (y < 0)
|
|
56
|
+
return { ok: false, message: `the ${ratio} frame starts ${-y} px above the page; lower crop.padding` };
|
|
57
|
+
if (x + width > page.width)
|
|
58
|
+
return { ok: false, message: `the ${ratio} frame runs ${x + width - page.width} px past the page's right edge; lower crop.padding` };
|
|
59
|
+
if (y + height > page.height) {
|
|
60
|
+
return { ok: false, message: `the ${ratio} frame (${width}×${height} px) runs ${y + height - page.height} px past the page's bottom edge` };
|
|
61
|
+
}
|
|
62
|
+
return { ok: true, frame: { x, y, width, height } };
|
|
63
|
+
}
|
|
64
|
+
/** Device pixels round once per side, so the file may be one pixel off the frame × scale. */
|
|
65
|
+
const DIMENSION_TOLERANCE_PX = 1;
|
|
66
|
+
/** Null when the PNG is the frame at the device scale; otherwise what it is instead. */
|
|
67
|
+
export function findDimensionFailure(file, frame, scale) {
|
|
68
|
+
const width = Math.round(frame.width * scale);
|
|
69
|
+
const height = Math.round(frame.height * scale);
|
|
70
|
+
const isWithin = Math.abs(file.width - width) <= DIMENSION_TOLERANCE_PX && Math.abs(file.height - height) <= DIMENSION_TOLERANCE_PX;
|
|
71
|
+
if (isWithin)
|
|
72
|
+
return null;
|
|
73
|
+
return `the file is ${file.width}×${file.height} px, not the crop's ${width}×${height} px; deleted`;
|
|
74
|
+
}
|
|
75
|
+
/** Null when no hidden selector shows an element in the frame; otherwise the first that does, and how many. */
|
|
76
|
+
export function findHideFailure(counts) {
|
|
77
|
+
for (const { selector, shown } of counts) {
|
|
78
|
+
if (shown === null)
|
|
79
|
+
return `hide "${selector}" is not a selector the browser can parse`;
|
|
80
|
+
if (shown > 0)
|
|
81
|
+
return `hide "${selector}" still shows ${shown} element${shown === 1 ? "" : "s"} in the frame`;
|
|
82
|
+
}
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
32
85
|
//# sourceMappingURL=gates.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gates.js","sourceRoot":"","sources":["../../src/screenshot/gates.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"gates.js","sourceRoot":"","sources":["../../src/screenshot/gates.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AAEH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,WAAW,CAAU,CAAC;AAIzI,yCAAyC;AACzC,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAEtC,6GAA6G;AAC7G,MAAM,UAAU,iBAAiB,CAAC,MAAqB,EAAE,GAAW;IAClE,IAAI,MAAM,KAAK,IAAI;QAAE,OAAO,yBAAyB,GAAG,EAAE,CAAC;IAC3D,IAAI,MAAM,IAAI,kBAAkB;QAAE,OAAO,QAAQ,MAAM,SAAS,GAAG,EAAE,CAAC;IACtE,OAAO,IAAI,CAAC;AACd,CAAC;AAED,sGAAsG;AACtG,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B,mGAAmG;AACnG,MAAM,UAAU,iBAAiB,CAAC,OAAe,EAAE,MAAc;IAC/D,IAAI,OAAO,IAAI,MAAM,GAAG,mBAAmB;QAAE,OAAO,IAAI,CAAC;IACzD,OAAO,4BAA4B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,0BAA0B,MAAM,EAAE,CAAC;AAC3F,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,eAAe,CAAC,KAAa,EAAE,QAAgB;IAC7D,IAAI,KAAK,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IACnC,OAAO,gBAAgB,KAAK,0BAA0B,QA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AAG,CAAC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,IAAI,sBAAsB,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,sBAAsB,CAAC;IACpI,IAAI,QAAQ;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,eAAe,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,MAAM,uBAAuB,KAAK,IAAI,MAAM,cAAc,CAAC;AACtG,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,eAAe,CAAC,MAA6D;IAC3F,KAAK,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,MAAM,EAAE,CAAC;QACzC,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,SAAS,QAAQ,2CAA2C,CAAC;QACxF,IAAI,KAAK,GAAG,CAAC;YAAE,OAAO,SAAS,QAAQ,iBAAiB,KAAK,WAAW,KAAK,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,eAAe,CAAC;IAChH,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type PrepareResult = {
|
|
2
|
+
ok: true;
|
|
3
|
+
data: Record<string, string>;
|
|
4
|
+
} | {
|
|
5
|
+
ok: false;
|
|
6
|
+
error: string;
|
|
7
|
+
};
|
|
8
|
+
/** The data from the last non-empty line of the output: a JSON object of strings or numbers. */
|
|
9
|
+
export declare function parsePrepareOutput(stdout: string): PrepareResult;
|
|
10
|
+
export interface RunPrepareOptions {
|
|
11
|
+
/** The folder of marketing.json. */
|
|
12
|
+
cwd: string;
|
|
13
|
+
/** The app's address, handed to the command as MARKETING_BASE_URL. */
|
|
14
|
+
baseUrl: string;
|
|
15
|
+
}
|
|
16
|
+
/** Runs the command (no shell) and reads its data; a failure names the exit, never the output. */
|
|
17
|
+
export declare function runPrepare(command: readonly [string, ...string[]], options: RunPrepareOptions): PrepareResult;
|
|
18
|
+
//# sourceMappingURL=prepare.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.d.ts","sourceRoot":"","sources":["../../src/screenshot/prepare.ts"],"names":[],"mappings":"AAaA,MAAM,MAAM,aAAa,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtG,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,aAAa,CAuBhE;AAED,MAAM,WAAW,iBAAiB;IAChC,oCAAoC;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,sEAAsE;IACtE,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,kGAAkG;AAClG,wBAAgB,UAAU,CAAC,OAAO,EAAE,SAAS,CAAC,MAAM,EAAE,GAAG,MAAM,EAAE,CAAC,EAAE,OAAO,EAAE,iBAAiB,GAAG,aAAa,CAc7G"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { spawnSync } from "node:child_process";
|
|
2
|
+
/**
|
|
3
|
+
* `signIn.prepare`: the app's own command that creates and seeds the account the signed-in screenshots show, and
|
|
4
|
+
* prints what the frames must show as `{data:key}`. Its output may hold the account's password, so it is parsed and
|
|
5
|
+
* never echoed; its error stream goes to the terminal as the command writes it.
|
|
6
|
+
*/
|
|
7
|
+
/** A seed script that runs longer than this is stuck, not slow. */
|
|
8
|
+
const PREPARE_TIMEOUT_MS = 10 * 60_000;
|
|
9
|
+
/** Seed scripts print logs; the cap only stops a runaway one from filling memory. */
|
|
10
|
+
const MAX_OUTPUT_BYTES = 16 * 1024 * 1024;
|
|
11
|
+
/** The data from the last non-empty line of the output: a JSON object of strings or numbers. */
|
|
12
|
+
export function parsePrepareOutput(stdout) {
|
|
13
|
+
const lastLine = stdout
|
|
14
|
+
.split("\n")
|
|
15
|
+
.map((line) => line.trim())
|
|
16
|
+
.filter((line) => line.length > 0)
|
|
17
|
+
.at(-1);
|
|
18
|
+
const expected = 'its last line of output must be a JSON object of strings or numbers, e.g. {"email": "demo@example.com", "total": "12,345"}';
|
|
19
|
+
if (lastLine === undefined)
|
|
20
|
+
return { ok: false, error: `signIn.prepare printed nothing; ${expected}` };
|
|
21
|
+
let parsed;
|
|
22
|
+
try {
|
|
23
|
+
parsed = JSON.parse(lastLine);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// The line may hold a password, so the parse error, which quotes it, is not passed on.
|
|
27
|
+
return { ok: false, error: `signIn.prepare's last line is not JSON; ${expected}` };
|
|
28
|
+
}
|
|
29
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed))
|
|
30
|
+
return { ok: false, error: `signIn.prepare's last line is not a JSON object; ${expected}` };
|
|
31
|
+
const data = {};
|
|
32
|
+
for (const [key, value] of Object.entries(parsed)) {
|
|
33
|
+
if (typeof value === "string")
|
|
34
|
+
data[key] = value;
|
|
35
|
+
else if (typeof value === "number" && Number.isFinite(value))
|
|
36
|
+
data[key] = String(value);
|
|
37
|
+
else
|
|
38
|
+
return { ok: false, error: `signIn.prepare's value "${key}" is not a string or a number; ${expected}` };
|
|
39
|
+
}
|
|
40
|
+
return { ok: true, data };
|
|
41
|
+
}
|
|
42
|
+
/** Runs the command (no shell) and reads its data; a failure names the exit, never the output. */
|
|
43
|
+
export function runPrepare(command, options) {
|
|
44
|
+
const [program, ...args] = command;
|
|
45
|
+
const result = spawnSync(program, args, {
|
|
46
|
+
cwd: options.cwd,
|
|
47
|
+
env: { ...process.env, MARKETING_BASE_URL: options.baseUrl },
|
|
48
|
+
encoding: "utf8",
|
|
49
|
+
stdio: ["ignore", "pipe", "inherit"],
|
|
50
|
+
timeout: PREPARE_TIMEOUT_MS,
|
|
51
|
+
maxBuffer: MAX_OUTPUT_BYTES,
|
|
52
|
+
});
|
|
53
|
+
const shown = command.join(" ");
|
|
54
|
+
if (result.error !== undefined)
|
|
55
|
+
return { ok: false, error: `signIn.prepare (${shown}) could not run: ${result.error.message}` };
|
|
56
|
+
if (result.status !== 0)
|
|
57
|
+
return { ok: false, error: `signIn.prepare (${shown}) ended with code ${String(result.status ?? result.signal)}` };
|
|
58
|
+
return parsePrepareOutput(result.stdout);
|
|
59
|
+
}
|
|
60
|
+
//# sourceMappingURL=prepare.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepare.js","sourceRoot":"","sources":["../../src/screenshot/prepare.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;;;GAIG;AAEH,mEAAmE;AACnE,MAAM,kBAAkB,GAAG,EAAE,GAAG,MAAM,CAAC;AACvC,qFAAqF;AACrF,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAI1C,gGAAgG;AAChG,MAAM,UAAU,kBAAkB,CAAC,MAAc;IAC/C,MAAM,QAAQ,GAAG,MAAM;SACpB,KAAK,CAAC,IAAI,CAAC;SACX,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC;SACjC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IACV,MAAM,QAAQ,GAAG,4HAA4H,CAAC;IAC9I,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mCAAmC,QAAQ,EAAE,EAAE,CAAC;IACvG,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAChC,CAAC;IAAC,MAAM,CAAC;QACP,u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AQ,EAAE,MAAM,EAAE,SAAS,CAAC;QACpC,OAAO,EAAE,kBAAkB;QAC3B,SAAS,EAAE,gBAAgB;KAC5B,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IAChC,IAAI,MAAM,CAAC,KAAK,KAAK,SAAS;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,KAAK,oBAAoB,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;IAChI,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,mBAAmB,KAAK,qBAAqB,MAAM,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,CAAC;IAC5I,OAAO,kBAAkB,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;AAC3C,CAAC"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { ColorTheme } from "../config/colors.js";
|
|
2
2
|
import type { MarketingJson } from "../config/schema.js";
|
|
3
3
|
import { type ScreenshotGate } from "./gates.js";
|
|
4
|
+
import { type SignInPlan } from "./sign-in.js";
|
|
4
5
|
/**
|
|
5
6
|
* `softure-marketing shots`: the `screenshots` entries of `marketing.json`. Each shot of an entry
|
|
6
7
|
* (one per colour scheme, `config/screenshot-names.ts`) gets a fresh browser context with the entry's viewport, device
|
|
7
8
|
* scale and motion preference, and is kept only when it passes every gate (`gates.ts`) on its own.
|
|
8
9
|
* Every file an entry could write is removed before it runs, so a failed shot leaves no file behind,
|
|
9
|
-
* not even an older one: a stale PNG must never look like a fresh pass.
|
|
10
|
+
* not even an older one: a stale PNG must never look like a fresh pass. Entries with `signedIn` share one sign-in
|
|
11
|
+
* per run, and no two kept files of a run may have the same bytes.
|
|
10
12
|
*/
|
|
11
13
|
export type ScreenshotEntry = MarketingJson["screenshots"][number];
|
|
12
14
|
/** How the browser presents itself to the app, from `marketing.json`. */
|
|
@@ -29,6 +31,8 @@ export interface TakeScreenshotsOptions {
|
|
|
29
31
|
browser: ScreenshotBrowser;
|
|
30
32
|
/** A Chromium to use instead of Playwright's own (`PLAYWRIGHT_CHROMIUM_PATH`). */
|
|
31
33
|
executablePath?: string;
|
|
34
|
+
/** How `signedIn` entries sign in, placeholders resolved; without it, every `signedIn` shot is refused. */
|
|
35
|
+
signIn?: SignInPlan;
|
|
32
36
|
}
|
|
33
37
|
/** `id` is the entry's, `name` the file's without `.png` (`<id>` or `<id>-<scheme>`). */
|
|
34
38
|
export type ScreenshotResult = {
|
|
@@ -45,7 +49,10 @@ export type ScreenshotResult = {
|
|
|
45
49
|
message: string;
|
|
46
50
|
};
|
|
47
51
|
export declare function getScreenshotFile(outDir: string, name: string): string;
|
|
48
|
-
/**
|
|
52
|
+
/**
|
|
53
|
+
* Takes every shot of every entry in order; one failing shot does not stop the others. The sign-in runs once,
|
|
54
|
+
* before the first `signedIn` entry; when it fails, every `signedIn` shot is refused with its reason.
|
|
55
|
+
*/
|
|
49
56
|
export declare function takeScreenshots(options: TakeScreenshotsOptions): Promise<ScreenshotResult[]>;
|
|
50
57
|
export interface TakePageScreenshotOptions {
|
|
51
58
|
/** The shot's settings; its `path` is ignored, `url` is the page. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/screenshot/screenshot.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"screenshot.d.ts","sourceRoot":"","sources":["../../src/screenshot/screenshot.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAKzD,OAAO,EAA0H,KAAK,cAAc,EAAE,MAAM,YAAY,CAAC;AACzK,OAAO,EAA2C,KAAK,UAAU,EAAE,MAAM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