@empiricalrun/playwright-utils 0.15.4 → 0.15.6

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 CHANGED
@@ -1,5 +1,17 @@
1
1
  # @empiricalrun/playwright-utils
2
2
 
3
+ ## 0.15.6
4
+
5
+ ### Patch Changes
6
+
7
+ - b16b12c: fix: close new page opened for auth store
8
+
9
+ ## 0.15.5
10
+
11
+ ### Patch Changes
12
+
13
+ - 5715b75: fix: type errors in playwright utils
14
+
3
15
  ## 0.15.4
4
16
 
5
17
  ### Patch Changes
@@ -17,7 +17,7 @@ export declare class AuthStore<T extends WithKey<{}>> {
17
17
  appType?: AppType;
18
18
  });
19
19
  loginIfRequired(): Promise<void>;
20
- private pageWithAuthState;
20
+ private newPageWithAuthState;
21
21
  private saveAuthState;
22
22
  static location(userContext: {
23
23
  key: string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,cAAc,EAAU,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAE/D,KAAK,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,GAAG,EAAE,MAAM,CAAA;CAAE,CAAC;AAEtC,KAAK,OAAO,GAAG,SAAS,GAAG,kBAAkB,CAAC;AAE9C,qBAAa,SAAS,CAAC,CAAC,SAAS,OAAO,CAAC,EAAE,CAAC;IAC1C,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,WAAW,EAAE,CAAC,CAAC;IACf,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACzD,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;gBACxD,EACV,IAAI,EACJ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ACV,IAAI,EACJ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,OAAmB,GACpB,EAAE;QACD,IAAI,EAAE,IAAI,CAAC;QACX,WAAW,EAAE,CAAC,CAAC;QACf,SAAS,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;QACzD,iBAAiB,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;QACpE,OAAO,CAAC,EAAE,OAAO,CAAC;KACnB;IAQK,eAAe;YA6BP,oBAAoB;YAsBpB,aAAa;IA6B3B,MAAM,CAAC,QAAQ,CAAC,WAAW,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;WAIxC,eAAe,CAC1B,OAAO,EAAE,cAAc,EACvB,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC;CAoB5B"}
@@ -27,10 +27,11 @@ class AuthStore {
27
27
  shouldDoLogin = true;
28
28
  }
29
29
  else {
30
- const page = await this.pageWithAuthState(this.page, storagePath);
30
+ const page = await this.newPageWithAuthState(this.page, storagePath);
31
31
  try {
32
32
  const hasLoggedIn = await this.checkLoggedInFunc(page, this.userContext);
33
33
  shouldDoLogin = !hasLoggedIn;
34
+ await page.close();
34
35
  }
35
36
  catch (err) {
36
37
  if (err instanceof playwright_core_1.errors.TimeoutError) {
@@ -46,7 +47,7 @@ class AuthStore {
46
47
  await this.saveAuthState(storagePath);
47
48
  }
48
49
  }
49
- async pageWithAuthState(page, storagePath) {
50
+ async newPageWithAuthState(page, storagePath) {
50
51
  if (this.appType === "web-app") {
51
52
  // Load state from the file in a new context
52
53
  // We create a new context because of Playwright APIs
@@ -5,4 +5,8 @@ declare module "playwright-core" {
5
5
  interface Locator extends EnhancedLocator {
6
6
  }
7
7
  }
8
+ declare module "@playwright/test" {
9
+ interface Locator extends EnhancedLocator {
10
+ }
11
+ }
8
12
  //# sourceMappingURL=playwright-extensions.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"playwright-extensions.d.ts","sourceRoot":"","sources":["../src/playwright-extensions.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,OAAO,QAAQ,iBAAiB,CAAC;IAC/B,UAAU,OAAQ,SAAQ,eAAe;KAAG;CAC7C"}
1
+ {"version":3,"file":"playwright-extensions.d.ts","sourceRoot":"","sources":["../src/playwright-extensions.ts"],"names":[],"mappings":"AASA,MAAM,MAAM,eAAe,GAAG;IAC5B,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C,CAAC;AAEF,OAAO,QAAQ,iBAAiB,CAAC;IAC/B,UAAU,OAAQ,SAAQ,eAAe;KAAG;CAC7C;AAED,OAAO,QAAQ,kBAAkB,CAAC;IAChC,UAAU,OAAQ,SAAQ,eAAe;KAAG;CAC7C"}
@@ -1,7 +1,7 @@
1
- import type { PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from "@playwright/test";
1
+ import type { PlaywrightTestArgs, PlaywrightTestOptions, PlaywrightWorkerArgs, PlaywrightWorkerOptions, TestType } from "@playwright/test";
2
2
  import { injectLocatorHighlightScripts } from "./scripts";
3
- import { EnhancedPlaywrightTestArgs, HighlighterOpts } from "./types";
4
- export declare const baseTestFixture: (testFn: TestType<EnhancedPlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>, options?: HighlighterOpts) => TestType<EnhancedPlaywrightTestArgs & PlaywrightTestOptions & {
3
+ import { HighlighterOpts } from "./types";
4
+ export declare const baseTestFixture: (testFn: TestType<PlaywrightTestArgs & PlaywrightTestOptions, PlaywrightWorkerArgs & PlaywrightWorkerOptions>, options?: HighlighterOpts) => TestType<PlaywrightTestArgs & PlaywrightTestOptions & {
5
5
  [key: string]: any;
6
6
  }, PlaywrightWorkerArgs & PlaywrightWorkerOptions>;
7
7
  export { injectLocatorHighlightScripts };
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,0BAA0B,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAEtE,eAAO,MAAM,eAAe,WAClB,SACN,0BAA0B,GAAG,qBAAqB,EAClD,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe;;kDAYzB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe;;kDAYzB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
@@ -1,49 +1,6 @@
1
- import type { Locator, Page, PlaywrightTestArgs } from "@playwright/test";
2
1
  export type HighlighterOpts = {
3
2
  mousePointerHighlighter?: boolean;
4
3
  locatorHighlighter?: boolean;
5
4
  visionMethods?: boolean;
6
5
  };
7
- interface EnhancedLocator extends Locator {
8
- query(instruction: string): Promise<string>;
9
- }
10
- interface EnhancedPage extends Page {
11
- locator(selector: string, options?: {
12
- has?: Locator;
13
- hasNot?: Locator;
14
- hasNotText?: string | RegExp;
15
- hasText?: string | RegExp;
16
- }): EnhancedLocator;
17
- getByRole(role: "alert" | "alertdialog" | "application" | "article" | "banner" | "blockquote" | "button" | "caption" | "cell" | "checkbox" | "code" | "columnheader" | "combobox" | "complementary" | "contentinfo" | "definition" | "deletion" | "dialog" | "directory" | "document" | "emphasis" | "feed" | "figure" | "form" | "generic" | "grid" | "gridcell" | "group" | "heading" | "img" | "insertion" | "link" | "list" | "listbox" | "listitem" | "log" | "main" | "marquee" | "math" | "meter" | "menu" | "menubar" | "menuitem" | "menuitemcheckbox" | "menuitemradio" | "navigation" | "none" | "note" | "option" | "paragraph" | "presentation" | "progressbar" | "radio" | "radiogroup" | "region" | "row" | "rowgroup" | "rowheader" | "scrollbar" | "search" | "searchbox" | "separator" | "slider" | "spinbutton" | "status" | "strong" | "subscript" | "superscript" | "switch" | "tab" | "table" | "tablist" | "tabpanel" | "term" | "textbox" | "time" | "timer" | "toolbar" | "tooltip" | "tree" | "treegrid" | "treeitem", options?: {
18
- checked?: boolean;
19
- disabled?: boolean;
20
- exact?: boolean;
21
- expanded?: boolean;
22
- includeHidden?: boolean;
23
- level?: number;
24
- name?: string | RegExp;
25
- pressed?: boolean;
26
- selected?: boolean;
27
- }): EnhancedLocator;
28
- getByLabel(text: string | RegExp, options?: {
29
- exact?: boolean;
30
- }): EnhancedLocator;
31
- getByPlaceholder(text: string | RegExp, options?: {
32
- exact?: boolean;
33
- }): EnhancedLocator;
34
- getByText(text: string | RegExp, options?: {
35
- exact?: boolean;
36
- }): EnhancedLocator;
37
- getByTestId(testId: string | RegExp): EnhancedLocator;
38
- getByAltText(text: string | RegExp, options?: {
39
- exact?: boolean;
40
- }): EnhancedLocator;
41
- getByTitle(text: string | RegExp, options?: {
42
- exact?: boolean;
43
- }): EnhancedLocator;
44
- }
45
- export interface EnhancedPlaywrightTestArgs extends PlaywrightTestArgs {
46
- page: EnhancedPage;
47
- }
48
- export {};
49
6
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/test/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAE1E,MAAM,MAAM,eAAe,GAAG;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC;AAEF,UAAU,eAAgB,SAAQ,OAAO;IACvC,KAAK,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7C;AAED,UAAU,YAAa,SAAQ,IAAI;IAEjC,OAAO,CACL,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE;QACR,GAAG,CAAC,EAAE,OAAO,CAAC;QACd,MAAM,CAAC,EAAE,OAAO,CAAC;QACjB,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;QAC7B,OAAO,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;KAC3B,GACA,eAAe,CAAC;IACnB,SAAS,CACP,IAAI,EACA,OAAO,GACP,aAAa,GACb,aAAa,GACb,SAAS,GACT,QAAQ,GACR,YAAY,GACZ,QAAQ,GACR,SAAS,GACT,MAAM,GACN,UAAU,GACV,MAAM,GACN,cAAc,GACd,UAAU,GACV,eAAe,GACf,aAAa,GACb,YAAY,GACZ,UAAU,GACV,QAAQ,GACR,WAAW,GACX,UAAU,GACV,UAAU,GACV,MAAM,GACN,QAAQ,GACR,MAAM,GACN,SAAS,GACT,MAAM,GACN,UAAU,GACV,OAAO,GACP,SAAS,GACT,KAAK,GACL,WAAW,GACX,MAAM,GACN,MAAM,GACN,SAAS,GACT,UAAU,GACV,KAAK,GACL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QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5B,eAAe,CAAC;IACnB,WAAW,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,eAAe,CAAC;IACtD,YAAY,CACV,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5B,eAAe,CAAC;IACnB,UAAU,CACR,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5B,eAAe,CAAC;CACpB;AAED,MAAM,WAAW,0BAA2B,SAAQ,kBAAkB;IACpE,IAAI,EAAE,YAAY,CAAC;CACpB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/test/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,eAAe,GAAG;IAC5B,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAC7B,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.15.4",
3
+ "version": "0.15.6",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"