@jskit-ai/auth-web 0.2.15 → 0.2.17
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 +9 -0
- package/fixtures/sign-in/main.js +24 -1
- package/fixtures/sign-in/vite.config.mjs +2 -0
- package/locales/en.json +2 -1
- package/package.json +8 -8
- package/patterns/auth-surface/PATTERN.md +18 -5
- package/patterns/auth-surface/example/src/components/AppBrand.vue +17 -0
- package/patterns/auth-surface/example/src/pages/auth/login.vue +2 -2
- package/patterns/auth-surface/example/src/pages/auth/reset-password.vue +2 -2
- package/patterns/auth-surface/example/src/pages/auth/signout.vue +2 -2
- package/patterns/auth-surface/example/src/views/auth/LoginView.vue +6 -1
- package/patterns/auth-surface/example/src/views/auth/ResetPasswordView.vue +6 -1
- package/patterns/auth-surface/example/src/views/auth/SignOutView.vue +6 -1
- package/src/client/composables/loginView/constants.js +2 -2
- package/src/client/composables/loginView/useLoginViewState.js +5 -1
- package/src/client/views/AuthProfileWidget.vue +28 -2
- package/src/client/views/AuthScreen.vue +98 -0
- package/src/client/views/DefaultLoginView.vue +294 -290
- package/src/client/views/DefaultResetPasswordView.vue +61 -85
- package/src/client/views/DefaultSignOutView.vue +62 -43
- package/src/test/playwright.js +36 -15
- package/test/authSurfacePatternBrand.test.js +34 -0
- package/test/clientSurface.test.js +29 -26
- package/test/playwright.test.js +82 -22
- package/test/signIn.browser.test.js +214 -0
|
@@ -1,79 +1,72 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<v-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
2
|
+
<AuthScreen class="reset-screen" :class="{ 'reset-screen--mobile': isMobileViewport }">
|
|
3
|
+
<template v-if="$slots.brand" #brand="brand">
|
|
4
|
+
<slot name="brand" v-bind="brand" />
|
|
5
|
+
</template>
|
|
6
|
+
<v-card
|
|
7
|
+
class="reset-card"
|
|
8
|
+
:class="{ 'reset-card--mobile': isMobileViewport }"
|
|
9
|
+
variant="flat"
|
|
10
|
+
:rounded="isMobileViewport ? false : undefined"
|
|
11
11
|
>
|
|
12
|
-
<v-card
|
|
13
|
-
class="reset-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
:elevation="isMobileViewport ? 0 : 1"
|
|
17
|
-
:border="!isMobileViewport"
|
|
18
|
-
>
|
|
19
|
-
<v-card-text class="reset-content" :class="{ 'reset-content--mobile': isMobileViewport }">
|
|
20
|
-
<div class="reset-header mb-5">
|
|
21
|
-
<h1 class="reset-title">{{ t("jskit.auth.resetPassword.title") }}</h1>
|
|
22
|
-
</div>
|
|
12
|
+
<v-card-text class="reset-content" :class="{ 'reset-content--mobile': isMobileViewport }">
|
|
13
|
+
<div class="reset-header mb-5">
|
|
14
|
+
<h1 class="reset-title text-headline-medium">{{ t("jskit.auth.resetPassword.title") }}</h1>
|
|
15
|
+
</div>
|
|
23
16
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
17
|
+
<v-alert v-if="errorMessage" type="error" variant="tonal" class="mb-4">
|
|
18
|
+
{{ errorMessage }}
|
|
19
|
+
</v-alert>
|
|
27
20
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
21
|
+
<v-alert v-if="status === 'done'" type="success" variant="tonal" class="mb-4">
|
|
22
|
+
{{ t("jskit.auth.resetPassword.done") }}
|
|
23
|
+
</v-alert>
|
|
31
24
|
|
|
32
|
-
|
|
25
|
+
<v-progress-linear v-if="status === 'checking'" indeterminate color="primary" class="mb-4" />
|
|
33
26
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
27
|
+
<v-form v-if="status === 'ready'" @submit.prevent="submitReset" novalidate>
|
|
28
|
+
<v-text-field
|
|
29
|
+
v-model="password"
|
|
30
|
+
:label="t('jskit.auth.resetPassword.newPassword')"
|
|
31
|
+
:type="showPassword ? 'text' : 'password'"
|
|
32
|
+
variant="outlined"
|
|
33
|
+
density="comfortable"
|
|
34
|
+
autocomplete="new-password"
|
|
35
|
+
:append-inner-icon="showPassword ? '$visibilityOff' : '$visibility'"
|
|
36
|
+
:error-messages="passwordError"
|
|
37
|
+
class="mb-3"
|
|
38
|
+
@click:append-inner="showPassword = !showPassword"
|
|
39
|
+
/>
|
|
40
|
+
<v-text-field
|
|
41
|
+
v-model="confirmPassword"
|
|
42
|
+
:label="t('jskit.auth.resetPassword.confirmPassword')"
|
|
43
|
+
:type="showConfirmPassword ? 'text' : 'password'"
|
|
44
|
+
variant="outlined"
|
|
45
|
+
density="comfortable"
|
|
46
|
+
autocomplete="new-password"
|
|
47
|
+
:append-inner-icon="showConfirmPassword ? '$visibilityOff' : '$visibility'"
|
|
48
|
+
:error-messages="confirmPasswordError"
|
|
49
|
+
class="mb-4"
|
|
50
|
+
@click:append-inner="showConfirmPassword = !showConfirmPassword"
|
|
51
|
+
/>
|
|
52
|
+
<v-btn block color="primary" size="large" type="submit" :loading="loading" :disabled="!canSubmit">
|
|
53
|
+
{{ t("jskit.auth.resetPassword.submit") }}
|
|
54
|
+
</v-btn>
|
|
55
|
+
</v-form>
|
|
63
56
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
</div>
|
|
57
|
+
<div v-if="status === 'done' || status === 'error'" class="mt-4 d-flex justify-end">
|
|
58
|
+
<v-btn variant="text" color="secondary" href="/auth/login">
|
|
59
|
+
{{ t("jskit.auth.resetPassword.backToSignIn") }}
|
|
60
|
+
</v-btn>
|
|
61
|
+
</div>
|
|
62
|
+
</v-card-text>
|
|
63
|
+
</v-card>
|
|
64
|
+
</AuthScreen>
|
|
73
65
|
</template>
|
|
74
66
|
|
|
75
67
|
<script setup>
|
|
76
68
|
import { useDisplay } from "vuetify";
|
|
69
|
+
import AuthScreen from "./AuthScreen.vue";
|
|
77
70
|
import { useDefaultResetPasswordView } from "../composables/useDefaultResetPasswordView.js";
|
|
78
71
|
import { useJskitText } from "../i18n.js";
|
|
79
72
|
|
|
@@ -95,28 +88,14 @@ const {
|
|
|
95
88
|
</script>
|
|
96
89
|
|
|
97
90
|
<style scoped>
|
|
98
|
-
.reset-screen {
|
|
99
|
-
/* Start below shell banners shown on a surface without an app bar. */
|
|
100
|
-
--auth-screen-height: calc(100dvh - var(--shell-error-banners-inline-height, 0px));
|
|
101
|
-
position: fixed;
|
|
102
|
-
inset: var(--shell-error-banners-inline-height, 0px) 0 0;
|
|
103
|
-
z-index: 1;
|
|
104
|
-
overflow-y: auto;
|
|
105
|
-
min-height: var(--auth-screen-height);
|
|
106
|
-
background-color: rgb(var(--v-theme-background));
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
.reset-shell {
|
|
110
|
-
min-height: var(--auth-screen-height);
|
|
111
|
-
}
|
|
112
|
-
|
|
113
91
|
.reset-card {
|
|
114
92
|
width: min(480px, 100%);
|
|
115
93
|
}
|
|
116
94
|
|
|
95
|
+
/* On a phone the card is the screen below the brand row, if any. */
|
|
117
96
|
.reset-card--mobile {
|
|
97
|
+
flex: 1 0 auto;
|
|
118
98
|
width: 100%;
|
|
119
|
-
min-height: var(--auth-screen-height);
|
|
120
99
|
}
|
|
121
100
|
|
|
122
101
|
.reset-content {
|
|
@@ -124,14 +103,11 @@ const {
|
|
|
124
103
|
}
|
|
125
104
|
|
|
126
105
|
.reset-content--mobile {
|
|
127
|
-
|
|
128
|
-
padding: calc(24px + env(safe-area-inset-top, 0px)) 20px calc(32px + env(safe-area-inset-bottom, 0px));
|
|
106
|
+
padding: calc(24px + var(--auth-screen-top-inset, 0px)) 20px calc(32px + env(safe-area-inset-bottom, 0px));
|
|
129
107
|
}
|
|
130
108
|
|
|
131
109
|
.reset-title {
|
|
132
110
|
margin: 0;
|
|
133
|
-
font-size: 28px;
|
|
134
|
-
line-height: 1.2;
|
|
135
111
|
color: rgb(var(--v-theme-on-surface));
|
|
136
112
|
}
|
|
137
113
|
</style>
|
|
@@ -1,59 +1,78 @@
|
|
|
1
1
|
<template>
|
|
2
|
-
<
|
|
3
|
-
<v-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
2
|
+
<AuthScreen class="signout-screen" :class="{ 'signout-screen--mobile': isMobileViewport }">
|
|
3
|
+
<template v-if="$slots.brand" #brand="brand">
|
|
4
|
+
<slot name="brand" v-bind="brand" />
|
|
5
|
+
</template>
|
|
6
|
+
<v-card
|
|
7
|
+
class="signout-card"
|
|
8
|
+
:class="{ 'signout-card--mobile': isMobileViewport }"
|
|
9
|
+
variant="flat"
|
|
10
|
+
:rounded="isMobileViewport ? false : undefined"
|
|
11
|
+
>
|
|
12
|
+
<v-card-text class="signout-content" :class="{ 'signout-content--mobile': isMobileViewport }">
|
|
13
|
+
<h1 class="signout-title text-headline-medium mb-3">{{ t("jskit.auth.signOut.title") }}</h1>
|
|
14
|
+
|
|
15
|
+
<p v-if="status === 'pending'" class="on-surface-variant mb-4">
|
|
16
|
+
{{ t("jskit.auth.signOut.pending") }}
|
|
17
|
+
</p>
|
|
18
|
+
|
|
19
|
+
<p v-if="status === 'error'" class="text-body-large on-surface-variant mb-4">
|
|
20
|
+
{{ errorMessage || t("jskit.auth.signOut.failedTryAgain") }}
|
|
21
|
+
</p>
|
|
22
|
+
|
|
23
|
+
<div class="d-flex ga-3">
|
|
24
|
+
<v-btn
|
|
25
|
+
v-if="status === 'error'"
|
|
26
|
+
color="primary"
|
|
27
|
+
variant="flat"
|
|
28
|
+
class="text-none"
|
|
29
|
+
@click="retrySignOut"
|
|
30
|
+
>
|
|
31
|
+
{{ t("jskit.auth.signOut.retry") }}
|
|
32
|
+
</v-btn>
|
|
33
|
+
<v-btn
|
|
34
|
+
v-if="status === 'error'"
|
|
35
|
+
color="secondary"
|
|
36
|
+
variant="text"
|
|
37
|
+
class="text-none"
|
|
38
|
+
@click="goToLogin"
|
|
39
|
+
>
|
|
40
|
+
{{ t("jskit.auth.signOut.goToLogin") }}
|
|
41
|
+
</v-btn>
|
|
42
|
+
<v-progress-circular v-if="status === 'pending'" indeterminate color="primary" size="22" />
|
|
43
|
+
</div>
|
|
44
|
+
</v-card-text>
|
|
45
|
+
</v-card>
|
|
46
|
+
</AuthScreen>
|
|
41
47
|
</template>
|
|
42
48
|
|
|
43
49
|
<script setup>
|
|
50
|
+
import { useDisplay } from "vuetify";
|
|
51
|
+
import AuthScreen from "./AuthScreen.vue";
|
|
44
52
|
import { useDefaultSignOutView } from "../composables/useDefaultSignOutView.js";
|
|
45
53
|
import { useJskitText } from "../i18n.js";
|
|
46
54
|
|
|
55
|
+
const { mobile: isMobileViewport } = useDisplay({ mobileBreakpoint: 960 });
|
|
47
56
|
const { t } = useJskitText();
|
|
48
57
|
const { status, errorMessage, retrySignOut, goToLogin } = useDefaultSignOutView();
|
|
49
58
|
</script>
|
|
50
59
|
|
|
51
60
|
<style scoped>
|
|
52
|
-
.signout-main {
|
|
53
|
-
background-color: rgb(var(--v-theme-surface-container));
|
|
54
|
-
}
|
|
55
|
-
|
|
56
61
|
.signout-card {
|
|
57
62
|
width: min(520px, 100%);
|
|
58
63
|
}
|
|
64
|
+
|
|
65
|
+
/* On a phone the card is the screen below the brand row, if any. */
|
|
66
|
+
.signout-card--mobile {
|
|
67
|
+
flex: 1 0 auto;
|
|
68
|
+
width: 100%;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
.signout-content {
|
|
72
|
+
padding: 28px;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.signout-content--mobile {
|
|
76
|
+
padding: calc(24px + var(--auth-screen-top-inset, 0px)) 20px calc(32px + env(safe-area-inset-bottom, 0px));
|
|
77
|
+
}
|
|
59
78
|
</style>
|
package/src/test/playwright.js
CHANGED
|
@@ -1,13 +1,8 @@
|
|
|
1
1
|
import { DEV_AUTH_SECRET_HEADER } from "@jskit-ai/auth-core/server/devAuth";
|
|
2
2
|
import { AUTH_PATHS } from "@jskit-ai/auth-core/shared/authPaths";
|
|
3
3
|
|
|
4
|
-
function defaultLocalBaseUrl() {
|
|
5
|
-
const port = String(process.env.PLAYWRIGHT_PORT || "").trim() || "4173";
|
|
6
|
-
return `http://127.0.0.1:${port}`;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
4
|
function resolveLocalBaseUrl(value) {
|
|
10
|
-
const baseUrl = String(value
|
|
5
|
+
const baseUrl = String(value).trim().replace(/\/+$/u, "");
|
|
11
6
|
let url;
|
|
12
7
|
try {
|
|
13
8
|
url = new URL(baseUrl);
|
|
@@ -41,15 +36,22 @@ async function responseBody(response) {
|
|
|
41
36
|
return body ? ` ${body}` : "";
|
|
42
37
|
}
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Signs `request`, a Playwright APIRequestContext, in as an existing user through the local app's dev-auth route: a
|
|
41
|
+
* page context's `request`, or the one a browserTestConfig() `signIn` module is given to sign a worker in once. Without
|
|
42
|
+
* `baseURL`, it signs in on the context's own baseURL: under browserTestConfig() each worker's own server. The private
|
|
43
|
+
* secret is only ever sent to a local app URL; a managed target (PLAYWRIGHT_BASE_URL) is refused before any request.
|
|
44
|
+
* @param {import("@playwright/test").APIRequestContext} request
|
|
45
|
+
* @param {{ email?: string, userId?: string, secret?: string, baseURL?: string }} [options]
|
|
46
|
+
*/
|
|
47
|
+
async function loginRequestAsExistingUser(request, {
|
|
45
48
|
email = "",
|
|
46
49
|
userId = "",
|
|
47
50
|
secret = process.env.AUTH_DEV_BYPASS_SECRET,
|
|
48
|
-
baseURL =
|
|
51
|
+
baseURL = ""
|
|
49
52
|
} = {}) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
throw new Error("loginAsExistingUser requires a Playwright page.");
|
|
53
|
+
if (typeof request?.get !== "function") {
|
|
54
|
+
throw new Error("loginRequestAsExistingUser requires a Playwright APIRequestContext.");
|
|
53
55
|
}
|
|
54
56
|
|
|
55
57
|
const normalizedSecret = String(secret || "").trim();
|
|
@@ -57,12 +59,18 @@ async function loginAsExistingUser(page, {
|
|
|
57
59
|
throw new Error("loginAsExistingUser requires AUTH_DEV_BYPASS_SECRET.");
|
|
58
60
|
}
|
|
59
61
|
|
|
60
|
-
const
|
|
62
|
+
const givenBaseUrl = baseURL ? resolveLocalBaseUrl(baseURL) : "";
|
|
63
|
+
if (!givenBaseUrl && process.env.PLAYWRIGHT_BASE_URL) {
|
|
64
|
+
resolveLocalBaseUrl(process.env.PLAYWRIGHT_BASE_URL);
|
|
65
|
+
}
|
|
61
66
|
const identity = resolveIdentity({ email, userId });
|
|
62
|
-
|
|
67
|
+
// A path alone resolves against the context's own baseURL.
|
|
68
|
+
const sessionResponse = await request.get(`${givenBaseUrl}${AUTH_PATHS.SESSION}`);
|
|
63
69
|
if (!sessionResponse.ok()) {
|
|
64
70
|
throw new Error(`Session bootstrap failed: ${sessionResponse.status()}${await responseBody(sessionResponse)}`);
|
|
65
71
|
}
|
|
72
|
+
// The secret goes only to the local server that answered the session request.
|
|
73
|
+
const localBaseUrl = givenBaseUrl || resolveLocalBaseUrl(new URL(sessionResponse.url()).origin);
|
|
66
74
|
|
|
67
75
|
const session = await sessionResponse.json();
|
|
68
76
|
const csrfToken = String(session?.csrfToken || "").trim();
|
|
@@ -70,7 +78,7 @@ async function loginAsExistingUser(page, {
|
|
|
70
78
|
throw new Error("Session bootstrap did not return csrfToken.");
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
const loginResponse = await
|
|
81
|
+
const loginResponse = await request.post(`${localBaseUrl}${AUTH_PATHS.DEV_LOGIN_AS}`, {
|
|
74
82
|
data: identity,
|
|
75
83
|
headers: {
|
|
76
84
|
"csrf-token": csrfToken,
|
|
@@ -84,4 +92,17 @@ async function loginAsExistingUser(page, {
|
|
|
84
92
|
return loginResponse.json();
|
|
85
93
|
}
|
|
86
94
|
|
|
87
|
-
|
|
95
|
+
/**
|
|
96
|
+
* Signs `page`'s context in as an existing user, as `loginRequestAsExistingUser()` signs its `request` in.
|
|
97
|
+
* @param {import("@playwright/test").Page} page
|
|
98
|
+
* @param {{ email?: string, userId?: string, secret?: string, baseURL?: string }} [options]
|
|
99
|
+
*/
|
|
100
|
+
async function loginAsExistingUser(page, options = {}) {
|
|
101
|
+
const context = page?.context?.();
|
|
102
|
+
if (!context?.request) {
|
|
103
|
+
throw new Error("loginAsExistingUser requires a Playwright page.");
|
|
104
|
+
}
|
|
105
|
+
return loginRequestAsExistingUser(context.request, options);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { loginAsExistingUser, loginRequestAsExistingUser };
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import assert from "node:assert/strict";
|
|
2
|
+
import { readFile } from "node:fs/promises";
|
|
3
|
+
import test from "node:test";
|
|
4
|
+
|
|
5
|
+
// The auth-surface pattern shows the app's identity on its sign-in, reset and sign-out screens: each page renders the
|
|
6
|
+
// app's view wrapper, and the wrapper fills the default view's brand slot with AppBrand.vue, the app's name.
|
|
7
|
+
const EXAMPLE = new URL("../patterns/auth-surface/example/src/", import.meta.url);
|
|
8
|
+
const SCREENS = Object.freeze([
|
|
9
|
+
{ page: "login", view: "LoginView" },
|
|
10
|
+
{ page: "reset-password", view: "ResetPasswordView" },
|
|
11
|
+
{ page: "signout", view: "SignOutView" }
|
|
12
|
+
]);
|
|
13
|
+
const read = (relative) => readFile(new URL(relative, EXAMPLE), "utf8");
|
|
14
|
+
|
|
15
|
+
test("the auth-surface pages render the app's view wrappers, which fill the brand slot with AppBrand", async () => {
|
|
16
|
+
for (const { page, view } of SCREENS) {
|
|
17
|
+
const pageSource = await read(`pages/auth/${page}.vue`);
|
|
18
|
+
assert.match(pageSource, new RegExp(`import ${view} from "@/views/auth/${view}\\.vue";`, "u"), `${page}.vue imports the app's wrapper`);
|
|
19
|
+
assert.match(pageSource, new RegExp(`<${view} />`, "u"), `${page}.vue renders the app's wrapper`);
|
|
20
|
+
assert.doesNotMatch(pageSource, /Default\w+View/u, `${page}.vue does not render the default view itself`);
|
|
21
|
+
|
|
22
|
+
const viewSource = await read(`views/auth/${view}.vue`);
|
|
23
|
+
assert.match(viewSource, new RegExp(`import Default${view} from "@jskit-ai/auth-web/client/views/Default${view}";`, "u"));
|
|
24
|
+
assert.match(viewSource, /import AppBrand from "@\/components\/AppBrand\.vue";/u);
|
|
25
|
+
assert.match(viewSource, /<template #brand="\{ compact \}">\s*<AppBrand :compact="compact" \/>\s*<\/template>/u, `${view}.vue fills the brand slot`);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
test("AppBrand shows the app's name and no heading", async () => {
|
|
30
|
+
const source = await read("components/AppBrand.vue");
|
|
31
|
+
assert.match(source, /const APP_NAME = "Reading Room";/u);
|
|
32
|
+
assert.match(source, /compact \? 'text-title-medium' : 'text-title-large'/u);
|
|
33
|
+
assert.doesNotMatch(source, /<h[1-6]\b/u);
|
|
34
|
+
});
|
|
@@ -75,38 +75,39 @@ test("auth profile activator keeps Material 3's 48dp touch target without a fixe
|
|
|
75
75
|
const widgetSource = readFileSync(widgetPath, "utf8");
|
|
76
76
|
|
|
77
77
|
assert.match(widgetSource, /class="auth-profile-widget__activator text-none pl-1 pr-2"/);
|
|
78
|
+
// Without the name, up to medium width, the activator is an icon button, so its state layer is a circle round the
|
|
79
|
+
// avatar; the name shows on expanded windows only, through the shell's window size classes.
|
|
80
|
+
assert.match(widgetSource, /const showsName = computed\(\(\) => isExpanded\.value \|\| isLarge\.value\);/u);
|
|
81
|
+
assert.match(widgetSource, /<v-btn v-else v-bind="props" icon variant="text" class="auth-profile-widget__activator" :aria-label="displayName">/u);
|
|
78
82
|
// material-web gives every default-size button a 48dp touch target around its 40dp body; a fixed height would
|
|
79
83
|
// make the button itself taller than Material 3 draws it.
|
|
80
84
|
assert.doesNotMatch(widgetSource, /min-height/u);
|
|
81
85
|
assert.doesNotMatch(widgetSource, /<v-btn[^>]*auth-profile-widget__activator[^>]*\ssize=/u);
|
|
82
86
|
});
|
|
83
87
|
|
|
84
|
-
test("
|
|
85
|
-
const
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
assert.match(
|
|
89
|
-
assert.match(viewSource, /useDisplay\(\{\s*mobileBreakpoint:\s*960\s*\}\)/);
|
|
90
|
-
assert.doesNotMatch(viewSource, /<v-main\b/);
|
|
91
|
-
assert.match(viewSource, /login-screen--mobile/);
|
|
92
|
-
assert.match(viewSource, /login-shell--mobile/);
|
|
93
|
-
assert.match(viewSource, /auth-card--mobile/);
|
|
94
|
-
assert.match(viewSource, /auth-content--mobile/);
|
|
95
|
-
assert.match(viewSource, /:elevation="isMobileViewport \? 0 : 1"/);
|
|
96
|
-
// An elevated Material 3 card on wide windows, the whole screen on phones; never an outlined one.
|
|
97
|
-
assert.doesNotMatch(viewSource, /:border=|\sborder(?=[\s>])/);
|
|
98
|
-
assert.match(viewSource, /\.login-screen\s*\{[\s\S]*position:\s*fixed;/);
|
|
88
|
+
test("the auth views fill the viewport through AuthScreen: a card on wide windows, the whole screen on phones", () => {
|
|
89
|
+
const read = (name) => readFileSync(fileURLToPath(new URL(`../src/client/views/${name}.vue`, import.meta.url)), "utf8");
|
|
90
|
+
const screen = read("AuthScreen");
|
|
91
|
+
assert.match(screen, /useDisplay\(\{\s*mobileBreakpoint:\s*960\s*\}\)/);
|
|
92
|
+
assert.match(screen, /\.auth-screen\s*\{[\s\S]*position:\s*fixed;/);
|
|
99
93
|
// The full-viewport screen starts below shell banners shown on this bar-less surface.
|
|
100
|
-
assert.match(
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
94
|
+
assert.match(screen, /\.auth-screen\s*\{[\s\S]*inset:\s*var\(--shell-error-banners-inline-height, 0px\) 0 0;/);
|
|
95
|
+
assert.doesNotMatch(screen, /min-height:\s*100dvh/);
|
|
96
|
+
for (const [name, card] of [["DefaultLoginView", "auth-card"], ["DefaultResetPasswordView", "reset-card"], ["DefaultSignOutView", "signout-card"]]) {
|
|
97
|
+
const view = read(name);
|
|
98
|
+
assert.match(view, /<AuthScreen\b/, name);
|
|
99
|
+
// The app's brand slot reaches the screen's pane and row.
|
|
100
|
+
assert.match(view, /<template v-if="\$slots\.brand" #brand="brand">\s*<slot name="brand" v-bind="brand" \/>/, name);
|
|
101
|
+
assert.doesNotMatch(view, /<v-main\b|position:\s*fixed/, name);
|
|
102
|
+
assert.match(view, new RegExp(`${card}--mobile`), name);
|
|
103
|
+
// One container treatment: the card's tone against the screen, with no shadow or outline over it.
|
|
104
|
+
assert.match(view, /<v-card\b[^>]*\svariant="flat"/, name);
|
|
105
|
+
assert.doesNotMatch(view, /:?elevation=/, name);
|
|
106
|
+
// An elevated Material 3 card on wide windows, the whole screen on phones; never an outlined one.
|
|
107
|
+
assert.doesNotMatch(view, /:border=|\sborder(?=[\s>])/, name);
|
|
108
|
+
// Each has its one h1.
|
|
109
|
+
assert.equal((view.match(/<h1\b/gu) || []).length, 1, name);
|
|
110
|
+
}
|
|
110
111
|
});
|
|
111
112
|
|
|
112
113
|
test("default login view avoids decorative login chrome", () => {
|
|
@@ -117,7 +118,9 @@ test("default login view avoids decorative login chrome", () => {
|
|
|
117
118
|
|
|
118
119
|
assert.match(viewSource, /v-if="authTitle \|\| authSubtitle"/);
|
|
119
120
|
assert.doesNotMatch(viewSource, /Jskit Workspace|JSKIT WORKSPACE|auth-kicker|>Secure</);
|
|
120
|
-
|
|
121
|
+
// Sign-in has its one h1 ("Sign in") and no tagline.
|
|
122
|
+
assert.match(constantsSource, /AUTH_TITLE_BY_MODE = Object\.freeze\(\{\s*\[LOGIN_MODE\]:\s*"jskit\.auth\.login\.title\.login"/);
|
|
123
|
+
assert.match(constantsSource, /AUTH_SUBTITLE_BY_MODE = Object\.freeze\(\{\s*\[LOGIN_MODE\]:\s*""/);
|
|
121
124
|
assert.doesNotMatch(constantsSource, /\[LOGIN_MODE\]:\s*"Welcome"/);
|
|
122
125
|
assert.doesNotMatch(constantsSource, /\[LOGIN_MODE\]:\s*"Sign in to continue\.?"/);
|
|
123
126
|
});
|