@theaiplatform/miniapp-sdk 0.3.1 → 0.3.2
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/rspack/index.d.ts +8 -0
- package/dist/rspack/index.js +22 -19
- package/dist/testing/rstest.d.ts +32 -45
- package/dist/testing/rstest.js +14 -6
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -30,7 +30,7 @@ Start with the [Miniapp SDK documentation](https://docs.theaiplatform.app/miniap
|
|
|
30
30
|
- `@theaiplatform/miniapp-sdk/testing/rstest`
|
|
31
31
|
- `@theaiplatform/miniapp-sdk/config-schema.json`
|
|
32
32
|
|
|
33
|
-
## In-app E2E testing
|
|
33
|
+
## In-app E2E testing
|
|
34
34
|
|
|
35
35
|
The `/testing/rstest` entry point extends Rstest's Playwright fixtures with a
|
|
36
36
|
host-provided miniapp surface and exact TAP session provenance. Tests can assert
|
package/dist/rspack/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Format } from 'ajv';
|
|
1
2
|
import type { LibConfig } from '@rslib/core';
|
|
2
3
|
import { ModuleFederationOptions } from '@module-federation/rsbuild-plugin';
|
|
3
4
|
import { RsbuildPlugin } from '@rsbuild/core';
|
|
@@ -29,8 +30,15 @@ declare type Config = {
|
|
|
29
30
|
|
|
30
31
|
export declare const pluginTap: (options?: Config) => RsbuildPlugin;
|
|
31
32
|
|
|
33
|
+
/** Registers the canonical JSON Schema formats used by TAP manifests. */
|
|
34
|
+
export declare const registerTapManifestAjvFormats: <Registry extends TapManifestAjvFormatRegistry>(ajv: Registry) => Registry;
|
|
35
|
+
|
|
32
36
|
export declare const tapLib: (options?: Config) => LibConfig;
|
|
33
37
|
|
|
38
|
+
declare interface TapManifestAjvFormatRegistry {
|
|
39
|
+
addFormat(name: string, format: Format): unknown;
|
|
40
|
+
}
|
|
41
|
+
|
|
34
42
|
/** Emitted-package scan used to reject machine-local build artifacts. */
|
|
35
43
|
export declare type TapPackageArtifactPortabilityOptions = {
|
|
36
44
|
output: string;
|
package/dist/rspack/index.js
CHANGED
|
@@ -1994,27 +1994,30 @@ const isUrl = (value)=>{
|
|
|
1994
1994
|
return false;
|
|
1995
1995
|
}
|
|
1996
1996
|
};
|
|
1997
|
+
const registerTapManifestAjvFormats = (ajv)=>{
|
|
1998
|
+
ajv.addFormat('uri', {
|
|
1999
|
+
type: 'string',
|
|
2000
|
+
validate: isUrl
|
|
2001
|
+
});
|
|
2002
|
+
ajv.addFormat('uint8', {
|
|
2003
|
+
type: 'number',
|
|
2004
|
+
validate: (value)=>Number.isInteger(value) && value >= 0 && value <= 255
|
|
2005
|
+
});
|
|
2006
|
+
ajv.addFormat('uint16', {
|
|
2007
|
+
type: 'number',
|
|
2008
|
+
validate: (value)=>Number.isInteger(value) && value >= 0 && value <= 65535
|
|
2009
|
+
});
|
|
2010
|
+
ajv.addFormat('uint64', {
|
|
2011
|
+
type: 'number',
|
|
2012
|
+
validate: (value)=>Number.isSafeInteger(value) && value >= 0
|
|
2013
|
+
});
|
|
2014
|
+
return ajv;
|
|
2015
|
+
};
|
|
1997
2016
|
const getSchemaValidator = async ()=>{
|
|
1998
2017
|
if (!schemaValidator) {
|
|
1999
|
-
const ajv = new __rspack_external_ajv_dist_2020_js_e85899db["default"]({
|
|
2018
|
+
const ajv = registerTapManifestAjvFormats(new __rspack_external_ajv_dist_2020_js_e85899db["default"]({
|
|
2000
2019
|
allErrors: true
|
|
2001
|
-
});
|
|
2002
|
-
ajv.addFormat('uri', {
|
|
2003
|
-
type: 'string',
|
|
2004
|
-
validate: isUrl
|
|
2005
|
-
});
|
|
2006
|
-
ajv.addFormat('uint8', {
|
|
2007
|
-
type: 'number',
|
|
2008
|
-
validate: (value)=>Number.isInteger(value) && value >= 0 && value <= 255
|
|
2009
|
-
});
|
|
2010
|
-
ajv.addFormat('uint16', {
|
|
2011
|
-
type: 'number',
|
|
2012
|
-
validate: (value)=>Number.isInteger(value) && value >= 0 && value <= 65535
|
|
2013
|
-
});
|
|
2014
|
-
ajv.addFormat('uint64', {
|
|
2015
|
-
type: 'number',
|
|
2016
|
-
validate: (value)=>Number.isSafeInteger(value) && value >= 0
|
|
2017
|
-
});
|
|
2020
|
+
}));
|
|
2018
2021
|
schemaValidator = ajv.compile(config_schema_namespaceObject);
|
|
2019
2022
|
}
|
|
2020
2023
|
return schemaValidator;
|
|
@@ -3512,4 +3515,4 @@ const tapLib = (options = {})=>{
|
|
|
3512
3515
|
]
|
|
3513
3516
|
};
|
|
3514
3517
|
};
|
|
3515
|
-
export { assembleTapPackage, assertPortableTapPackageArtifacts, pluginTap, tapLib };
|
|
3518
|
+
export { assembleTapPackage, assertPortableTapPackageArtifacts, pluginTap, registerTapManifestAjvFormats, tapLib };
|
package/dist/testing/rstest.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import { afterAll } from '@rstest/playwright';
|
|
2
|
-
import { afterEach } from '@rstest/playwright';
|
|
3
|
-
import { APIRequestContext } from 'playwright';
|
|
4
2
|
import { beforeAll } from '@rstest/playwright';
|
|
5
|
-
import { beforeEach } from '@rstest/playwright';
|
|
6
3
|
import type { Browser } from 'playwright';
|
|
7
4
|
import type { BrowserContext } from 'playwright';
|
|
8
5
|
import { describe } from '@rstest/playwright';
|
|
9
6
|
import { expect } from '@rstest/playwright';
|
|
10
7
|
import type { FrameLocator } from 'playwright';
|
|
11
8
|
import type { Page } from 'playwright';
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
9
|
+
import type { PlaywrightFixtures } from '@rstest/playwright';
|
|
10
|
+
import type { PlaywrightTest } from '@rstest/playwright';
|
|
11
|
+
import type { TestContext } from '@rstest/core';
|
|
12
|
+
import type { TestOptions } from '@rstest/core';
|
|
15
13
|
import { z } from 'zod';
|
|
16
14
|
|
|
17
15
|
export { afterAll }
|
|
18
16
|
|
|
19
|
-
export
|
|
17
|
+
export declare const afterEach: TapAfterEachHook;
|
|
20
18
|
|
|
21
19
|
export { beforeAll }
|
|
22
20
|
|
|
23
|
-
export
|
|
21
|
+
export declare const beforeEach: TapBeforeEachHook;
|
|
24
22
|
|
|
25
23
|
export { describe }
|
|
26
24
|
|
|
27
25
|
export { expect }
|
|
28
26
|
|
|
27
|
+
declare type MergeContext<ExtraContext, FixturesContext> = {
|
|
28
|
+
[Key in keyof FixturesContext | keyof ExtraContext]: Key extends keyof FixturesContext ? FixturesContext[Key] : Key extends keyof ExtraContext ? ExtraContext[Key] : never;
|
|
29
|
+
};
|
|
30
|
+
|
|
29
31
|
/** Validate a driver session before any endpoint or provenance field is used. */
|
|
30
32
|
export declare function parseTapMiniappTestSession(value: unknown): TapMiniappTestSession;
|
|
31
33
|
|
|
@@ -60,6 +62,16 @@ declare const sessionSchema: z.ZodObject<{
|
|
|
60
62
|
testBundleDigest: z.ZodString;
|
|
61
63
|
}, z.core.$strip>;
|
|
62
64
|
|
|
65
|
+
declare type TapAfterEachCallback<ExtraContext> = (context: TapHookContext<ExtraContext>) => void | Promise<void>;
|
|
66
|
+
|
|
67
|
+
declare type TapAfterEachHook<ExtraContext = TapRstestFixtures> = (callback: TapAfterEachCallback<ExtraContext>, timeout?: number) => void;
|
|
68
|
+
|
|
69
|
+
declare type TapBeforeEachCallback<ExtraContext> = (context: TapHookContext<ExtraContext>) => void | TapAfterEachCallback<ExtraContext> | Promise<void | TapAfterEachCallback<ExtraContext>>;
|
|
70
|
+
|
|
71
|
+
declare type TapBeforeEachHook<ExtraContext = TapRstestFixtures> = (callback: TapBeforeEachCallback<ExtraContext>, timeout?: number) => void;
|
|
72
|
+
|
|
73
|
+
declare type TapHookContext<ExtraContext> = TestContext & ExtraContext;
|
|
74
|
+
|
|
63
75
|
export declare type TapMiniappTestControl = {
|
|
64
76
|
/** Restore the run's declared fixture and permission scenario. */
|
|
65
77
|
reset: () => Promise<void>;
|
|
@@ -85,47 +97,22 @@ export declare type TapRstestFixtures = {
|
|
|
85
97
|
tap: TapMiniappTestFixture;
|
|
86
98
|
};
|
|
87
99
|
|
|
100
|
+
declare type TapRstestTest<ExtraContext = TapRstestFixtures> = Omit<PlaywrightTest<ExtraContext>, 'afterEach' | 'beforeEach' | 'extend'> & {
|
|
101
|
+
(description: string, callback?: (context: TapHookContext<ExtraContext>) => void | Promise<void>, timeout?: number): void;
|
|
102
|
+
(description: string, options: TestOptions, callback?: (context: TapHookContext<ExtraContext>) => void | Promise<void>): void;
|
|
103
|
+
afterEach: TapAfterEachHook<ExtraContext>;
|
|
104
|
+
beforeEach: TapBeforeEachHook<ExtraContext>;
|
|
105
|
+
extend: <FixturesContext extends Record<string, unknown> = Record<never, never>>(fixtures: PlaywrightFixtures<FixturesContext, ExtraContext>) => TapRstestTest<MergeContext<ExtraContext, FixturesContext>>;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/** Rstest's per-test context plus TAP's authorized browser and run fixtures. */
|
|
109
|
+
export declare type TapTestContext = TestContext & TapRstestFixtures;
|
|
110
|
+
|
|
88
111
|
/**
|
|
89
112
|
* Rstest's Playwright test API with TAP-owned browser, page, iframe, and run
|
|
90
113
|
* fixtures. The upstream runner still owns scheduling, assertions, hooks, and
|
|
91
114
|
* reporting; TAP owns the privileged browser/session boundary.
|
|
92
115
|
*/
|
|
93
|
-
export declare const test:
|
|
94
|
-
browser: Browser;
|
|
95
|
-
context: BrowserContext;
|
|
96
|
-
request: APIRequestContext;
|
|
97
|
-
surface: FrameLocator;
|
|
98
|
-
page: Page;
|
|
99
|
-
tap: Readonly<Pick<{
|
|
100
|
-
schemaVersion: 1;
|
|
101
|
-
runId: string;
|
|
102
|
-
workspaceId: string;
|
|
103
|
-
channelId: string;
|
|
104
|
-
packageId: string;
|
|
105
|
-
installationId: string;
|
|
106
|
-
mode: "surface" | "live-tap";
|
|
107
|
-
dataScope: "fixture" | "selected-channel";
|
|
108
|
-
permissionScenario: string;
|
|
109
|
-
surfaceId: string;
|
|
110
|
-
surfaceSelector: string;
|
|
111
|
-
surfaceAssetOrigin: string;
|
|
112
|
-
pageUrlPrefix: string;
|
|
113
|
-
cdpEndpoint: string;
|
|
114
|
-
cdpAuthorization: string;
|
|
115
|
-
artifactDirectory: string;
|
|
116
|
-
allowedNetworkOrigins: string[];
|
|
117
|
-
credentialAliases: string[];
|
|
118
|
-
sourceDigest: string;
|
|
119
|
-
testBundleDigest: string;
|
|
120
|
-
releaseDigest?: string | undefined;
|
|
121
|
-
localGeneration?: number | undefined;
|
|
122
|
-
}, "packageId" | "installationId" | "workspaceId" | "channelId" | "mode" | "runId" | "dataScope" | "permissionScenario" | "surfaceId" | "surfaceAssetOrigin" | "releaseDigest" | "localGeneration" | "sourceDigest" | "testBundleDigest"> & {
|
|
123
|
-
readonly allowedNetworkOrigins: readonly string[];
|
|
124
|
-
readonly credentialAliases: readonly string[];
|
|
125
|
-
control: TapMiniappTestControl;
|
|
126
|
-
}>;
|
|
127
|
-
playwright: PlaywrightOptions;
|
|
128
|
-
serve: PlaywrightServe;
|
|
129
|
-
}>;
|
|
116
|
+
export declare const test: TapRstestTest;
|
|
130
117
|
|
|
131
118
|
export { }
|
package/dist/testing/rstest.js
CHANGED
|
@@ -161,7 +161,7 @@ const test = __rspack_external__rstest_playwright_5734ff29.test.extend({
|
|
|
161
161
|
path: (0, __rspack_external_node_path_806ed179.join)(traceDirectory, 'trace.zip')
|
|
162
162
|
});
|
|
163
163
|
const traceSummary = {
|
|
164
|
-
schemaVersion:
|
|
164
|
+
schemaVersion: 2,
|
|
165
165
|
runId: session.runId,
|
|
166
166
|
taskId: task.id,
|
|
167
167
|
mode: session.mode,
|
|
@@ -171,11 +171,17 @@ const test = __rspack_external__rstest_playwright_5734ff29.test.extend({
|
|
|
171
171
|
sourceDigest: session.sourceDigest,
|
|
172
172
|
testBundleDigest: session.testBundleDigest,
|
|
173
173
|
tracePath: 'trace.zip',
|
|
174
|
-
|
|
174
|
+
traceRedacted: false,
|
|
175
|
+
traceSensitivity: 'raw-sensitive',
|
|
176
|
+
traceAccessScope: 'channel-only',
|
|
177
|
+
traceMayContain: [
|
|
175
178
|
'authorization headers',
|
|
176
179
|
'cookies',
|
|
177
180
|
'credential values',
|
|
178
|
-
'network bodies'
|
|
181
|
+
'network request and response bodies',
|
|
182
|
+
'DOM snapshots',
|
|
183
|
+
'screenshots',
|
|
184
|
+
'test sources'
|
|
179
185
|
]
|
|
180
186
|
};
|
|
181
187
|
await Promise.all([
|
|
@@ -191,7 +197,9 @@ const test = __rspack_external__rstest_playwright_5734ff29.test.extend({
|
|
|
191
197
|
`- Source digest: \`${session.sourceDigest}\``,
|
|
192
198
|
`- Test bundle digest: \`${session.testBundleDigest}\``,
|
|
193
199
|
'',
|
|
194
|
-
'
|
|
200
|
+
'`trace.zip` is raw, sensitive, channel-only evidence. It is not redacted and may contain authorization headers, cookies, credential values, network bodies, DOM snapshots, screenshots, and test source.',
|
|
201
|
+
'',
|
|
202
|
+
'Open the trace from The AI Platform Test Lab for debugging. Do not publish it or attach it to specialist context. The final assertion outcome is authoritative in `report.json` and `report.md`.',
|
|
195
203
|
''
|
|
196
204
|
].join('\n'), 'utf8')
|
|
197
205
|
]);
|
|
@@ -214,6 +222,8 @@ const test = __rspack_external__rstest_playwright_5734ff29.test.extend({
|
|
|
214
222
|
await use(fixtureMetadata(await loadSession(), page));
|
|
215
223
|
}
|
|
216
224
|
});
|
|
225
|
+
const afterEach = __rspack_external__rstest_playwright_5734ff29.afterEach;
|
|
226
|
+
const beforeEach = __rspack_external__rstest_playwright_5734ff29.beforeEach;
|
|
217
227
|
function originOf(value) {
|
|
218
228
|
try {
|
|
219
229
|
const url = new URL(value);
|
|
@@ -233,9 +243,7 @@ const NON_NETWORK_PROTOCOLS = new Set([
|
|
|
233
243
|
'file:'
|
|
234
244
|
]);
|
|
235
245
|
var afterAll = __rspack_external__rstest_playwright_5734ff29.afterAll;
|
|
236
|
-
var afterEach = __rspack_external__rstest_playwright_5734ff29.afterEach;
|
|
237
246
|
var beforeAll = __rspack_external__rstest_playwright_5734ff29.beforeAll;
|
|
238
|
-
var beforeEach = __rspack_external__rstest_playwright_5734ff29.beforeEach;
|
|
239
247
|
var describe = __rspack_external__rstest_playwright_5734ff29.describe;
|
|
240
248
|
var expect = __rspack_external__rstest_playwright_5734ff29.expect;
|
|
241
249
|
export { afterAll, afterEach, beforeAll, beforeEach, describe, expect, parseTapMiniappTestSession, test };
|