@jskit-ai/auth-web 0.2.46 → 0.2.47
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jskit-ai/auth-web",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.47",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "jskit test"
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"@jskit-ai/auth-core": "0.2.31",
|
|
37
37
|
"@jskit-ai/http-runtime": "0.2.27",
|
|
38
38
|
"@jskit-ai/kernel": "0.2.27",
|
|
39
|
-
"@jskit-ai/shell-web": "0.2.
|
|
39
|
+
"@jskit-ai/shell-web": "0.2.41",
|
|
40
40
|
"@tanstack/vue-query": "^5.90.5",
|
|
41
41
|
"pinia": "^4.0.3",
|
|
42
42
|
"vue": "^3.5.44",
|
|
@@ -96,6 +96,13 @@ after(async () => {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
// The app's /home after the page load that brought the browser there: a sign-in, the provider's redirect back or
|
|
100
|
+
// another site's link replaces the page, and a page load waits under the navigation timeout, not expect's 5 s, which
|
|
101
|
+
// is too short for a whole page load while many browser test files run at once.
|
|
102
|
+
function waitForHome(page) {
|
|
103
|
+
return page.waitForURL((url) => url.origin === new URL(stack.appUrl).origin && url.pathname === "/home");
|
|
104
|
+
}
|
|
105
|
+
|
|
99
106
|
function cookieNames(header) {
|
|
100
107
|
return String(header || "").split(";").map((pair) => pair.split("=")[0].trim()).filter(Boolean).sort();
|
|
101
108
|
}
|
|
@@ -144,6 +151,7 @@ test("with strict cookies, Google sign-in comes back from the provider's site an
|
|
|
144
151
|
await page.getByRole("button", { name: "Continue with Google" }).click();
|
|
145
152
|
await page.waitForURL((url) => url.href.startsWith(stack.issuerUrl));
|
|
146
153
|
await page.getByRole("button", { name: "Continue", exact: true }).click();
|
|
154
|
+
await waitForHome(page);
|
|
147
155
|
await expect(page.getByTestId("home")).toHaveText("Signed in: true");
|
|
148
156
|
assert.equal(new URL(page.url()).pathname, "/home");
|
|
149
157
|
|
|
@@ -193,12 +201,14 @@ test("with strict cookies, a link from another site opens the app signed in by t
|
|
|
193
201
|
await page.getByLabel("Email").fill("grace@example.com");
|
|
194
202
|
await page.getByLabel("Password", { exact: true }).fill(PASSWORD);
|
|
195
203
|
await page.getByTestId("auth-submit").click();
|
|
204
|
+
await waitForHome(page);
|
|
196
205
|
await expect(page.getByTestId("home")).toHaveText("Signed in: true");
|
|
197
206
|
|
|
198
207
|
stack.apiRequests.length = 0;
|
|
199
208
|
documents.length = 0;
|
|
200
209
|
await page.goto(webmail);
|
|
201
210
|
await page.getByRole("link", { name: "Open your account" }).click();
|
|
211
|
+
await waitForHome(page);
|
|
202
212
|
await expect(page.getByTestId("home")).toHaveText("Signed in: true");
|
|
203
213
|
// The link's page load came from another site and carried no Strict cookie ...
|
|
204
214
|
const landing = await appDocument(documents, (url) => url.pathname === "/home");
|
|
@@ -89,7 +89,9 @@ function reports(page) {
|
|
|
89
89
|
return page.evaluate(() => window.authFixture.reports);
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
-
// The page itself, not a sign-in page whose returnTo=/home also ends the address.
|
|
92
|
+
// The page itself, not a sign-in page whose returnTo=/home also ends the address. Signing in replaces the page, so
|
|
93
|
+
// a check of /home waits for its page load first, under the navigation timeout: expect's own 5 s is too short for a
|
|
94
|
+
// whole page load while many browser test files run at once.
|
|
93
95
|
function waitForHome(page) {
|
|
94
96
|
return page.waitForURL((url) => url.pathname === "/home");
|
|
95
97
|
}
|
|
@@ -124,6 +126,7 @@ test("password sign-in opens the requested page, remembers the account, and sign
|
|
|
124
126
|
await expect(page.getByTestId("auth-submit")).toBeDisabled();
|
|
125
127
|
|
|
126
128
|
await signIn(page, "Ada@Example.com", "correct horse");
|
|
129
|
+
await waitForHome(page);
|
|
127
130
|
await expect(page.getByTestId("home")).toHaveText("Signed in: true");
|
|
128
131
|
assert.equal(new URL(page.url()).pathname, "/home");
|
|
129
132
|
const login = api.requests.find((request) => request.key === "POST /api/login");
|
|
@@ -142,6 +145,8 @@ test("password sign-in opens the requested page, remembers the account, and sign
|
|
|
142
145
|
assert.deepEqual(await page.evaluate(() => window.authFixture.context.auth.permissions), ["read"]);
|
|
143
146
|
|
|
144
147
|
await page.goto("/auth/signout?returnTo=/home");
|
|
148
|
+
// Signing out replaces the page with sign-in's.
|
|
149
|
+
await page.waitForURL((url) => url.pathname === "/auth/login");
|
|
145
150
|
await expect(page.getByText("Welcome back, Ada Lovelace")).toBeVisible();
|
|
146
151
|
assert.equal(new URL(page.url()).search, "?returnTo=%2Fhome");
|
|
147
152
|
assert.equal(api.requests.filter((request) => request.key === "POST /api/logout").length, 1);
|
|
@@ -189,6 +194,7 @@ test("a refused sign-in reports the server's error and leaves the form usable",
|
|
|
189
194
|
test("a signed-in visitor leaves the sign-in page, on opening it and when a session starts elsewhere", options, async () => {
|
|
190
195
|
const signedIn = await openApp({ session: SIGNED_IN });
|
|
191
196
|
await signedIn.page.goto("/auth/login?returnTo=/home");
|
|
197
|
+
await waitForHome(signedIn.page);
|
|
192
198
|
await expect(signedIn.page.getByTestId("home")).toHaveText("Signed in: true");
|
|
193
199
|
await finish(signedIn);
|
|
194
200
|
|
|
@@ -474,6 +480,7 @@ test("OAuth starts at the provider and a callback finishes on the requested page
|
|
|
474
480
|
}
|
|
475
481
|
});
|
|
476
482
|
await api.page.goto("/auth/login?code=code-1&state=state-1&oauthProvider=google&oauthReturnTo=/home");
|
|
483
|
+
await waitForHome(api.page);
|
|
477
484
|
await expect(api.page.getByTestId("home")).toHaveText("Signed in: true");
|
|
478
485
|
assert.deepEqual(api.requests.at(-1).body, { provider: "google", code: "code-1", state: "state-1" });
|
|
479
486
|
await finish(api);
|
|
@@ -487,6 +494,8 @@ test("OAuth starts at the provider and a callback finishes on the requested page
|
|
|
487
494
|
}
|
|
488
495
|
});
|
|
489
496
|
await landed.page.goto("/home?code=code-2&oauthProvider=google");
|
|
497
|
+
// The guard sends the callback to sign-in, which completes it and replaces the page with /home again.
|
|
498
|
+
await landed.page.waitForURL((url) => url.pathname === "/home" && !url.searchParams.has("code"));
|
|
490
499
|
await expect(landed.page.getByTestId("home")).toHaveText("Signed in: true");
|
|
491
500
|
assert.equal(new URL(landed.page.url()).searchParams.has("code"), false);
|
|
492
501
|
await finish(landed);
|