@dloizides/ui-tour 1.0.2 → 1.1.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.
@@ -0,0 +1,107 @@
1
+ 'use strict';
2
+
3
+ // src/playwright/TourRunFailure.ts
4
+ var TourRunFailure = /* @__PURE__ */ ((TourRunFailure2) => {
5
+ TourRunFailure2["NeverStarted"] = "never started";
6
+ TourRunFailure2["TargetMissing"] = "target missing";
7
+ TourRunFailure2["Stuck"] = "stuck";
8
+ TourRunFailure2["ClosedEarly"] = "closed early";
9
+ return TourRunFailure2;
10
+ })(TourRunFailure || {});
11
+ function tourFailure(tourId, step, steps, reason) {
12
+ return `tour ${tourId} step ${step}/${steps}: ${reason}`;
13
+ }
14
+
15
+ // src/playwright/playAllTours.ts
16
+ var START_PREFIX = "tour-start-";
17
+ var AUTO_SUFFIX = "-auto";
18
+ var AUTO_BUTTONS = `[data-testid^="${START_PREFIX}"][data-testid$="${AUTO_SUFFIX}"]`;
19
+ var CLOSED_GROUPS = '[data-testid^="tour-group-"][aria-expanded="false"]';
20
+ var PICKER = '[data-testid="tour-picker"]';
21
+ var CAPTION = '[data-testid="tour-caption"]';
22
+ var SKIP = '[data-testid="tour-skip"]';
23
+ var GONE_POLLS = 2;
24
+ var DEFAULT_STEP_TIMEOUT_MS = 3e4;
25
+ var DEFAULT_POLL_MS = 250;
26
+ async function expandGroups(page) {
27
+ const closed = page.locator(CLOSED_GROUPS);
28
+ let remaining = await closed.count();
29
+ while (remaining > 0) {
30
+ await closed.first().click();
31
+ const next = await closed.count();
32
+ if (next >= remaining) return;
33
+ remaining = next;
34
+ }
35
+ }
36
+ async function showPicker(page, options) {
37
+ if (await page.locator(PICKER).count() === 0) {
38
+ if (options.openPicker !== void 0) await options.openPicker(page);
39
+ else await page.keyboard.press("F2");
40
+ }
41
+ await expandGroups(page);
42
+ }
43
+ async function listTourIds(page) {
44
+ const buttons = page.locator(AUTO_BUTTONS);
45
+ const total = await buttons.count();
46
+ const ids = [];
47
+ for (let index = 0; index < total; index += 1) {
48
+ const testId = await buttons.nth(index).getAttribute("data-testid") ?? "";
49
+ ids.push(testId.slice(START_PREFIX.length, testId.length - AUTO_SUFFIX.length));
50
+ }
51
+ return ids;
52
+ }
53
+ function result(tourId, state, reason) {
54
+ if (reason === void 0) return { tourId, passed: true, step: state.step, steps: state.steps };
55
+ return { tourId, passed: false, step: state.step, steps: state.steps, reason, message: tourFailure(tourId, state.step, state.steps, reason) };
56
+ }
57
+ async function observe(page, tourId, state, timeoutMs) {
58
+ const caption = page.locator(CAPTION);
59
+ if (await caption.count() === 0) {
60
+ if (!state.seen) return state.sinceChangeMs >= timeoutMs ? result(tourId, state, "never started" /* NeverStarted */) : null;
61
+ state.gonePolls += 1;
62
+ if (state.gonePolls < GONE_POLLS) return null;
63
+ return state.step === state.steps ? result(tourId, state) : result(tourId, state, "closed early" /* ClosedEarly */);
64
+ }
65
+ state.gonePolls = 0;
66
+ const step = Number(await caption.getAttribute("data-tour-step"));
67
+ state.steps = Number(await caption.getAttribute("data-tour-steps"));
68
+ if (!state.seen || step !== state.step) {
69
+ state.seen = true;
70
+ state.step = step;
71
+ state.sinceChangeMs = 0;
72
+ }
73
+ if (await page.locator(SKIP).count() > 0) return result(tourId, state, "target missing" /* TargetMissing */);
74
+ return state.sinceChangeMs >= timeoutMs ? result(tourId, state, "stuck" /* Stuck */) : null;
75
+ }
76
+ async function playOne(page, tourId, options) {
77
+ const timeoutMs = options.stepTimeoutMs ?? DEFAULT_STEP_TIMEOUT_MS;
78
+ const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
79
+ await showPicker(page, options);
80
+ await page.locator(`[data-testid="${START_PREFIX}${tourId}${AUTO_SUFFIX}"]`).click();
81
+ const state = { seen: false, step: 0, steps: 0, sinceChangeMs: 0, gonePolls: 0 };
82
+ for (; ; ) {
83
+ const outcome = await observe(page, tourId, state, timeoutMs);
84
+ if (outcome !== null) return outcome;
85
+ await page.waitForTimeout(pollMs);
86
+ state.sinceChangeMs += pollMs;
87
+ }
88
+ }
89
+ async function playAllToursInAuto(page, options = {}) {
90
+ await showPicker(page, options);
91
+ const ids = options.ids ?? await listTourIds(page);
92
+ const results = [];
93
+ for (const id of ids) results.push(await playOne(page, id, options));
94
+ return results;
95
+ }
96
+ async function expectAllToursPlay(page, options = {}) {
97
+ const failures = (await playAllToursInAuto(page, options)).filter((run) => !run.passed).map((run) => run.message ?? run.tourId);
98
+ if (failures.length > 0) throw new Error(`Tours failed in Auto:
99
+ ${failures.join("\n")}`);
100
+ }
101
+
102
+ exports.TourRunFailure = TourRunFailure;
103
+ exports.expectAllToursPlay = expectAllToursPlay;
104
+ exports.playAllToursInAuto = playAllToursInAuto;
105
+ exports.tourFailure = tourFailure;
106
+ //# sourceMappingURL=index.js.map
107
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/playwright/TourRunFailure.ts","../../src/playwright/playAllTours.ts"],"names":["TourRunFailure"],"mappings":";;;AAAO,IAAK,cAAA,qBAAAA,eAAAA,KAAL;AACL,EAAAA,gBAAA,cAAA,CAAA,GAAe,eAAA;AACf,EAAAA,gBAAA,eAAA,CAAA,GAAgB,gBAAA;AAChB,EAAAA,gBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,gBAAA,aAAA,CAAA,GAAc,cAAA;AAJJ,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;AAQL,SAAS,WAAA,CAAY,MAAA,EAAgB,IAAA,EAAc,KAAA,EAAe,MAAA,EAAgC;AACvG,EAAA,OAAO,QAAQ,MAAM,CAAA,MAAA,EAAS,IAAI,CAAA,CAAA,EAAI,KAAK,KAAK,MAAM,CAAA,CAAA;AACxD;;;ACPA,IAAM,YAAA,GAAe,aAAA;AACrB,IAAM,WAAA,GAAc,OAAA;AACpB,IAAM,YAAA,GAAe,CAAA,eAAA,EAAkB,YAAY,CAAA,iBAAA,EAAoB,W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CAAA,CAAE,CAAA;AAC1F","file":"index.js","sourcesContent":["export enum TourRunFailure {\n NeverStarted = 'never started',\n TargetMissing = 'target missing',\n Stuck = 'stuck',\n ClosedEarly = 'closed early',\n}\n\n/** Formats one failed tour as `tour <id> step <n>/<m>: <reason>`. */\nexport function tourFailure(tourId: string, step: number, steps: number, reason: TourRunFailure): string {\n return `tour ${tourId} step ${step}/${steps}: ${reason}`;\n}\n","import { tourFailure, TourRunFailure } from './TourRunFailure';\nimport type { PlayToursOptions, TourPage, TourRunResult } from './types';\n\nconst START_PREFIX = 'tour-start-';\nconst AUTO_SUFFIX = '-auto';\nconst AUTO_BUTTONS = `[data-testid^=\"${START_PREFIX}\"][data-testid$=\"${AUTO_SUFFIX}\"]`;\nconst CLOSED_GROUPS = '[data-testid^=\"tour-group-\"][aria-expanded=\"false\"]';\nconst PICKER = '[data-testid=\"tour-picker\"]';\nconst CAPTION = '[data-testid=\"tour-caption\"]';\nconst SKIP = '[data-testid=\"tour-skip\"]';\nconst GONE_POLLS = 2;\nconst DEFAULT_STEP_TIMEOUT_MS = 30000;\nconst DEFAULT_POLL_MS = 250;\n\ninterface RunState {\n seen: boolean;\n step: number;\n steps: number;\n sinceChangeMs: number;\n gonePolls: number;\n}\n\nasync function expandGroups(page: TourPage): Promise<void> {\n const closed = page.locator(CLOSED_GROUPS);\n let remaining = await closed.count();\n while (remaining > 0) {\n await closed.first().click();\n const next = await closed.count();\n if (next >= remaining) return;\n remaining = next;\n }\n}\n\nasync function showPicker(page: TourPage, options: PlayToursOptions): Promise<void> {\n if ((await page.locator(PICKER).count()) === 0) {\n if (options.openPicker !== undefined) await options.openPicker(page);\n else await page.keyboard.press('F2');\n }\n await expandGroups(page);\n}\n\nasync function listTourIds(page: TourPage): Promise<string[]> {\n const buttons = page.locator(AUTO_BUTTONS);\n const total = await buttons.count();\n const ids: string[] = [];\n for (let index = 0; index < total; index += 1) {\n const testId = (await buttons.nth(index).getAttribute('data-testid')) ?? '';\n ids.push(testId.slice(START_PREFIX.length, testId.length - AUTO_SUFFIX.length));\n }\n return ids;\n}\n\nfunction result(tourId: string, state: RunState, reason?: TourRunFailure): TourRunResult {\n if (reason === undefined) return { tourId, passed: true, step: state.step, steps: state.steps };\n return { tourId, passed: false, step: state.step, steps: state.steps, reason, message: tourFailure(tourId, state.step, state.steps, reason) };\n}\n\nasync function observe(page: TourPage, tourId: string, state: RunState, timeoutMs: number): Promise<TourRunResult | null> {\n const caption = page.locator(CAPTION);\n if ((await caption.count()) === 0) {\n if (!state.seen) return state.sinceChangeMs >= timeoutMs ? result(tourId, state, TourRunFailure.NeverStarted) : null;\n state.gonePolls += 1;\n if (state.gonePolls < GONE_POLLS) return null;\n return state.step === state.steps ? result(tourId, state) : result(tourId, state, TourRunFailure.ClosedEarly);\n }\n state.gonePolls = 0;\n const step = Number(await caption.getAttribute('data-tour-step'));\n state.steps = Number(await caption.getAttribute('data-tour-steps'));\n if (!state.seen || step !== state.step) {\n state.seen = true;\n state.step = step;\n state.sinceChangeMs = 0;\n }\n if ((await page.locator(SKIP).count()) > 0) return result(tourId, state, TourRunFailure.TargetMissing);\n return state.sinceChangeMs >= timeoutMs ? result(tourId, state, TourRunFailure.Stuck) : null;\n}\n\nasync function playOne(page: TourPage, tourId: string, options: PlayToursOptions): Promise<TourRunResult> {\n const timeoutMs = options.stepTimeoutMs ?? DEFAULT_STEP_TIMEOUT_MS;\n const pollMs = options.pollMs ?? DEFAULT_POLL_MS;\n await showPicker(page, options);\n await page.locator(`[data-testid=\"${START_PREFIX}${tourId}${AUTO_SUFFIX}\"]`).click();\n const state: RunState = { seen: false, step: 0, steps: 0, sinceChangeMs: 0, gonePolls: 0 };\n for (;;) {\n const outcome = await observe(page, tourId, state, timeoutMs);\n if (outcome !== null) return outcome;\n await page.waitForTimeout(pollMs);\n state.sinceChangeMs += pollMs;\n }\n}\n\n/** Plays every tour in the picker (or `ids`) in Auto mode, one after another, and reports how far each got. */\nexport async function playAllToursInAuto(page: TourPage, options: PlayToursOptions = {}): Promise<TourRunResult[]> {\n await showPicker(page, options);\n const ids = options.ids ?? (await listTourIds(page));\n const results: TourRunResult[] = [];\n for (const id of ids) results.push(await playOne(page, id, options));\n return results;\n}\n\n/** One-line spec body: plays every tour in Auto and throws `tour <id> step <n>/<m>: <reason>` for each failure. */\nexport async function expectAllToursPlay(page: TourPage, options: PlayToursOptions = {}): Promise<void> {\n const failures = (await playAllToursInAuto(page, options)).filter((run) => !run.passed).map((run) => run.message ?? run.tourId);\n if (failures.length > 0) throw new Error(`Tours failed in Auto:\\n${failures.join('\\n')}`);\n}\n"]}
@@ -0,0 +1,102 @@
1
+ // src/playwright/TourRunFailure.ts
2
+ var TourRunFailure = /* @__PURE__ */ ((TourRunFailure2) => {
3
+ TourRunFailure2["NeverStarted"] = "never started";
4
+ TourRunFailure2["TargetMissing"] = "target missing";
5
+ TourRunFailure2["Stuck"] = "stuck";
6
+ TourRunFailure2["ClosedEarly"] = "closed early";
7
+ return TourRunFailure2;
8
+ })(TourRunFailure || {});
9
+ function tourFailure(tourId, step, steps, reason) {
10
+ return `tour ${tourId} step ${step}/${steps}: ${reason}`;
11
+ }
12
+
13
+ // src/playwright/playAllTours.ts
14
+ var START_PREFIX = "tour-start-";
15
+ var AUTO_SUFFIX = "-auto";
16
+ var AUTO_BUTTONS = `[data-testid^="${START_PREFIX}"][data-testid$="${AUTO_SUFFIX}"]`;
17
+ var CLOSED_GROUPS = '[data-testid^="tour-group-"][aria-expanded="false"]';
18
+ var PICKER = '[data-testid="tour-picker"]';
19
+ var CAPTION = '[data-testid="tour-caption"]';
20
+ var SKIP = '[data-testid="tour-skip"]';
21
+ var GONE_POLLS = 2;
22
+ var DEFAULT_STEP_TIMEOUT_MS = 3e4;
23
+ var DEFAULT_POLL_MS = 250;
24
+ async function expandGroups(page) {
25
+ const closed = page.locator(CLOSED_GROUPS);
26
+ let remaining = await closed.count();
27
+ while (remaining > 0) {
28
+ await closed.first().click();
29
+ const next = await closed.count();
30
+ if (next >= remaining) return;
31
+ remaining = next;
32
+ }
33
+ }
34
+ async function showPicker(page, options) {
35
+ if (await page.locator(PICKER).count() === 0) {
36
+ if (options.openPicker !== void 0) await options.openPicker(page);
37
+ else await page.keyboard.press("F2");
38
+ }
39
+ await expandGroups(page);
40
+ }
41
+ async function listTourIds(page) {
42
+ const buttons = page.locator(AUTO_BUTTONS);
43
+ const total = await buttons.count();
44
+ const ids = [];
45
+ for (let index = 0; index < total; index += 1) {
46
+ const testId = await buttons.nth(index).getAttribute("data-testid") ?? "";
47
+ ids.push(testId.slice(START_PREFIX.length, testId.length - AUTO_SUFFIX.length));
48
+ }
49
+ return ids;
50
+ }
51
+ function result(tourId, state, reason) {
52
+ if (reason === void 0) return { tourId, passed: true, step: state.step, steps: state.steps };
53
+ return { tourId, passed: false, step: state.step, steps: state.steps, reason, message: tourFailure(tourId, state.step, state.steps, reason) };
54
+ }
55
+ async function observe(page, tourId, state, timeoutMs) {
56
+ const caption = page.locator(CAPTION);
57
+ if (await caption.count() === 0) {
58
+ if (!state.seen) return state.sinceChangeMs >= timeoutMs ? result(tourId, state, "never started" /* NeverStarted */) : null;
59
+ state.gonePolls += 1;
60
+ if (state.gonePolls < GONE_POLLS) return null;
61
+ return state.step === state.steps ? result(tourId, state) : result(tourId, state, "closed early" /* ClosedEarly */);
62
+ }
63
+ state.gonePolls = 0;
64
+ const step = Number(await caption.getAttribute("data-tour-step"));
65
+ state.steps = Number(await caption.getAttribute("data-tour-steps"));
66
+ if (!state.seen || step !== state.step) {
67
+ state.seen = true;
68
+ state.step = step;
69
+ state.sinceChangeMs = 0;
70
+ }
71
+ if (await page.locator(SKIP).count() > 0) return result(tourId, state, "target missing" /* TargetMissing */);
72
+ return state.sinceChangeMs >= timeoutMs ? result(tourId, state, "stuck" /* Stuck */) : null;
73
+ }
74
+ async function playOne(page, tourId, options) {
75
+ const timeoutMs = options.stepTimeoutMs ?? DEFAULT_STEP_TIMEOUT_MS;
76
+ const pollMs = options.pollMs ?? DEFAULT_POLL_MS;
77
+ await showPicker(page, options);
78
+ await page.locator(`[data-testid="${START_PREFIX}${tourId}${AUTO_SUFFIX}"]`).click();
79
+ const state = { seen: false, step: 0, steps: 0, sinceChangeMs: 0, gonePolls: 0 };
80
+ for (; ; ) {
81
+ const outcome = await observe(page, tourId, state, timeoutMs);
82
+ if (outcome !== null) return outcome;
83
+ await page.waitForTimeout(pollMs);
84
+ state.sinceChangeMs += pollMs;
85
+ }
86
+ }
87
+ async function playAllToursInAuto(page, options = {}) {
88
+ await showPicker(page, options);
89
+ const ids = options.ids ?? await listTourIds(page);
90
+ const results = [];
91
+ for (const id of ids) results.push(await playOne(page, id, options));
92
+ return results;
93
+ }
94
+ async function expectAllToursPlay(page, options = {}) {
95
+ const failures = (await playAllToursInAuto(page, options)).filter((run) => !run.passed).map((run) => run.message ?? run.tourId);
96
+ if (failures.length > 0) throw new Error(`Tours failed in Auto:
97
+ ${failures.join("\n")}`);
98
+ }
99
+
100
+ export { TourRunFailure, expectAllToursPlay, playAllToursInAuto, tourFailure };
101
+ //# sourceMappingURL=index.mjs.map
102
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/playwright/TourRunFailure.ts","../../src/playwright/playAllTours.ts"],"names":["TourRunFailure"],"mappings":";AAAO,IAAK,cAAA,qBAAAA,eAAAA,KAAL;AACL,EAAAA,gBAAA,cAAA,CAAA,GAAe,eAAA;AACf,EAAAA,gBAAA,eAAA,CAAA,GAAgB,gBAAA;AAChB,EAAAA,gBAAA,OAAA,CAAA,GAAQ,OAAA;AACR,EAAAA,gBAAA,aAAA,CAAA,GAAc,cAAA;AAJJ,EAAA,OAAAA,eAAAA;AAAA,CAAA,EAAA,cAAA,IAAA,EAAA;AAQL,SAAS,WAAA,CAAY,MAAA,EAAgB,IAAA,EAAc,KAAA,EAAe,MAAA,EAAgC;AACvG,EAAA,OAAO,QAAQ,MAAM,CAAA,MAAA,EAAS,IAAI,CAAA,CAAA,EAAI,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AAI,OAAA,IAAW,IAAI,MAAM,CAAA;AAC9H,EAAA,IAAI,QAAA,CAAS,MAAA,GAAS,CAAA,EAAG,MAAM,IAAI,KAAA,CAAM,CAAA;AAAA,EAA0B,QAAA,CAAS,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AAC1F","file":"index.mjs","sourcesContent":["export enum TourRunFailure {\n NeverStarted = 'never started',\n TargetMissing = 'target missing',\n Stuck = 'stuck',\n ClosedEarly = 'closed early',\n}\n\n/** Formats one failed tour as `tour <id> step <n>/<m>: <reason>`. */\nexport function tourFailure(tourId: string, step: number, steps: number, reason: TourRunFailure): string {\n return `tour ${tourId} step ${step}/${steps}: ${reason}`;\n}\n","import { tourFailure, TourRunFailure } from './TourRunFailure';\nimport type { PlayToursOptions, TourPage, TourRunResult } from './types';\n\nconst START_PREFIX = 'tour-start-';\nconst AUTO_SUFFIX = '-auto';\nconst AUTO_BUTTONS = `[data-testid^=\"${START_PREFIX}\"][data-testid$=\"${AUTO_SUFFIX}\"]`;\nconst CLOSED_GROUPS = '[data-testid^=\"tour-group-\"][aria-expanded=\"false\"]';\nconst PICKER = '[data-testid=\"tour-picker\"]';\nconst CAPTION = '[data-testid=\"tour-caption\"]';\nconst SKIP = '[data-testid=\"tour-skip\"]';\nconst GONE_POLLS = 2;\nconst DEFAULT_STEP_TIMEOUT_MS = 30000;\nconst DEFAULT_POLL_MS = 250;\n\ninterface RunState {\n seen: boolean;\n step: number;\n steps: number;\n sinceChangeMs: number;\n gonePolls: number;\n}\n\nasync function expandGroups(page: TourPage): Promise<void> {\n const closed = page.locator(CLOSED_GROUPS);\n let remaining = await closed.count();\n while (remaining > 0) {\n await closed.first().click();\n const next = await closed.count();\n if (next >= remaining) return;\n remaining = next;\n }\n}\n\nasync function showPicker(page: TourPage, options: PlayToursOptions): Promise<void> {\n if ((await page.locator(PICKER).count()) === 0) {\n if (options.openPicker !== undefined) await options.openPicker(page);\n else await page.keyboard.press('F2');\n }\n await expandGroups(page);\n}\n\nasync function listTourIds(page: TourPage): Promise<string[]> {\n const buttons = page.locator(AUTO_BUTTONS);\n const total = await buttons.count();\n const ids: string[] = [];\n for (let index = 0; index < total; index += 1) {\n const testId = (await buttons.nth(index).getAttribute('data-testid')) ?? '';\n ids.push(testId.slice(START_PREFIX.length, testId.length - AUTO_SUFFIX.length));\n }\n return ids;\n}\n\nfunction result(tourId: string, state: RunState, reason?: TourRunFailure): TourRunResult {\n if (reason === undefined) return { tourId, passed: true, step: state.step, steps: state.steps };\n return { tourId, passed: false, step: state.step, steps: state.steps, reason, message: tourFailure(tourId, state.step, state.steps, reason) };\n}\n\nasync function observe(page: TourPage, tourId: string, state: RunState, timeoutMs: number): Promise<TourRunResult | null> {\n const caption = page.locator(CAPTION);\n if ((await caption.count()) === 0) {\n if (!state.seen) return state.sinceChangeMs >= timeoutMs ? result(tourId, state, TourRunFailure.NeverStarted) : null;\n state.gonePolls += 1;\n if (state.gonePolls < GONE_POLLS) return null;\n return state.step === state.steps ? result(tourId, state) : result(tourId, state, TourRunFailure.ClosedEarly);\n }\n state.gonePolls = 0;\n const step = Number(await caption.getAttribute('data-tour-step'));\n state.steps = Number(await caption.getAttribute('data-tour-steps'));\n if (!state.seen || step !== state.step) {\n state.seen = true;\n state.step = step;\n state.sinceChangeMs = 0;\n }\n if ((await page.locator(SKIP).count()) > 0) return result(tourId, state, TourRunFailure.TargetMissing);\n return state.sinceChangeMs >= timeoutMs ? result(tourId, state, TourRunFailure.Stuck) : null;\n}\n\nasync function playOne(page: TourPage, tourId: string, options: PlayToursOptions): Promise<TourRunResult> {\n const timeoutMs = options.stepTimeoutMs ?? DEFAULT_STEP_TIMEOUT_MS;\n const pollMs = options.pollMs ?? DEFAULT_POLL_MS;\n await showPicker(page, options);\n await page.locator(`[data-testid=\"${START_PREFIX}${tourId}${AUTO_SUFFIX}\"]`).click();\n const state: RunState = { seen: false, step: 0, steps: 0, sinceChangeMs: 0, gonePolls: 0 };\n for (;;) {\n const outcome = await observe(page, tourId, state, timeoutMs);\n if (outcome !== null) return outcome;\n await page.waitForTimeout(pollMs);\n state.sinceChangeMs += pollMs;\n }\n}\n\n/** Plays every tour in the picker (or `ids`) in Auto mode, one after another, and reports how far each got. */\nexport async function playAllToursInAuto(page: TourPage, options: PlayToursOptions = {}): Promise<TourRunResult[]> {\n await showPicker(page, options);\n const ids = options.ids ?? (await listTourIds(page));\n const results: TourRunResult[] = [];\n for (const id of ids) results.push(await playOne(page, id, options));\n return results;\n}\n\n/** One-line spec body: plays every tour in Auto and throws `tour <id> step <n>/<m>: <reason>` for each failure. */\nexport async function expectAllToursPlay(page: TourPage, options: PlayToursOptions = {}): Promise<void> {\n const failures = (await playAllToursInAuto(page, options)).filter((run) => !run.passed).map((run) => run.message ?? run.tourId);\n if (failures.length > 0) throw new Error(`Tours failed in Auto:\\n${failures.join('\\n')}`);\n}\n"]}
@@ -0,0 +1,9 @@
1
+ import { Tour } from '@dloizides/ui-tour';
2
+
3
+ type Translations = Readonly<Record<string, unknown>>;
4
+ /** Lists every problem in key-based tour data: shape errors, missing translation keys, malformed targets, write-control clicks. */
5
+ declare function findTourProblems(tours: readonly Tour[], translations: Translations): string[];
6
+ /** Throws one error listing every problem `findTourProblems` finds; call it from a jest test. */
7
+ declare function expectValidTours(tours: readonly Tour[], translations: Translations): void;
8
+
9
+ export { type Translations, expectValidTours, findTourProblems };
@@ -0,0 +1,9 @@
1
+ import { Tour } from '@dloizides/ui-tour';
2
+
3
+ type Translations = Readonly<Record<string, unknown>>;
4
+ /** Lists every problem in key-based tour data: shape errors, missing translation keys, malformed targets, write-control clicks. */
5
+ declare function findTourProblems(tours: readonly Tour[], translations: Translations): string[];
6
+ /** Throws one error listing every problem `findTourProblems` finds; call it from a jest test. */
7
+ declare function expectValidTours(tours: readonly Tour[], translations: Translations): void;
8
+
9
+ export { type Translations, expectValidTours, findTourProblems };
@@ -0,0 +1,52 @@
1
+ 'use strict';
2
+
3
+ var uiTour = require('@dloizides/ui-tour');
4
+
5
+ // src/testing/findTourProblems.ts
6
+ var TEST_ID = /^[A-Za-z0-9][\w.:-]*$/;
7
+ var TEST_ID_SEPARATOR = /[-_.:]/;
8
+ var ROLES = new Set(Object.values(uiTour.TargetRole));
9
+ function lookup(translations, key) {
10
+ return key.split(".").reduce((node, part) => node !== null && typeof node === "object" ? node[part] : void 0, translations);
11
+ }
12
+ function keyProblem(translations, where, field, key) {
13
+ const value = lookup(translations, key);
14
+ return typeof value === "string" && value !== "" ? [] : [`${where}: ${field} key "${key}" is missing in translations`];
15
+ }
16
+ function targetProblems(where, target) {
17
+ if (typeof target === "string") return TEST_ID.test(target) ? [] : [`${where}: malformed target "${target}"`];
18
+ const problems = [];
19
+ if (!ROLES.has(target.role)) problems.push(`${where}: unknown role "${String(target.role)}"`);
20
+ if (target.nth !== void 0 && !(Number.isInteger(target.nth) && target.nth >= 0)) problems.push(`${where}: nth must be a whole number >= 0`);
21
+ return problems;
22
+ }
23
+ function targetNames(target) {
24
+ if (typeof target === "string") return target.split(TEST_ID_SEPARATOR).filter((token) => token !== "");
25
+ return [target.name instanceof RegExp ? target.name.source.replace(/^\^/, "") : target.name];
26
+ }
27
+ function writeProblem(where, tour, step) {
28
+ if (step.action !== uiTour.StepAction.Click) return [];
29
+ const name = targetNames(step.target).find((candidate) => uiTour.isForbiddenClick(candidate, tour.allowSave === true));
30
+ return name === void 0 ? [] : [`${where}: clicks write control "${name}"`];
31
+ }
32
+ function tourProblems(tour, translations) {
33
+ const problems = [...keyProblem(translations, `tour ${tour.id}`, "title", tour.title), ...keyProblem(translations, `tour ${tour.id}`, "category", tour.category)];
34
+ (Array.isArray(tour.steps) ? tour.steps : []).forEach((step, index) => {
35
+ const where = `tour ${tour.id} step ${index + 1}`;
36
+ problems.push(...keyProblem(translations, where, "text", step.text), ...targetProblems(where, step.target), ...writeProblem(where, tour, step));
37
+ });
38
+ return problems;
39
+ }
40
+ function findTourProblems(tours, translations) {
41
+ return [...uiTour.validateTours(tours).errors, ...tours.flatMap((tour) => tourProblems(tour, translations))];
42
+ }
43
+ function expectValidTours(tours, translations) {
44
+ const problems = findTourProblems(tours, translations);
45
+ if (problems.length > 0) throw new Error(`Invalid tours:
46
+ ${problems.join("\n")}`);
47
+ }
48
+
49
+ exports.expectValidTours = expectValidTours;
50
+ exports.findTourProblems = findTourProblems;
51
+ //# sourceMappingURL=index.js.map
52
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/testing/findTourProblems.ts"],"names":["TargetRole","StepAction","isForbiddenClick","validateTours"],"mappings":";;;;;AAKA,IAAM,OAAA,GAAU,uBAAA;AAChB,IAAM,iBAAA,GAAoB,QAAA;AAC1B,IAAM,QAAQ,IAAI,GAAA,CAAY,MAAA,CAAO,MAAA,CAAOA,iBAAU,CAAC,CAAA;AAEvD,SAAS,MAAA,CAAO,cAA4B,GAAA,EAAsB;AAChE,EAAA,OAAO,IAAI,KAAA,CAAM,GAAG,CAAA,CAAE,MAAA,CAAgB,CAAC,IAAA,EAAM,IAAA,KAAU,IAAA,KAAS,IAAA,IAAQ,OAAO,IAAA,KAAS,QAAA,GAAY,KAAiC,IAAI,CAAA,GAAI,QAAY,YAAY,CAAA;AACvK;AAEA,SAAS,UAAA,CAAW,YAAA,EAA4B,KAAA,EAAe,KAAA,EAAe,GAAA,EAAuB;AACnG,EAAA,MAAM,KAAA,GAAQ,MAAA,CAAO,YAAA,EAAc,GAAG,CAAA;AACtC,EAAA,OAAO,OAAO,KAAA,KAAU,QAAA,IAAY,KAAA,KAAU,KAAK,EAAC,GAAI,CAAC,CAAA,EAAG,KAAK,CAAA,EAAA,EAAK,KAAK,CAAA,MAAA,EAAS,GAAG,CAAA,4BAAA,CAA8B,CAAA;AACvH;AAEA,SAAS,cAAA,CAAe,OAAe,MAAA,EAA8B;AACnE,EAAA,IAAI,OAAO,MAAA,KAAW,QAAA,EAAU,OAAO,QAAQ,IAAA,CAAK,MAAM,CAAA,GAAI,KAAK,CAAC,CAAA,EA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C;AACzF,EAAA,MAAM,QAAA,GAAW,gBAAA,CAAiB,KAAA,EAAO,YAAY,CAAA;AACrD,EAAA,IAAI,QAAA,CAAS,MAAA,GAAS,CAAA,EAAG,MAAM,IAAI,KAAA,CAAM,CAAA;AAAA,EAAmB,QAAA,CAAS,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACnF","file":"index.js","sourcesContent":["import { isForbiddenClick, StepAction, TargetRole, validateTours } from '@dloizides/ui-tour';\nimport type { StepTarget, Tour, TourStep } from '@dloizides/ui-tour';\n\nexport type Translations = Readonly<Record<string, unknown>>;\n\nconst TEST_ID = /^[A-Za-z0-9][\\w.:-]*$/;\nconst TEST_ID_SEPARATOR = /[-_.:]/;\nconst ROLES = new Set<string>(Object.values(TargetRole));\n\nfunction lookup(translations: Translations, key: string): unknown {\n return key.split('.').reduce<unknown>((node, part) => (node !== null && typeof node === 'object' ? (node as Record<string, unknown>)[part] : undefined), translations);\n}\n\nfunction keyProblem(translations: Translations, where: string, field: string, key: string): string[] {\n const value = lookup(translations, key);\n return typeof value === 'string' && value !== '' ? [] : [`${where}: ${field} key \"${key}\" is missing in translations`];\n}\n\nfunction targetProblems(where: string, target: StepTarget): string[] {\n if (typeof target === 'string') return TEST_ID.test(target) ? [] : [`${where}: malformed target \"${target}\"`];\n const problems: string[] = [];\n if (!ROLES.has(target.role)) problems.push(`${where}: unknown role \"${String(target.role)}\"`);\n if (target.nth !== undefined && !(Number.isInteger(target.nth) && target.nth >= 0)) problems.push(`${where}: nth must be a whole number >= 0`);\n return problems;\n}\n\nfunction targetNames(target: StepTarget): string[] {\n if (typeof target === 'string') return target.split(TEST_ID_SEPARATOR).filter((token) => token !== '');\n return [target.name instanceof RegExp ? target.name.source.replace(/^\\^/, '') : target.name];\n}\n\nfunction writeProblem(where: string, tour: Tour, step: TourStep): string[] {\n if (step.action !== StepAction.Click) return [];\n const name = targetNames(step.target).find((candidate) => isForbiddenClick(candidate, tour.allowSave === true));\n return name === undefined ? [] : [`${where}: clicks write control \"${name}\"`];\n}\n\nfunction tourProblems(tour: Tour, translations: Translations): string[] {\n const problems = [...keyProblem(translations, `tour ${tour.id}`, 'title', tour.title), ...keyProblem(translations, `tour ${tour.id}`, 'category', tour.category)];\n (Array.isArray(tour.steps) ? tour.steps : []).forEach((step, index) => {\n const where = `tour ${tour.id} step ${index + 1}`;\n problems.push(...keyProblem(translations, where, 'text', step.text), ...targetProblems(where, step.target), ...writeProblem(where, tour, step));\n });\n return problems;\n}\n\n/** Lists every problem in key-based tour data: shape errors, missing translation keys, malformed targets, write-control clicks. */\nexport function findTourProblems(tours: readonly Tour[], translations: Translations): string[] {\n return [...validateTours(tours).errors, ...tours.flatMap((tour) => tourProblems(tour, translations))];\n}\n\n/** Throws one error listing every problem `findTourProblems` finds; call it from a jest test. */\nexport function expectValidTours(tours: readonly Tour[], translations: Translations): void {\n const problems = findTourProblems(tours, translations);\n if (problems.length > 0) throw new Error(`Invalid tours:\\n${problems.join('\\n')}`);\n}\n"]}
@@ -0,0 +1,49 @@
1
+ import { TargetRole, validateTours, StepAction, isForbiddenClick } from '@dloizides/ui-tour';
2
+
3
+ // src/testing/findTourProblems.ts
4
+ var TEST_ID = /^[A-Za-z0-9][\w.:-]*$/;
5
+ var TEST_ID_SEPARATOR = /[-_.:]/;
6
+ var ROLES = new Set(Object.values(TargetRole));
7
+ function lookup(translations, key) {
8
+ return key.split(".").reduce((node, part) => node !== null && typeof node === "object" ? node[part] : void 0, translations);
9
+ }
10
+ function keyProblem(translations, where, field, key) {
11
+ const value = lookup(translations, key);
12
+ return typeof value === "string" && value !== "" ? [] : [`${where}: ${field} key "${key}" is missing in translations`];
13
+ }
14
+ function targetProblems(where, target) {
15
+ if (typeof target === "string") return TEST_ID.test(target) ? [] : [`${where}: malformed target "${target}"`];
16
+ const problems = [];
17
+ if (!ROLES.has(target.role)) problems.push(`${where}: unknown role "${String(target.role)}"`);
18
+ if (target.nth !== void 0 && !(Number.isInteger(target.nth) && target.nth >= 0)) problems.push(`${where}: nth must be a whole number >= 0`);
19
+ return problems;
20
+ }
21
+ function targetNames(target) {
22
+ if (typeof target === "string") return target.split(TEST_ID_SEPARATOR).filter((token) => token !== "");
23
+ return [target.name instanceof RegExp ? target.name.source.replace(/^\^/, "") : target.name];
24
+ }
25
+ function writeProblem(where, tour, step) {
26
+ if (step.action !== StepAction.Click) return [];
27
+ const name = targetNames(step.target).find((candidate) => isForbiddenClick(candidate, tour.allowSave === true));
28
+ return name === void 0 ? [] : [`${where}: clicks write control "${name}"`];
29
+ }
30
+ function tourProblems(tour, translations) {
31
+ const problems = [...keyProblem(translations, `tour ${tour.id}`, "title", tour.title), ...keyProblem(translations, `tour ${tour.id}`, "category", tour.category)];
32
+ (Array.isArray(tour.steps) ? tour.steps : []).forEach((step, index) => {
33
+ const where = `tour ${tour.id} step ${index + 1}`;
34
+ problems.push(...keyProblem(translations, where, "text", step.text), ...targetProblems(where, step.target), ...writeProblem(where, tour, step));
35
+ });
36
+ return problems;
37
+ }
38
+ function findTourProblems(tours, translations) {
39
+ return [...validateTours(tours).errors, ...tours.flatMap((tour) => tourProblems(tour, translations))];
40
+ }
41
+ function expectValidTours(tours, translations) {
42
+ const problems = findTourProblems(tours, translations);
43
+ if (problems.length > 0) throw new Error(`Invalid tours:
44
+ ${problems.join("\n")}`);
45
+ }
46
+
47
+ export { expectValidTours, findTourProblems };
48
+ //# sourceMappingURL=index.mjs.map
49
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/testing/findTourProblems.ts"],"names":[],"mappings":";;;AAKA,IAAM,OAAA,GAAU,uBAAA;AAChB,IAAM,iBAAA,GAAoB,QAAA;AAC1B,IAAM,QAAQ,IAAI,GAAA,CAAY,MAAA,CAAO,MAAA,CAAO,UAAU,CAAC,CAAA;AAEvD,SAAS,MAAA,CAAO,cAA4B,GAAA,EAAsB;AAChE,EAAA,OAAO,IAAI,KAAA,CAAM,GAAG,CAAA,CAAE,MAA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A,KAAA,EAAQ,IAAA,CAAK,EAAE,CAAA,MAAA,EAAS,QAAQ,CAAC,CAAA,CAAA;AAC/C,IAAA,QAAA,CAAS,IAAA,CAAK,GAAG,UAAA,CAAW,YAAA,EAAc,OAAO,MAAA,EAAQ,IAAA,CAAK,IAAI,CAAA,EAAG,GAAG,eAAe,KAAA,EAAO,IAAA,CAAK,MAAM,CAAA,EAAG,GAAG,aAAa,KAAA,EAAO,IAAA,EAAM,IAAI,CAAC,CAAA;AAAA,EAChJ,CAAC,CAAA;AACD,EAAA,OAAO,QAAA;AACT;AAGO,SAAS,gBAAA,CAAiB,OAAwB,YAAA,EAAsC;AAC7F,EAAA,OAAO,CAAC,GAAG,aAAA,CAAc,KAAK,EAAE,MAAA,EAAQ,GAAG,KAAA,CAAM,OAAA,CAAQ,CAAC,IAAA,KAAS,YAAA,CAAa,IAAA,EAAM,YAAY,CAAC,CAAC,CAAA;AACtG;AAGO,SAAS,gBAAA,CAAiB,OAAwB,YAAA,EAAkC;AACzF,EAAA,MAAM,QAAA,GAAW,gBAAA,CAAiB,KAAA,EAAO,YAAY,CAAA;AACrD,EAAA,IAAI,QAAA,CAAS,MAAA,GAAS,CAAA,EAAG,MAAM,IAAI,KAAA,CAAM,CAAA;AAAA,EAAmB,QAAA,CAAS,IAAA,CAAK,IAAI,CAAC,CAAA,CAAE,CAAA;AACnF","file":"index.mjs","sourcesContent":["import { isForbiddenClick, StepAction, TargetRole, validateTours } from '@dloizides/ui-tour';\nimport type { StepTarget, Tour, TourStep } from '@dloizides/ui-tour';\n\nexport type Translations = Readonly<Record<string, unknown>>;\n\nconst TEST_ID = /^[A-Za-z0-9][\\w.:-]*$/;\nconst TEST_ID_SEPARATOR = /[-_.:]/;\nconst ROLES = new Set<string>(Object.values(TargetRole));\n\nfunction lookup(translations: Translations, key: string): unknown {\n return key.split('.').reduce<unknown>((node, part) => (node !== null && typeof node === 'object' ? (node as Record<string, unknown>)[part] : undefined), translations);\n}\n\nfunction keyProblem(translations: Translations, where: string, field: string, key: string): string[] {\n const value = lookup(translations, key);\n return typeof value === 'string' && value !== '' ? [] : [`${where}: ${field} key \"${key}\" is missing in translations`];\n}\n\nfunction targetProblems(where: string, target: StepTarget): string[] {\n if (typeof target === 'string') return TEST_ID.test(target) ? [] : [`${where}: malformed target \"${target}\"`];\n const problems: string[] = [];\n if (!ROLES.has(target.role)) problems.push(`${where}: unknown role \"${String(target.role)}\"`);\n if (target.nth !== undefined && !(Number.isInteger(target.nth) && target.nth >= 0)) problems.push(`${where}: nth must be a whole number >= 0`);\n return problems;\n}\n\nfunction targetNames(target: StepTarget): string[] {\n if (typeof target === 'string') return target.split(TEST_ID_SEPARATOR).filter((token) => token !== '');\n return [target.name instanceof RegExp ? target.name.source.replace(/^\\^/, '') : target.name];\n}\n\nfunction writeProblem(where: string, tour: Tour, step: TourStep): string[] {\n if (step.action !== StepAction.Click) return [];\n const name = targetNames(step.target).find((candidate) => isForbiddenClick(candidate, tour.allowSave === true));\n return name === undefined ? [] : [`${where}: clicks write control \"${name}\"`];\n}\n\nfunction tourProblems(tour: Tour, translations: Translations): string[] {\n const problems = [...keyProblem(translations, `tour ${tour.id}`, 'title', tour.title), ...keyProblem(translations, `tour ${tour.id}`, 'category', tour.category)];\n (Array.isArray(tour.steps) ? tour.steps : []).forEach((step, index) => {\n const where = `tour ${tour.id} step ${index + 1}`;\n problems.push(...keyProblem(translations, where, 'text', step.text), ...targetProblems(where, step.target), ...writeProblem(where, tour, step));\n });\n return problems;\n}\n\n/** Lists every problem in key-based tour data: shape errors, missing translation keys, malformed targets, write-control clicks. */\nexport function findTourProblems(tours: readonly Tour[], translations: Translations): string[] {\n return [...validateTours(tours).errors, ...tours.flatMap((tour) => tourProblems(tour, translations))];\n}\n\n/** Throws one error listing every problem `findTourProblems` finds; call it from a jest test. */\nexport function expectValidTours(tours: readonly Tour[], translations: Translations): void {\n const problems = findTourProblems(tours, translations);\n if (problems.length > 0) throw new Error(`Invalid tours:\\n${problems.join('\\n')}`);\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dloizides/ui-tour",
3
- "version": "1.0.2",
3
+ "version": "1.1.0",
4
4
  "description": "In-app guided tours for React Native Web apps: Guide me, Show me and Auto modes with a themed ring, caption, cursor, tour picker and first-run offer. Write controls are never clicked. Web only; renders nothing on native.",
5
5
  "keywords": [
6
6
  "react",
@@ -46,6 +46,72 @@
46
46
  "types": "./dist/index.d.ts",
47
47
  "default": "./dist/index.js"
48
48
  }
49
+ },
50
+ "./expo": {
51
+ "react-native": {
52
+ "types": "./dist/expo/index.d.ts",
53
+ "default": "./dist/expo/index.js"
54
+ },
55
+ "browser": {
56
+ "types": "./dist/expo/index.d.ts",
57
+ "default": "./dist/expo/index.js"
58
+ },
59
+ "require": {
60
+ "types": "./dist/expo/index.d.ts",
61
+ "default": "./dist/expo/index.js"
62
+ },
63
+ "import": {
64
+ "types": "./dist/expo/index.d.mts",
65
+ "default": "./dist/expo/index.mjs"
66
+ },
67
+ "default": {
68
+ "types": "./dist/expo/index.d.ts",
69
+ "default": "./dist/expo/index.js"
70
+ }
71
+ },
72
+ "./testing": {
73
+ "react-native": {
74
+ "types": "./dist/testing/index.d.ts",
75
+ "default": "./dist/testing/index.js"
76
+ },
77
+ "browser": {
78
+ "types": "./dist/testing/index.d.ts",
79
+ "default": "./dist/testing/index.js"
80
+ },
81
+ "require": {
82
+ "types": "./dist/testing/index.d.ts",
83
+ "default": "./dist/testing/index.js"
84
+ },
85
+ "import": {
86
+ "types": "./dist/testing/index.d.mts",
87
+ "default": "./dist/testing/index.mjs"
88
+ },
89
+ "default": {
90
+ "types": "./dist/testing/index.d.ts",
91
+ "default": "./dist/testing/index.js"
92
+ }
93
+ },
94
+ "./playwright": {
95
+ "react-native": {
96
+ "types": "./dist/playwright/index.d.ts",
97
+ "default": "./dist/playwright/index.js"
98
+ },
99
+ "browser": {
100
+ "types": "./dist/playwright/index.d.ts",
101
+ "default": "./dist/playwright/index.js"
102
+ },
103
+ "require": {
104
+ "types": "./dist/playwright/index.d.ts",
105
+ "default": "./dist/playwright/index.js"
106
+ },
107
+ "import": {
108
+ "types": "./dist/playwright/index.d.mts",
109
+ "default": "./dist/playwright/index.mjs"
110
+ },
111
+ "default": {
112
+ "types": "./dist/playwright/index.d.ts",
113
+ "default": "./dist/playwright/index.js"
114
+ }
49
115
  }
