@jskit-ai/auth-web 0.2.14 → 0.2.16
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 +7 -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 +7 -7
- 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/test/authSurfacePatternBrand.test.js +34 -0
- package/test/clientSurface.test.js +29 -26
- 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>
|
|
@@ -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
|
});
|
|
@@ -486,3 +486,217 @@ test("a failed sign-out shows the error and retries, on a phone-sized screen", o
|
|
|
486
486
|
await expect(page.locator(".login-screen--mobile")).toHaveCount(1);
|
|
487
487
|
await finish(api);
|
|
488
488
|
});
|
|
489
|
+
|
|
490
|
+
// The app bar's account control leaves the bar's title and actions their room: an icon button around the avatar on
|
|
491
|
+
// compact and medium windows, and on expanded ones the name beside it, ending in an ellipsis past 12rem.
|
|
492
|
+
test("the account control is the avatar alone up to medium width and truncates a long name beside it on wider windows", options, async () => {
|
|
493
|
+
const name = "Augusta Ada King, Countess of Lovelace and First Programmer";
|
|
494
|
+
const api = await openApp({ session: { ...SIGNED_IN, username: name }, viewport: { width: 768, height: 1024 } });
|
|
495
|
+
const { page } = api;
|
|
496
|
+
await page.goto("/home");
|
|
497
|
+
const control = page.getByRole("button", { name });
|
|
498
|
+
await expect(control).toBeVisible();
|
|
499
|
+
assert.equal(await control.evaluate((element) => element.classList.contains("v-btn--icon")), true, "an icon button at 768");
|
|
500
|
+
await expect(page.locator(".auth-profile-widget__name")).toHaveCount(0);
|
|
501
|
+
|
|
502
|
+
await page.setViewportSize({ width: 1280, height: 900 });
|
|
503
|
+
const label = page.locator(".auth-profile-widget__name");
|
|
504
|
+
await expect(label).toHaveText(name);
|
|
505
|
+
const shown = await label.evaluate((element) => ({
|
|
506
|
+
width: element.getBoundingClientRect().width,
|
|
507
|
+
truncated: element.scrollWidth > element.clientWidth,
|
|
508
|
+
rem: Number.parseFloat(getComputedStyle(document.documentElement).fontSize)
|
|
509
|
+
}));
|
|
510
|
+
assert.ok(shown.width <= 12 * shown.rem + 1, `the name takes at most 12rem: ${shown.width}px`);
|
|
511
|
+
assert.equal(shown.truncated, true, "a long name ends in an ellipsis");
|
|
512
|
+
await finish(api);
|
|
513
|
+
});
|
|
514
|
+
|
|
515
|
+
// Material 3's segmented button: one outline, equal segments, the selected one on secondary-container with a check.
|
|
516
|
+
// Register has no "Back to sign in": the Sign in segment is the way back.
|
|
517
|
+
test("Sign in and Register are a segmented button, and Register has no way back but its segment", options, async () => {
|
|
518
|
+
const api = await openApp();
|
|
519
|
+
const { page } = api;
|
|
520
|
+
await page.goto("/auth/login");
|
|
521
|
+
const group = page.getByRole("radiogroup", { name: "Sign in or register" });
|
|
522
|
+
await expect(group).toBeVisible();
|
|
523
|
+
const read = () => group.evaluate((element) => {
|
|
524
|
+
const role = (name) => {
|
|
525
|
+
const probe = document.body.appendChild(document.createElement("span"));
|
|
526
|
+
probe.style.color = `rgb(var(--v-theme-${name}))`;
|
|
527
|
+
const color = getComputedStyle(probe).color;
|
|
528
|
+
probe.remove();
|
|
529
|
+
return color;
|
|
530
|
+
};
|
|
531
|
+
const style = getComputedStyle(element);
|
|
532
|
+
return {
|
|
533
|
+
outline: [style.borderTopWidth, style.borderTopColor === role("outline"), style.borderTopLeftRadius],
|
|
534
|
+
height: element.getBoundingClientRect().height,
|
|
535
|
+
segments: [...element.querySelectorAll("[role=radio]")].map((segment) => {
|
|
536
|
+
const segmentStyle = getComputedStyle(segment);
|
|
537
|
+
return {
|
|
538
|
+
name: segment.textContent.trim(),
|
|
539
|
+
checked: segment.getAttribute("aria-checked"),
|
|
540
|
+
width: Math.round(segment.getBoundingClientRect().width),
|
|
541
|
+
check: segment.querySelectorAll(".v-btn__prepend .v-icon").length,
|
|
542
|
+
filled: segmentStyle.backgroundColor === role("secondary-container"),
|
|
543
|
+
type: [segmentStyle.fontSize, segmentStyle.fontWeight]
|
|
544
|
+
};
|
|
545
|
+
})
|
|
546
|
+
};
|
|
547
|
+
});
|
|
548
|
+
const expected = (selected) => {
|
|
549
|
+
const segments = ["Sign in", "Register"].map((name) => ({
|
|
550
|
+
name,
|
|
551
|
+
checked: String(name === selected),
|
|
552
|
+
check: name === selected ? 1 : 0,
|
|
553
|
+
filled: name === selected,
|
|
554
|
+
type: ["14px", "500"]
|
|
555
|
+
}));
|
|
556
|
+
return { outline: ["1px", true, "9999px"], height: 40, segments };
|
|
557
|
+
};
|
|
558
|
+
const withoutWidths = ({ segments, ...rest }) => ({ ...rest, segments: segments.map(({ width, ...segment }) => segment) });
|
|
559
|
+
|
|
560
|
+
const layout = await read();
|
|
561
|
+
assert.deepEqual(withoutWidths(layout), expected("Sign in"));
|
|
562
|
+
assert.equal(layout.segments[0].width, layout.segments[1].width, "the segments are equal");
|
|
563
|
+
|
|
564
|
+
await page.getByRole("radio", { name: "Register" }).click();
|
|
565
|
+
await expect(page.getByRole("heading", { level: 1, name: "Create your account" })).toBeVisible();
|
|
566
|
+
// The segments' fill changes through Vuetify's background transition.
|
|
567
|
+
await expect.poll(async () => withoutWidths(await read())).toEqual(expected("Register"));
|
|
568
|
+
await expect(page.getByRole("button", { name: "Back to sign in" })).toHaveCount(0);
|
|
569
|
+
await expect(page.getByText("Already have an account?")).toHaveCount(0);
|
|
570
|
+
|
|
571
|
+
await page.getByRole("radio", { name: "Sign in" }).click();
|
|
572
|
+
await expect(page.getByRole("heading", { level: 1, name: "Sign in" })).toBeVisible();
|
|
573
|
+
await finish(api);
|
|
574
|
+
});
|
|
575
|
+
|
|
576
|
+
test("every auth screen has its one h1, sign-in's included", options, async () => {
|
|
577
|
+
const api = await openApp({
|
|
578
|
+
routes: {
|
|
579
|
+
"POST /api/password/recovery": deny(400, "Recovery link expired."),
|
|
580
|
+
"POST /api/logout": deny(503, "Sign-out service down.")
|
|
581
|
+
}
|
|
582
|
+
});
|
|
583
|
+
const { page } = api;
|
|
584
|
+
const heading = async (name) => {
|
|
585
|
+
await expect(page.getByRole("heading", { level: 1, name })).toBeVisible();
|
|
586
|
+
assert.equal(await page.locator("h1").count(), 1, `one h1 for ${name}`);
|
|
587
|
+
};
|
|
588
|
+
await page.goto("/auth/login");
|
|
589
|
+
await heading("Sign in");
|
|
590
|
+
await page.getByTestId("auth-mode-register").click();
|
|
591
|
+
await heading("Create your account");
|
|
592
|
+
await page.getByTestId("auth-mode-sign-in").click();
|
|
593
|
+
await page.getByRole("button", { name: "Forgot password?" }).click();
|
|
594
|
+
await heading("Reset your password");
|
|
595
|
+
await page.goto("/auth/reset-password?token=stale");
|
|
596
|
+
await heading("Reset password");
|
|
597
|
+
await page.goto("/auth/signout");
|
|
598
|
+
await heading("Signing you out");
|
|
599
|
+
await finish(api);
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
test("an app's brand shows in a pane beside the card on wide windows and in a row above it on phones", options, async () => {
|
|
603
|
+
for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }]) {
|
|
604
|
+
const at = `${viewport.width}px`;
|
|
605
|
+
const api = await openApp({
|
|
606
|
+
viewport,
|
|
607
|
+
routes: {
|
|
608
|
+
"POST /api/password/recovery": deny(400, "Recovery link expired."),
|
|
609
|
+
"POST /api/logout": deny(503, "Sign-out service down.")
|
|
610
|
+
}
|
|
611
|
+
});
|
|
612
|
+
const { page } = api;
|
|
613
|
+
for (const [path, title] of [["/auth/branded/login", "Sign in"], ["/auth/branded/reset-password?token=stale", "Reset password"], ["/auth/branded/signout", "Signing you out"]]) {
|
|
614
|
+
await page.goto(path);
|
|
615
|
+
await expect(page.getByRole("heading", { level: 1, name: title }), `${at} ${path}`).toBeVisible();
|
|
616
|
+
const layout = await page.evaluate(() => {
|
|
617
|
+
const box = (selector) => document.querySelector(selector)?.getBoundingClientRect().toJSON() || null;
|
|
618
|
+
const screen = document.querySelector("[data-testid='auth-screen']");
|
|
619
|
+
return {
|
|
620
|
+
pane: box("[data-testid='auth-brand-pane']"),
|
|
621
|
+
row: box("[data-testid='auth-brand-row']"),
|
|
622
|
+
card: box("[data-testid='auth-screen'] .v-card"),
|
|
623
|
+
treatment: (() => {
|
|
624
|
+
const style = window.getComputedStyle(document.querySelector("[data-testid='auth-screen'] .v-card"));
|
|
625
|
+
return { shadow: style.boxShadow, border: style.borderTopWidth, background: style.backgroundColor };
|
|
626
|
+
})(),
|
|
627
|
+
screenBackground: window.getComputedStyle(screen).backgroundColor,
|
|
628
|
+
h1s: document.querySelectorAll("h1").length,
|
|
629
|
+
overflow: screen.scrollWidth - screen.clientWidth
|
|
630
|
+
};
|
|
631
|
+
});
|
|
632
|
+
assert.equal(layout.h1s, 1, `${at} ${path}: the brand adds no heading`);
|
|
633
|
+
// Vuetify's flat variant computes as zero-size shadow layers: every offset, blur and spread is 0.
|
|
634
|
+
const shadowSizes = layout.treatment.shadow === "none" ? [] : layout.treatment.shadow.replace(/rgba?\([^)]*\)/gu, "").match(/-?[\d.]+px/gu) || [];
|
|
635
|
+
assert.deepEqual(shadowSizes.filter((size) => Number.parseFloat(size) !== 0), [], `${at} ${path}: the card has no shadow (${layout.treatment.shadow})`);
|
|
636
|
+
assert.equal(layout.treatment.border, "0px", `${at} ${path}: the card has no outline`);
|
|
637
|
+
assert.ok(layout.overflow <= 0, `${at} ${path}: no sideways scroll`);
|
|
638
|
+
if (viewport.width >= 960) {
|
|
639
|
+
assert.equal(layout.row, null, `${at} ${path}: no compact row`);
|
|
640
|
+
await expect(page.getByTestId("fixture-brand-pane")).toBeVisible();
|
|
641
|
+
assert.equal(Math.round(layout.pane.left), 0, `${at} ${path}: the pane starts at the window's edge`);
|
|
642
|
+
assert.equal(Math.round(layout.pane.height), viewport.height, `${at} ${path}: the pane fills the height`);
|
|
643
|
+
assert.ok(layout.card.left >= layout.pane.right, `${at} ${path}: the card is beside the pane`);
|
|
644
|
+
assert.notEqual(layout.treatment.background, layout.screenBackground, `${at} ${path}: the card's tone sets it off the screen`);
|
|
645
|
+
} else {
|
|
646
|
+
assert.equal(layout.pane, null, `${at} ${path}: no pane`);
|
|
647
|
+
await expect(page.getByTestId("fixture-brand-row")).toBeVisible();
|
|
648
|
+
assert.ok(layout.row.bottom <= layout.card.top + 1, `${at} ${path}: the row is above the card`);
|
|
649
|
+
assert.equal(Math.round(layout.card.width), viewport.width, `${at} ${path}: the card is full-bleed`);
|
|
650
|
+
assert.ok(Math.round(layout.card.bottom) >= viewport.height, `${at} ${path}: the card fills the rest`);
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
// Without a brand there is neither.
|
|
654
|
+
await page.goto("/auth/login");
|
|
655
|
+
await expect(page.getByRole("heading", { level: 1, name: "Sign in" })).toBeVisible();
|
|
656
|
+
await expect(page.getByTestId("auth-brand-pane")).toHaveCount(0);
|
|
657
|
+
await expect(page.getByTestId("auth-brand-row")).toHaveCount(0);
|
|
658
|
+
await finish(api);
|
|
659
|
+
}
|
|
660
|
+
});
|
|
661
|
+
|
|
662
|
+
// The auth-surface pattern's own pages, as an app copies them: each renders the app's view wrapper, which puts the
|
|
663
|
+
// app's name (AppBrand.vue, "Reading Room") in the brand slot, so every screen says which app it signs in to.
|
|
664
|
+
test("the auth-surface pattern's sign-in, reset and sign-out pages show the app's name", options, async () => {
|
|
665
|
+
for (const viewport of [{ width: 1280, height: 900 }, { width: 390, height: 844 }]) {
|
|
666
|
+
const at = `${viewport.width}px`;
|
|
667
|
+
const api = await openApp({
|
|
668
|
+
viewport,
|
|
669
|
+
routes: {
|
|
670
|
+
"POST /api/password/recovery": deny(400, "Recovery link expired."),
|
|
671
|
+
"POST /api/logout": deny(503, "Sign-out service down.")
|
|
672
|
+
}
|
|
673
|
+
});
|
|
674
|
+
const { page } = api;
|
|
675
|
+
for (const [path, title] of [["/auth/pattern/login", "Sign in"], ["/auth/pattern/reset-password?token=stale", "Reset password"], ["/auth/pattern/signout", "Signing you out"]]) {
|
|
676
|
+
await page.goto(path);
|
|
677
|
+
await expect(page.getByRole("heading", { level: 1, name: title }), `${at} ${path}`).toBeVisible();
|
|
678
|
+
const holder = page.getByTestId(viewport.width >= 960 ? "auth-brand-pane" : "auth-brand-row");
|
|
679
|
+
await expect(holder.getByTestId("app-brand"), `${at} ${path}`).toHaveText("Reading Room");
|
|
680
|
+
await expect(page.getByTestId("app-brand"), `${at} ${path}: one brand`).toHaveCount(1);
|
|
681
|
+
await expect(page.getByRole("heading", { level: 1 }), `${at} ${path}: the brand adds no heading`).toHaveCount(1);
|
|
682
|
+
}
|
|
683
|
+
await finish(api);
|
|
684
|
+
}
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
test("an app whose accounts are by invitation offers Register only to an invited person", options, async () => {
|
|
688
|
+
const invitationOnly = {
|
|
689
|
+
...SIGNED_OUT,
|
|
690
|
+
authCapabilities: { ...CAPABILITIES, features: { ...CAPABILITIES.features, password: { login: true, register: true, selfRegister: false } } }
|
|
691
|
+
};
|
|
692
|
+
const api = await openApp({ session: invitationOnly });
|
|
693
|
+
const { page } = api;
|
|
694
|
+
await page.goto("/auth/login");
|
|
695
|
+
await expect(page.getByRole("heading", { level: 1, name: "Sign in" })).toBeVisible();
|
|
696
|
+
// Sign in alone is no choice: no segmented button.
|
|
697
|
+
await expect(page.getByTestId("auth-mode-switch")).toHaveCount(0);
|
|
698
|
+
await page.goto("/auth/login?invitationToken=invite-for-bea");
|
|
699
|
+
await expect(page.getByTestId("auth-mode-sign-in")).toBeVisible();
|
|
700
|
+
await expect(page.getByTestId("auth-mode-register")).toBeVisible();
|
|
701
|
+
await finish(api);
|
|
702
|
+
});
|