@enekesabel/playwright-lite 0.4.0 → 0.5.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/dist/index.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { Locator, Page, PlaywrightTestOptions } from "@playwright/test";
1
+ import { ConsoleMessage, Locator, Page, PlaywrightTestOptions } from "@playwright/test";
2
2
  //#region src/expect.d.ts
3
3
  interface AsymmetricMatcher {
4
4
  asymmetricMatch(other: unknown): boolean;
@@ -171,9 +171,78 @@ type Expect<ExtendedMatchers = Record<never, never>> = {
171
171
  } & AsymmetricMatchers;
172
172
  declare const expect: Expect;
173
173
  //#endregion
174
+ //#region src/network.d.ts
175
+ interface Request {
176
+ /** The request URL, with the fragment stripped as the pinned server does. */
177
+ url(): string;
178
+ /** `"fetch"` or `"xhr"`: this observation sees only those two, by construction. */
179
+ resourceType(): string;
180
+ method(): string;
181
+ /**
182
+ * The request headers the caller set: `Request.headers` for a `fetch` call,
183
+ * `setRequestHeader` for an `XMLHttpRequest`.
184
+ */
185
+ headers(): Record<string, string>;
186
+ /** Reads `headers()`; a page never sees the headers that went on the wire. */
187
+ headerValue(name: string): Promise<string | null>;
188
+ postData(): string | null;
189
+ postDataBuffer(): Uint8Array | null;
190
+ postDataJSON(): unknown;
191
+ /** Always `false`: neither a `fetch` nor an XHR navigates the document. */
192
+ isNavigationRequest(): boolean;
193
+ failure(): {
194
+ errorText: string;
195
+ } | null;
196
+ /** Resolves with the response, or `null` once the request has failed. */
197
+ response(): Promise<Response | null>;
198
+ }
199
+ interface Response {
200
+ /** The final URL after redirects, which never carries a fragment. */
201
+ url(): string;
202
+ status(): number;
203
+ statusText(): string;
204
+ ok(): boolean;
205
+ /** The response headers the browser exposes to this document. */
206
+ headers(): Record<string, string>;
207
+ headerValue(name: string): Promise<string | null>;
208
+ body(): Promise<Uint8Array>;
209
+ text(): Promise<string>;
210
+ json(): Promise<unknown>;
211
+ /** Resolves once the response body has ended. */
212
+ finished(): Promise<null>;
213
+ request(): Request;
214
+ }
215
+ //#endregion
216
+ //#region src/dialog.d.ts
217
+ /** `beforeunload` is out of scope: it belongs to document replacement (ADR-0001). */
218
+ type DialogType = "alert" | "confirm" | "prompt";
219
+ type Settlement = {
220
+ accepted: boolean;
221
+ value?: string;
222
+ };
223
+ type SettlementBox = {
224
+ result?: Settlement;
225
+ };
226
+ /** One `alert`/`confirm`/`prompt` call, built per subscribed page around a settlement its siblings share. */
227
+ declare class Dialog {
228
+ private readonly _type;
229
+ private readonly _message;
230
+ private readonly _defaultValue;
231
+ private readonly box;
232
+ private readonly _page;
233
+ constructor(_type: DialogType, _message: string, _defaultValue: string, box: SettlementBox, _page: () => Page);
234
+ type(): DialogType;
235
+ message(): string;
236
+ defaultValue(): string;
237
+ page(): Page;
238
+ accept(promptText?: string): Promise<void>;
239
+ dismiss(): Promise<void>;
240
+ private settle;
241
+ }
242
+ //#endregion
174
243
  //#region src/index.d.ts
175
244
  type CreatePageOptions = Partial<Pick<PlaywrightTestOptions, "testIdAttribute" | "actionTimeout" | "navigationTimeout">>;
176
245
  /** Creates a Page for the current browser window. Omitted settings keep the runtime defaults. */
177
246
  declare function createPage(options?: CreatePageOptions): Page;
178
247
  //#endregion
179
- export { CreatePageOptions, type Expect, createPage, expect };
248
+ export { type ConsoleMessage, CreatePageOptions, type Dialog, type Expect, type Request, type Response, createPage, expect };