@ingcreators/annot-product-docs 0.1.0 → 0.3.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/CHANGELOG.md +295 -0
- package/README.md +41 -6
- package/dist/cli.d.ts +29 -0
- package/dist/config.d.ts +184 -0
- package/dist/drift.d.ts +77 -0
- package/dist/fixture.d.ts +111 -0
- package/dist/index.d.ts +14 -0
- package/dist/index.js +947 -0
- package/dist/mdx-annotations.d.ts +91 -0
- package/dist/mdx.d.ts +41 -0
- package/dist/playwright-screenshot-hook.d.ts +17 -0
- package/dist/resolver.d.ts +58 -0
- package/dist/types-config.d.ts +18 -0
- package/dist/types.d.ts +106 -0
- package/package.json +6 -6
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { Locator, Page } from '@playwright/test';
|
|
2
|
+
import { OverlaySpec } from './types.js';
|
|
3
|
+
export interface ProductDocsSyncOptions {
|
|
4
|
+
/** Must match a `<Screen id="...">` JSX block in the MDX file. */
|
|
5
|
+
id: string;
|
|
6
|
+
/** Absolute or cwd-relative path to the `.mdx` file. */
|
|
7
|
+
mdxPath: string;
|
|
8
|
+
/**
|
|
9
|
+
* Override the locator used as the snapshot root. Defaults to
|
|
10
|
+
* the page's `body` element. Useful when the test is scoped to
|
|
11
|
+
* a specific dialog or section.
|
|
12
|
+
*/
|
|
13
|
+
rootLocator?: Locator;
|
|
14
|
+
/**
|
|
15
|
+
* Override the HTML attribute whitelist for `annot:attributes`
|
|
16
|
+
* collection. Default is `DEFAULT_ATTR_WHITELIST` — covers the
|
|
17
|
+
* common form-control + accessibility attrs.
|
|
18
|
+
*/
|
|
19
|
+
attributeWhitelist?: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* @deprecated Renamed to {@link ProductDocsSyncOptions} in Phase 3
|
|
23
|
+
* of `docs/plans/playwright-screenshot-fixture-relayer.md` for
|
|
24
|
+
* naming clarity (the helper synchronizes the MDX comment blocks
|
|
25
|
+
* with the live UI — it does not take a screenshot). The old name
|
|
26
|
+
* keeps working but new code should use `ProductDocsSyncOptions`.
|
|
27
|
+
*/
|
|
28
|
+
export type ScreenCaptureOptions = ProductDocsSyncOptions;
|
|
29
|
+
export interface ProductDocs {
|
|
30
|
+
sync(opts: ProductDocsSyncOptions): Promise<void>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* @deprecated Renamed to {@link ProductDocs} in Phase 3 of
|
|
34
|
+
* `docs/plans/playwright-screenshot-fixture-relayer.md`. The old
|
|
35
|
+
* `Screen` name is ambiguous (collides with `@testing-library/react`'s
|
|
36
|
+
* `screen` + reads like a Playwright built-in). New code should
|
|
37
|
+
* use `ProductDocs`.
|
|
38
|
+
*/
|
|
39
|
+
export type Screen = ProductDocs;
|
|
40
|
+
/**
|
|
41
|
+
* HTML attributes captured into the `annot:attributes` block by
|
|
42
|
+
* default. Focused on form-control + accessibility shape — the
|
|
43
|
+
* stuff a screen-specifications spreadsheet / operation manual cares about per element.
|
|
44
|
+
*
|
|
45
|
+
* Hosts can override per-call via `opts.attributeWhitelist`.
|
|
46
|
+
*/
|
|
47
|
+
export declare const DEFAULT_ATTR_WHITELIST: readonly string[];
|
|
48
|
+
/**
|
|
49
|
+
* `test = annotatorTest.extend({ productDocs })` — drop-in for
|
|
50
|
+
* `@playwright/test`'s `test` plus a `productDocs` fixture for
|
|
51
|
+
* the docs flow. Tour files (`tests/docs/*.spec.ts`) import this
|
|
52
|
+
* `test` instead of `@playwright/test`:
|
|
53
|
+
*
|
|
54
|
+
* ```ts
|
|
55
|
+
* import { test } from "@ingcreators/annot-product-docs";
|
|
56
|
+
*
|
|
57
|
+
* test("login flow", async ({ page, productDocs }) => {
|
|
58
|
+
* await page.goto("/login");
|
|
59
|
+
* await productDocs.sync({
|
|
60
|
+
* id: "login",
|
|
61
|
+
* mdxPath: "docs/books/screen-spec/screens/SC-001-login.mdx",
|
|
62
|
+
* });
|
|
63
|
+
* });
|
|
64
|
+
* ```
|
|
65
|
+
*
|
|
66
|
+
* For back-compat the same fixture is also exposed as `screen`
|
|
67
|
+
* with a `.capture()` method (deprecated since Phase 3 of the
|
|
68
|
+
* relayer plan; remove after the documented deprecation window).
|
|
69
|
+
*/
|
|
70
|
+
export declare const test: import('@playwright/test').TestType<import('@playwright/test').PlaywrightTestArgs & import('@playwright/test').PlaywrightTestOptions & {
|
|
71
|
+
annotator: import('@ingcreators/annot-playwright').PlaywrightAnnotator;
|
|
72
|
+
} & {
|
|
73
|
+
productDocs: ProductDocs;
|
|
74
|
+
screen: ProductDocs;
|
|
75
|
+
}, import('@playwright/test').PlaywrightWorkerArgs & import('@playwright/test').PlaywrightWorkerOptions>;
|
|
76
|
+
/**
|
|
77
|
+
* Standalone sync helper — same behaviour as
|
|
78
|
+
* `productDocs.sync(...)` but takes the `Page` directly.
|
|
79
|
+
* Exported so callers who build their own Playwright fixture
|
|
80
|
+
* (e.g. composing additional fixtures on top) can still drive
|
|
81
|
+
* the docs-sync flow.
|
|
82
|
+
*
|
|
83
|
+
* Idempotent: if `mdxPath` already has `annot:snapshot` /
|
|
84
|
+
* `annot:attributes` blocks, they're replaced in place; if not,
|
|
85
|
+
* they're appended. Files without `annot:` frontmatter throw —
|
|
86
|
+
* the fixture refuses to touch non-annot MDX.
|
|
87
|
+
*/
|
|
88
|
+
export declare function syncProductDocs(page: Page, opts: ProductDocsSyncOptions): Promise<void>;
|
|
89
|
+
/**
|
|
90
|
+
* @deprecated Renamed to {@link syncProductDocs} in Phase 3 of
|
|
91
|
+
* `docs/plans/playwright-screenshot-fixture-relayer.md`. The old
|
|
92
|
+
* name reads as if a screenshot is captured; the function
|
|
93
|
+
* actually synchronizes MDX comment blocks. The deprecated alias
|
|
94
|
+
* is a reference-equality re-export of the new implementation so
|
|
95
|
+
* `===` checks across the rename boundary keep working.
|
|
96
|
+
*/
|
|
97
|
+
export declare const captureScreen: typeof syncProductDocs;
|
|
98
|
+
/**
|
|
99
|
+
* Walk the overlays in a `<Screen>`, resolve each one's `match`
|
|
100
|
+
* against the live page, and emit a YAML block of the form:
|
|
101
|
+
*
|
|
102
|
+
* role "Name":
|
|
103
|
+
* attrA: value
|
|
104
|
+
* attrB: value
|
|
105
|
+
*
|
|
106
|
+
* Only overlays whose `match` resolves to exactly one element
|
|
107
|
+
* contribute a section. Overlays with zero hits or multiple
|
|
108
|
+
* hits are skipped (the drift detector in Phase 1 PR 4 raises
|
|
109
|
+
* those — duplicating the diagnostic here would be noisy).
|
|
110
|
+
*/
|
|
111
|
+
export declare function collectAttributesYaml(page: Page, overlays: OverlaySpec[], whitelist: readonly string[]): Promise<string>;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export { filterAnnotMdxFiles, main, walkMdx, } from './cli.js';
|
|
2
|
+
export { annotDocsConfigSchema, annotFrontmatterSchema, defineConfig, isScreenRole, } from './config.js';
|
|
3
|
+
export type { DetectDriftOptions, DriftFinding, DriftKind, DriftSeverity, } from './drift.js';
|
|
4
|
+
export { detectDrift, detectDriftFromYaml, isLintableScreen, lintableScreens, summariseDrift, } from './drift.js';
|
|
5
|
+
export type { ProductDocs, ProductDocsSyncOptions, Screen, ScreenCaptureOptions, } from './fixture.js';
|
|
6
|
+
export { captureScreen, collectAttributesYaml, DEFAULT_ATTR_WHITELIST, syncProductDocs, test, } from './fixture.js';
|
|
7
|
+
export type { ParseMdxOptions } from './mdx.js';
|
|
8
|
+
export { parseMdx, parseMdxFile, updateCommentBlocks } from './mdx.js';
|
|
9
|
+
export type { BoxedEntry } from './mdx-annotations.js';
|
|
10
|
+
export { buildBadgeAnnotations, emptyAnnotationsSvg, parseSnapshotBoxes, resolveMdxAnnotations, svgFromBadges, svgFromBboxAnnotations, } from './mdx-annotations.js';
|
|
11
|
+
export type { ResolveFailureKind, ResolveResult, SnapshotEntry, } from './resolver.js';
|
|
12
|
+
export { parseSnapshot, resolveMatch, resolveOverlays, } from './resolver.js';
|
|
13
|
+
export type { AnnotCommentBlocks, AnnotFrontmatter, AnnotFrontmatterRole, AnnotMeta, AnnotXlsxConfig, HistoryEntrySpec, MatchKey, OverlayIntent, OverlaySpec, ParsedMdx, ScreenListSpec, ScreenSpec, TransitionSpec, } from './types.js';
|
|
14
|
+
export type { AnnotDocsConfig, BookConfig } from './types-config.js';
|