@empiricalrun/playwright-utils 0.16.1 → 0.16.3

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.16.3
4
+
5
+ ### Patch Changes
6
+
7
+ - 67f6e79: feat: return logged in page from AuthStore
8
+
9
+ ## 0.16.2
10
+
11
+ ### Patch Changes
12
+
13
+ - 8825df8: gcam "fix: custom page provider attaches multiple videos in report"
14
+
3
15
  ## 0.16.1
4
16
 
5
17
  ### Patch Changes
@@ -17,6 +17,7 @@ export declare class AuthStore<T extends WithKey<{}>> {
17
17
  appType?: AppType;
18
18
  });
19
19
  loginIfRequired(): Promise<void>;
20
+ loggedInPage(): Promise<Page | undefined>;
20
21
  private newPageWithAuthState;
21
22
  private saveAuthState;
22
23
  static location(userContext: {
@@ -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;gBAC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AAC,CAAC;gBACxD,EACV,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;IAIf,YAAY,IAAI,OAAO,CAAC,IAAI,GAAG,SAAS,CAAC;YAqCjC,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"}
@@ -21,7 +21,11 @@ class AuthStore {
21
21
  this.checkLoggedInFunc = checkLoggedInFunc;
22
22
  }
23
23
  async loginIfRequired() {
24
+ await this.loggedInPage();
25
+ }
26
+ async loggedInPage() {
24
27
  let shouldDoLogin = false;
28
+ let loggedInPage = undefined;
25
29
  const storagePath = AuthStore.location(this.userContext);
26
30
  if (!fs_1.default.existsSync(storagePath)) {
27
31
  shouldDoLogin = true;
@@ -30,8 +34,13 @@ class AuthStore {
30
34
  const page = await this.newPageWithAuthState(this.page, storagePath);
31
35
  try {
32
36
  const hasLoggedIn = await this.checkLoggedInFunc(page, this.userContext);
37
+ if (!hasLoggedIn) {
38
+ await page.close();
39
+ }
40
+ else {
41
+ loggedInPage = page;
42
+ }
33
43
  shouldDoLogin = !hasLoggedIn;
34
- await page.close();
35
44
  }
36
45
  catch (err) {
37
46
  if (err instanceof playwright_core_1.errors.TimeoutError) {
@@ -45,7 +54,9 @@ class AuthStore {
45
54
  if (shouldDoLogin) {
46
55
  await this.loginFunc(this.page, this.userContext);
47
56
  await this.saveAuthState(storagePath);
57
+ loggedInPage = this.page;
48
58
  }
59
+ return loggedInPage;
49
60
  }
50
61
  async newPageWithAuthState(page, storagePath) {
51
62
  if (this.appType === "web-app") {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/test/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,yBAAyB,EAAE,CACzB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtD,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAIF,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe,uHA2DzB,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,cAAc,EACd,qBAAqB,EACrB,IAAI,EACJ,kBAAkB,EAClB,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,QAAQ,EACT,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,6BAA6B,EAAE,MAAM,WAAW,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,WAAW,GAAG;IACjB,IAAI,EAAE,IAAI,CAAC;IACX,yBAAyB,EAAE,CACzB,OAAO,CAAC,EAAE,qBAAqB,KAC5B,OAAO,CAAC;QAAE,OAAO,EAAE,cAAc,CAAC;QAAC,IAAI,EAAE,IAAI,CAAA;KAAE,CAAC,CAAC;IACtD,UAAU,EAAE,IAAI,CAAC;CAClB,CAAC;AAIF,eAAO,MAAM,eAAe,WAClB,SACN,kBAAkB,GAAG,qBAAqB,EAC1C,oBAAoB,GAAG,uBAAuB,CAC/C,YACQ,eAAe,uHAwDzB,CAAC;AAEF,OAAO,EAAE,6BAA6B,EAAE,CAAC"}
@@ -20,13 +20,10 @@ const baseTestFixture = function (testFn, options = {
20
20
  (0, scripts_1.injectLocatorHighlightScripts)(page, options);
21
21
  await use(page);
22
22
  },
23
- customContextPageProvider: async ({ page }, use, testInfo) => {
23
+ customContextPageProvider: async ({ browser }, use, testInfo) => {
24
24
  const contexts = [];
25
25
  async function createContext(options = {}) {
26
- const pageContext = await page
27
- .context()
28
- .browser()
29
- .newContext({
26
+ const pageContext = await browser.newContext({
30
27
  ...options,
31
28
  recordVideo: {
32
29
  dir: path_1.default.join(testInfo.project.outputDir, videoStore, testInfo.testId),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empiricalrun/playwright-utils",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
4
4
  "publishConfig": {
5
5
  "registry": "https://registry.npmjs.org/",
6
6
  "access": "public"