50
116
  },
51
117
  "files": [
@@ -78,9 +144,18 @@
78
144
  "peerDependencies": {
79
145
  "react": ">=18.0.0",
80
146
  "react-dom": ">=18.0.0",
81
- "react-native": ">=0.74.0"
147
+ "react-native": ">=0.74.0",
148
+ "expo-router": ">=4.0.0",
149
+ "@playwright/test": ">=1.40.0"
150
+ },
151
+ "peerDependenciesMeta": {
152
+ "expo-router": {
153
+ "optional": true
154
+ },
155
+ "@playwright/test": {
156
+ "optional": true
157
+ }
82
158
  },
83
- "peerDependenciesMeta": {},
84
159
  "devDependencies": {
85
160
  "@testing-library/dom": "^10.4.0",
86
161
  "@testing-library/jest-dom": "^6.6.3",
@@ -104,5 +179,18 @@
104
179
  "ts-jest": "^29.1.0",
105
180
  "tsup": "^8.0.0",
106
181
  "typescript": "^5.4.0"
182
+ },
183
+ "typesVersions": {
184
+ "*": {
185
+ "expo": [
186
+ "dist/expo/index.d.ts"
187
+ ],
188
+ "testing": [
189
+ "dist/testing/index.d.ts"
190
+ ],
191
+ "playwright": [
192
+ "dist/playwright/index.d.ts"
193
+ ]
194
+ }
107
195
  }
108
196
  }