@haatlabs-core/templates 0.17.0 → 0.18.0
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 +3 -3
- package/starter/apps/web/index.html +2 -0
- package/starter/apps/web/public/theme-boot.js +6 -0
- package/starter/apps/worker/src/runtime.ts +2 -4
- package/starter/packages/web-ui/package.json.tmpl +2 -0
- package/starter/packages/web-ui/src/App.test.tsx +28 -19
- package/starter/packages/web-ui/src/App.tsx +131 -120
- package/starter/packages/web-ui/src/components/Logo.tsx +10 -0
- package/starter/packages/web-ui/src/pages/HomePage.tsx +10 -7
- package/starter/packages/web-ui/src/pages/stores/Stores.test.tsx +25 -17
- package/starter/packages/web-ui/src/styles.css +16 -14
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@haatlabs-core/templates",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "The starter files and shared project files that @haatlabs-core/cli writes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"haatlabs"
|
|
@@ -36,8 +36,8 @@
|
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"playwright-core": "1.63.0",
|
|
39
|
-
"@haatlabs-core/tsconfig": "0.
|
|
40
|
-
"@haatlabs-core/vitest-config": "0.
|
|
39
|
+
"@haatlabs-core/tsconfig": "0.18.0",
|
|
40
|
+
"@haatlabs-core/vitest-config": "0.18.0"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"build": "rm -rf dist && tsc -p tsconfig.build.json",
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>@@Name@@</title>
|
|
7
|
+
<!-- Sets the chosen light or dark theme before the page paints (a file: the CSP forbids inline scripts). -->
|
|
8
|
+
<script src="/theme-boot.js"></script>
|
|
7
9
|
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
|
|
8
10
|
</head>
|
|
9
11
|
<body>
|
|
@@ -46,10 +46,8 @@ export interface WorkerOverrides {
|
|
|
46
46
|
healthPort?: number | null;
|
|
47
47
|
/** The registry to record into (tests read it); a new one by default. */
|
|
48
48
|
metrics?: Metrics;
|
|
49
|
-
|
|
50
|
-
/** What calls Shopify (tests stand in for it); the global fetch by default. */
|
|
49
|
+
/** What the worker calls out with (tests stand in for it); the global fetch by default. */
|
|
51
50
|
fetch?: typeof fetch;
|
|
52
|
-
#@end
|
|
53
51
|
}
|
|
54
52
|
|
|
55
53
|
/**
|
|
@@ -166,7 +164,7 @@ export async function startWorker(
|
|
|
166
164
|
? startDisposableDomainRefresh({
|
|
167
165
|
store: new DisposableEmailRepository(system.db),
|
|
168
166
|
url: config.auth.disposableEmails.url,
|
|
169
|
-
fetch:
|
|
167
|
+
fetch: overrides.fetch ?? fetch,
|
|
170
168
|
logger,
|
|
171
169
|
redis,
|
|
172
170
|
appName: '@@name@@',
|
|
@@ -12,7 +12,9 @@
|
|
|
12
12
|
},
|
|
13
13
|
"dependencies": {
|
|
14
14
|
"@@@name@@/contracts": "workspace:*",
|
|
15
|
+
"@fontsource-variable/plus-jakarta-sans": "^5.3.0",
|
|
15
16
|
"@fontsource/ibm-plex-mono": "^5.3.0",
|
|
17
|
+
"@fontsource/jetbrains-mono": "^5.3.0",
|
|
16
18
|
"@fontsource/instrument-sans": "^5.3.0",
|
|
17
19
|
"@haatlabs-core/auth-contracts": "^@@platformVersion@@",
|
|
18
20
|
"@haatlabs-core/ui": "^@@platformVersion@@",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
|
-
import { cleanup, render, screen } from '@testing-library/react';
|
|
2
|
+
import { act, cleanup, render, screen } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { ALL_FEATURES_ON } from '@@@name@@/contracts';
|
|
5
5
|
import type { MeResponse } from '@@@name@@/contracts';
|
|
@@ -90,24 +90,33 @@ describe('standalone app', () => {
|
|
|
90
90
|
});
|
|
91
91
|
|
|
92
92
|
it('keeps the code step and shows the error when the code is refused, and can send a new one', async () => {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
.fn()
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
93
|
+
vi.useFakeTimers({ shouldAdvanceTime: true });
|
|
94
|
+
try {
|
|
95
|
+
const client = fakeClient({
|
|
96
|
+
me: vi.fn().mockRejectedValue(unauthorized()),
|
|
97
|
+
signInWithCode: vi
|
|
98
|
+
.fn()
|
|
99
|
+
.mockRejectedValue(new ApiError('UNAUTHENTICATED', 'That code is not right', 401)),
|
|
100
|
+
});
|
|
101
|
+
renderApp(client);
|
|
102
|
+
const user = userEvent.setup({ advanceTimers: vi.advanceTimersByTime });
|
|
103
|
+
await user.type(await screen.findByLabelText('Email'), 'owner@example.com');
|
|
104
|
+
await user.click(screen.getByRole('button', { name: 'Send me a code' }));
|
|
105
|
+
await user.type(await screen.findByLabelText('Code'), '00000000');
|
|
106
|
+
await user.click(screen.getByRole('button', { name: 'Sign in' }));
|
|
107
|
+
expect((await screen.findByRole('alert')).textContent).toBe('That code is not right');
|
|
108
|
+
// A new code may be asked for once the 60-second wait is over.
|
|
109
|
+
await act(async () => {
|
|
110
|
+
vi.advanceTimersByTime(61_000);
|
|
111
|
+
});
|
|
112
|
+
await user.click(screen.getByRole('button', { name: 'Send a new code' }));
|
|
113
|
+
expect(client.requestSignInCode).toHaveBeenCalledTimes(2);
|
|
114
|
+
// The email can be put right without starting the page again.
|
|
115
|
+
await user.click(screen.getByRole('button', { name: 'Use another email' }));
|
|
116
|
+
expect((screen.getByLabelText('Email') as HTMLInputElement).value).toBe('owner@example.com');
|
|
117
|
+
} finally {
|
|
118
|
+
vi.useRealTimers();
|
|
119
|
+
}
|
|
111
120
|
});
|
|
112
121
|
|
|
113
122
|
it('lets a code already in the inbox be used when no new one can be sent', async () => {
|
|
@@ -8,11 +8,15 @@ import '@fontsource/instrument-sans/500.css';
|
|
|
8
8
|
import '@fontsource/instrument-sans/600.css';
|
|
9
9
|
import '@fontsource/instrument-sans/700.css';
|
|
10
10
|
import '@fontsource/ibm-plex-mono/500.css';
|
|
11
|
+
import '@fontsource-variable/plus-jakarta-sans/index.css';
|
|
12
|
+
import '@fontsource/jetbrains-mono/500.css';
|
|
11
13
|
import './styles.css';
|
|
12
14
|
import { ApiError } from './api-client';
|
|
13
15
|
import type { ApiClient } from './api-client';
|
|
14
16
|
import { createQueryClient, isUnauthorized } from '@haatlabs-core/ui/client';
|
|
15
|
-
import {
|
|
17
|
+
import { AppShell, ThemeStyles } from '@haatlabs-core/ui';
|
|
18
|
+
import type { NavGroup } from '@haatlabs-core/ui';
|
|
19
|
+
import { Logo } from './components/Logo';
|
|
16
20
|
import { LoginPage } from './pages/LoginPage';
|
|
17
21
|
import { ConnectExtensionPage } from './pages/ConnectExtensionPage';
|
|
18
22
|
import { HomePage } from './pages/HomePage';
|
|
@@ -83,11 +87,60 @@ function Shell({
|
|
|
83
87
|
// A store a dashboard account connected, opened in Shopify admin, reaches only its own
|
|
84
88
|
// store: a page of the organization's own is shown only when `wholeOrganization` holds,
|
|
85
89
|
// and the API refuses its routes otherwise.
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
90
|
+
const nav: NavGroup[] = [
|
|
91
|
+
{
|
|
92
|
+
items: [
|
|
93
|
+
{ label: 'Home', to: '/home' },
|
|
94
|
+
{ label: 'Stores', to: '/stores' },
|
|
95
|
+
{ label: 'Plan and usage', to: '/usage' },
|
|
96
|
+
#@if standalone
|
|
97
|
+
{ label: 'Find images', to: '/find-images' },
|
|
98
|
+
#@end
|
|
99
|
+
],
|
|
100
|
+
},
|
|
101
|
+
];
|
|
102
|
+
const routes = (
|
|
103
|
+
<Routes>
|
|
104
|
+
<Route path="/home" element={<HomePage organizationName={me.data.organization.name} />} />
|
|
105
|
+
<Route
|
|
106
|
+
path="/stores"
|
|
107
|
+
element={
|
|
108
|
+
<StoresPage client={client} embedded={embedded} listingUrl={shopifyListingUrl} />
|
|
109
|
+
}
|
|
110
|
+
/>
|
|
111
|
+
<Route
|
|
112
|
+
path="/usage"
|
|
113
|
+
element={
|
|
114
|
+
<UsagePage
|
|
115
|
+
client={client}
|
|
116
|
+
canManagePlan={!embedded && me.data.role === 'OWNER'}
|
|
117
|
+
// The plan is the whole organization's: one store's staff only see it.
|
|
118
|
+
shopifyBilling={embedded && isAdmin && !me.data.storeOnly}
|
|
119
|
+
embedded={embedded}
|
|
120
|
+
/>
|
|
121
|
+
}
|
|
122
|
+
/>
|
|
123
|
+
#@if standalone
|
|
124
|
+
<Route path="/find-images" element={<FindImagesPage client={client} />} />
|
|
125
|
+
#@end
|
|
126
|
+
<Route
|
|
127
|
+
path="/connect/extension"
|
|
128
|
+
element={
|
|
129
|
+
<ConnectExtensionPage
|
|
130
|
+
client={client}
|
|
131
|
+
organizationName={me.data.organization.name}
|
|
132
|
+
role={me.data.role}
|
|
133
|
+
/>
|
|
134
|
+
}
|
|
135
|
+
/>
|
|
136
|
+
<Route path="*" element={<RedirectTo pathname="/home" />} />
|
|
137
|
+
</Routes>
|
|
138
|
+
);
|
|
139
|
+
if (embedded)
|
|
140
|
+
// Shopify's own frame already names the app and the shop, and there is nobody to
|
|
141
|
+
// sign out: one quiet navigation, as Shopify's own pages have.
|
|
142
|
+
return (
|
|
143
|
+
<>
|
|
91
144
|
<div className="embedded-nav">
|
|
92
145
|
<nav aria-label="Main" className="store-nav">
|
|
93
146
|
<NavLink to="/home">Home</NavLink>
|
|
@@ -95,71 +148,25 @@ function Shell({
|
|
|
95
148
|
<NavLink to="/usage">Plan and usage</NavLink>
|
|
96
149
|
</nav>
|
|
97
150
|
</div>
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
className="quiet"
|
|
115
|
-
disabled={logout.isPending}
|
|
116
|
-
onClick={() => logout.mutate()}
|
|
117
|
-
>
|
|
118
|
-
Sign out
|
|
119
|
-
</button>
|
|
120
|
-
</div>
|
|
121
|
-
</div>
|
|
122
|
-
{logout.error && !isUnauthorized(logout.error) && (
|
|
123
|
-
<p role="alert">{logout.error.message}</p>
|
|
124
|
-
)}
|
|
125
|
-
</header>
|
|
151
|
+
{routes}
|
|
152
|
+
</>
|
|
153
|
+
);
|
|
154
|
+
return (
|
|
155
|
+
<AppShell
|
|
156
|
+
brand={<Logo />}
|
|
157
|
+
nav={nav}
|
|
158
|
+
account={{
|
|
159
|
+
name: me.data.organization.name,
|
|
160
|
+
detail: me.data.user?.email ?? undefined,
|
|
161
|
+
onSignOut: () => logout.mutate(),
|
|
162
|
+
signingOut: logout.isPending,
|
|
163
|
+
}}
|
|
164
|
+
>
|
|
165
|
+
{logout.error && !isUnauthorized(logout.error) && (
|
|
166
|
+
<p role="alert">{logout.error.message}</p>
|
|
126
167
|
)}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
<Route
|
|
130
|
-
path="/stores"
|
|
131
|
-
element={
|
|
132
|
-
<StoresPage client={client} embedded={embedded} listingUrl={shopifyListingUrl} />
|
|
133
|
-
}
|
|
134
|
-
/>
|
|
135
|
-
<Route
|
|
136
|
-
path="/usage"
|
|
137
|
-
element={
|
|
138
|
-
<UsagePage
|
|
139
|
-
client={client}
|
|
140
|
-
canManagePlan={!embedded && me.data.role === 'OWNER'}
|
|
141
|
-
// The plan is the whole organization's: one store's staff only see it.
|
|
142
|
-
shopifyBilling={embedded && isAdmin && !me.data.storeOnly}
|
|
143
|
-
embedded={embedded}
|
|
144
|
-
/>
|
|
145
|
-
}
|
|
146
|
-
/>
|
|
147
|
-
#@if standalone
|
|
148
|
-
<Route path="/find-images" element={<FindImagesPage client={client} />} />
|
|
149
|
-
#@end
|
|
150
|
-
<Route
|
|
151
|
-
path="/connect/extension"
|
|
152
|
-
element={
|
|
153
|
-
<ConnectExtensionPage
|
|
154
|
-
client={client}
|
|
155
|
-
organizationName={me.data.organization.name}
|
|
156
|
-
role={me.data.role}
|
|
157
|
-
/>
|
|
158
|
-
}
|
|
159
|
-
/>
|
|
160
|
-
<Route path="*" element={<RedirectTo pathname="/home" />} />
|
|
161
|
-
</Routes>
|
|
162
|
-
</>
|
|
168
|
+
{routes}
|
|
169
|
+
</AppShell>
|
|
163
170
|
);
|
|
164
171
|
}
|
|
165
172
|
|
|
@@ -201,6 +208,8 @@ export function App({
|
|
|
201
208
|
}, [mode]);
|
|
202
209
|
return (
|
|
203
210
|
<QueryClientProvider client={queryClient}>
|
|
211
|
+
{/* Inside Shopify admin the pages keep Shopify's look. */}
|
|
212
|
+
{mode !== 'embedded' && <ThemeStyles accent="indigo" />}
|
|
204
213
|
<BrowserRouter>
|
|
205
214
|
<ScrollToTop />
|
|
206
215
|
<Shell
|
|
@@ -218,17 +227,21 @@ export function App({
|
|
|
218
227
|
import { QueryClientProvider, useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
|
|
219
228
|
import { useEffect, useState } from 'react';
|
|
220
229
|
import type { ReactElement } from 'react';
|
|
221
|
-
import { BrowserRouter,
|
|
230
|
+
import { BrowserRouter, Navigate, Route, Routes, useLocation } from 'react-router-dom';
|
|
222
231
|
import '@fontsource/instrument-sans/400.css';
|
|
223
232
|
import '@fontsource/instrument-sans/500.css';
|
|
224
233
|
import '@fontsource/instrument-sans/600.css';
|
|
225
234
|
import '@fontsource/instrument-sans/700.css';
|
|
226
235
|
import '@fontsource/ibm-plex-mono/500.css';
|
|
236
|
+
import '@fontsource-variable/plus-jakarta-sans/index.css';
|
|
237
|
+
import '@fontsource/jetbrains-mono/500.css';
|
|
227
238
|
import './styles.css';
|
|
228
239
|
import { ApiError } from './api-client';
|
|
229
240
|
import type { ApiClient } from './api-client';
|
|
230
241
|
import { createQueryClient, isUnauthorized } from '@haatlabs-core/ui/client';
|
|
231
|
-
import {
|
|
242
|
+
import { AppShell, ThemeStyles } from '@haatlabs-core/ui';
|
|
243
|
+
import type { NavGroup } from '@haatlabs-core/ui';
|
|
244
|
+
import { Logo } from './components/Logo';
|
|
232
245
|
import { LoginPage } from './pages/LoginPage';
|
|
233
246
|
import { ConnectExtensionPage } from './pages/ConnectExtensionPage';
|
|
234
247
|
import { HomePage } from './pages/HomePage';
|
|
@@ -276,56 +289,53 @@ function Shell({ client, reload }: { client: ApiClient; reload: () => void }): R
|
|
|
276
289
|
);
|
|
277
290
|
}
|
|
278
291
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
<nav aria-label="Main">
|
|
285
|
-
<NavLink to="/home">Home</NavLink>
|
|
286
|
-
<NavLink to="/usage">Plan and usage</NavLink>
|
|
292
|
+
const nav: NavGroup[] = [
|
|
293
|
+
{
|
|
294
|
+
items: [
|
|
295
|
+
{ label: 'Home', to: '/home' },
|
|
296
|
+
{ label: 'Plan and usage', to: '/usage' },
|
|
287
297
|
#@if standalone
|
|
288
|
-
|
|
298
|
+
{ label: 'Find images', to: '/find-images' },
|
|
289
299
|
#@end
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
#@if standalone
|
|
314
|
-
|
|
315
|
-
#@end
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
300
|
+
],
|
|
301
|
+
},
|
|
302
|
+
];
|
|
303
|
+
return (
|
|
304
|
+
<AppShell
|
|
305
|
+
brand={<Logo />}
|
|
306
|
+
nav={nav}
|
|
307
|
+
account={{
|
|
308
|
+
name: me.data.organization.name,
|
|
309
|
+
detail: me.data.user?.email ?? undefined,
|
|
310
|
+
onSignOut: () => logout.mutate(),
|
|
311
|
+
signingOut: logout.isPending,
|
|
312
|
+
}}
|
|
313
|
+
>
|
|
314
|
+
{logout.error && !isUnauthorized(logout.error) && (
|
|
315
|
+
<p role="alert">{logout.error.message}</p>
|
|
316
|
+
)}
|
|
317
|
+
<Routes>
|
|
318
|
+
<Route path="/home" element={<HomePage organizationName={me.data.organization.name} />} />
|
|
319
|
+
<Route
|
|
320
|
+
path="/usage"
|
|
321
|
+
element={<UsagePage client={client} canManagePlan={me.data.role === 'OWNER'} />}
|
|
322
|
+
/>
|
|
323
|
+
#@if standalone
|
|
324
|
+
<Route path="/find-images" element={<FindImagesPage client={client} />} />
|
|
325
|
+
#@end
|
|
326
|
+
<Route
|
|
327
|
+
path="/connect/extension"
|
|
328
|
+
element={
|
|
329
|
+
<ConnectExtensionPage
|
|
330
|
+
client={client}
|
|
331
|
+
organizationName={me.data.organization.name}
|
|
332
|
+
role={me.data.role}
|
|
333
|
+
/>
|
|
334
|
+
}
|
|
335
|
+
/>
|
|
336
|
+
<Route path="*" element={<RedirectTo pathname="/home" />} />
|
|
337
|
+
</Routes>
|
|
338
|
+
</AppShell>
|
|
329
339
|
);
|
|
330
340
|
}
|
|
331
341
|
|
|
@@ -357,6 +367,7 @@ export function App({
|
|
|
357
367
|
}, []);
|
|
358
368
|
return (
|
|
359
369
|
<QueryClientProvider client={queryClient}>
|
|
370
|
+
<ThemeStyles accent="indigo" />
|
|
360
371
|
<BrowserRouter>
|
|
361
372
|
<ScrollToTop />
|
|
362
373
|
<Shell client={client} reload={reload} />
|
|
@@ -48,6 +48,16 @@ function Mark(props: { size: number; onDark: boolean; label?: string }): ReactEl
|
|
|
48
48
|
/** The name as it is drawn beside the mark. */
|
|
49
49
|
const Wordmark = (): ReactElement => <span aria-hidden="true">@@name@@</span>;
|
|
50
50
|
|
|
51
|
+
/** The logo on its own: the app shell's brand, which links home itself. */
|
|
52
|
+
export function Logo(): ReactElement {
|
|
53
|
+
return (
|
|
54
|
+
<span className="logo" aria-label="@@Name@@" role="img">
|
|
55
|
+
<Mark size={SIZE.header} onDark={false} />
|
|
56
|
+
<Wordmark />
|
|
57
|
+
</span>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
51
61
|
/** The logo in the app header: a link home. */
|
|
52
62
|
export function LogoLink(): ReactElement {
|
|
53
63
|
return (
|
|
@@ -1,22 +1,25 @@
|
|
|
1
|
+
import { PageHeader } from '@haatlabs-core/ui';
|
|
1
2
|
import type { ReactElement } from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Where a signed-in user lands. The app's own work begins here: replace this page with
|
|
5
|
-
* the first thing a merchant does, and add a line to the
|
|
6
|
+
* the first thing a merchant does, and add a line to the sidebar for each page after.
|
|
6
7
|
*/
|
|
7
8
|
export function HomePage({ organizationName }: { organizationName: string }): ReactElement {
|
|
8
9
|
return (
|
|
9
10
|
<main className="page">
|
|
10
|
-
<h1>Home</h1>
|
|
11
|
-
<p>
|
|
12
11
|
#@if kindShopify
|
|
13
|
-
|
|
12
|
+
<PageHeader
|
|
13
|
+
title="Home"
|
|
14
|
+
subtitle={`Signed in to @@Name@@ as ${organizationName}. Your stores and your plan are in the sidebar.`}
|
|
15
|
+
/>
|
|
14
16
|
#@end
|
|
15
17
|
#@if !kindShopify
|
|
16
|
-
|
|
18
|
+
<PageHeader
|
|
19
|
+
title="Home"
|
|
20
|
+
subtitle={`Signed in to @@Name@@ as ${organizationName}. Your plan is in the sidebar.`}
|
|
21
|
+
/>
|
|
17
22
|
#@end
|
|
18
|
-
above.
|
|
19
|
-
</p>
|
|
20
23
|
</main>
|
|
21
24
|
);
|
|
22
25
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// @vitest-environment jsdom
|
|
2
|
-
import { cleanup, render, screen, waitFor, within } from '@testing-library/react';
|
|
2
|
+
import { act, cleanup, render, screen, waitFor, within } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
5
|
import type { MeResponse } from '@@@name@@/contracts';
|
|
@@ -201,22 +201,30 @@ describe('email sign-in on the store page of the embedded app', () => {
|
|
|
201
201
|
});
|
|
202
202
|
|
|
203
203
|
it('says so when the code is wrong, and lets it be tried again or sent again', async () => {
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
.fn()
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
204
|
+
vi.useFakeTimers({ shouldAdvanceTime: true });
|
|
205
|
+
try {
|
|
206
|
+
const client = show({
|
|
207
|
+
emailSignIn: vi.fn().mockResolvedValue(none),
|
|
208
|
+
setEmailSignIn: vi
|
|
209
|
+
.fn()
|
|
210
|
+
.mockRejectedValue(
|
|
211
|
+
new ApiError('UNAUTHENTICATED', 'That code is not right, or it has expired.', 401),
|
|
212
|
+
),
|
|
213
|
+
});
|
|
214
|
+
await askFor('owner@shop.example');
|
|
215
|
+
await confirm('00000000');
|
|
216
|
+
expect((await screen.findByRole('alert')).textContent).toBe(
|
|
217
|
+
'That code is not right, or it has expired.',
|
|
218
|
+
);
|
|
219
|
+
await act(async () => {
|
|
220
|
+
vi.advanceTimersByTime(61_000);
|
|
221
|
+
});
|
|
222
|
+
await userEvent.click(screen.getByRole('button', { name: 'Send a new code' }));
|
|
223
|
+
await waitFor(() => expect(client.requestEmailSignInCode).toHaveBeenCalledTimes(2));
|
|
224
|
+
expect(client.requestEmailSignInCode).toHaveBeenLastCalledWith({ email: 'owner@shop.example' });
|
|
225
|
+
} finally {
|
|
226
|
+
vi.useRealTimers();
|
|
227
|
+
}
|
|
220
228
|
});
|
|
221
229
|
|
|
222
230
|
it('lets the email be changed after a code was sent to the wrong one', async () => {
|
|
@@ -3,15 +3,17 @@
|
|
|
3
3
|
* docs/design. Elements are styled directly so pages need few class names.
|
|
4
4
|
*/
|
|
5
5
|
:root {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
--
|
|
9
|
-
--
|
|
10
|
-
--
|
|
11
|
-
--
|
|
12
|
-
--
|
|
13
|
-
--
|
|
14
|
-
--
|
|
6
|
+
/* The starter's colours follow the dashboard theme (@haatlabs-core/ui ThemeStyles); the values
|
|
7
|
+
after the comma are its own, kept wherever the theme is not rendered. */
|
|
8
|
+
--ground: var(--hl-ground, #f4f5f3);
|
|
9
|
+
--surface: var(--hl-surface, #ffffff);
|
|
10
|
+
--ink: var(--hl-text, #15171c);
|
|
11
|
+
--ink-soft: var(--hl-text, #2e323a);
|
|
12
|
+
--muted: var(--hl-muted, #575c66);
|
|
13
|
+
--line: var(--hl-border, #dadddb);
|
|
14
|
+
--line-soft: var(--hl-faint, #eceeea);
|
|
15
|
+
--control-line: var(--hl-border, #c4c8c1);
|
|
16
|
+
--accent: var(--hl-accent, #2447d6);
|
|
15
17
|
--accent-on-dark: #8fa6ff;
|
|
16
18
|
--high-ink: #0b5f3c;
|
|
17
19
|
--high-ground: #e3f3ea;
|
|
@@ -26,8 +28,8 @@
|
|
|
26
28
|
--notice-ink: #4f3300;
|
|
27
29
|
--notice-ground: #fff7e0;
|
|
28
30
|
--notice-line: #e7c873;
|
|
29
|
-
--font: 'Instrument Sans', system-ui, sans-serif;
|
|
30
|
-
--mono: 'IBM Plex Mono', ui-monospace, monospace;
|
|
31
|
+
--font: var(--hl-font, 'Instrument Sans', system-ui, sans-serif);
|
|
32
|
+
--mono: var(--hl-mono, 'IBM Plex Mono', ui-monospace, monospace);
|
|
31
33
|
--control: 44px;
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -109,9 +111,9 @@ button:hover:not(:disabled),
|
|
|
109
111
|
color: var(--ink);
|
|
110
112
|
}
|
|
111
113
|
button:disabled {
|
|
112
|
-
background: #c9cdd6;
|
|
113
|
-
border-color: #c9cdd6;
|
|
114
|
-
color: var(--ink-soft);
|
|
114
|
+
background: var(--hl-faint, #c9cdd6);
|
|
115
|
+
border-color: var(--hl-faint, #c9cdd6);
|
|
116
|
+
color: var(--hl-muted, var(--ink-soft));
|
|
115
117
|
cursor: not-allowed;
|
|
116
118
|
}
|
|
117
119
|
button.primary,
|