@bevel-software/platform-core-frontend 0.3.0 → 0.3.1
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": "@bevel-software/platform-core-frontend",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"description": "Open-source core UI of the Bevel platform (raw TS/TSX source): workspace explorer/viewer, branches & change requests, Library, secrets, tools, access control.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./src/index.ts",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"tailwind-merge": "^3.5.0",
|
|
39
39
|
"xlsx": "^0.18.5",
|
|
40
40
|
"yaml": "^2.9.0",
|
|
41
|
-
"@bevel-software/platform-shared": "0.3.
|
|
41
|
+
"@bevel-software/platform-shared": "0.3.1"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@testing-library/jest-dom": "^6.9.1",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
|
2
|
-
import { render, screen, waitFor } from '@testing-library/react';
|
|
2
|
+
import { render, screen, waitFor, within } from '@testing-library/react';
|
|
3
3
|
import userEvent from '@testing-library/user-event';
|
|
4
4
|
import { UserAccountsPage } from '../components/UserAccountsPage';
|
|
5
5
|
import { AdminContext } from '../state/admin.context';
|
|
@@ -75,17 +75,29 @@ describe('UserAccountsPage', () => {
|
|
|
75
75
|
renderPage();
|
|
76
76
|
await waitFor(() => expect(screen.getByText('Alice')).toBeInTheDocument());
|
|
77
77
|
expect(screen.getByText(/Single sign-on only/)).toBeInTheDocument();
|
|
78
|
-
expect(
|
|
79
|
-
|
|
78
|
+
expect(
|
|
79
|
+
screen.getByRole('button', { name: 'Set password for alice@example.com' }),
|
|
80
|
+
).toBeInTheDocument();
|
|
81
|
+
expect(
|
|
82
|
+
screen.getByRole('button', { name: 'Delete account alice@example.com' }),
|
|
83
|
+
).toBeInTheDocument();
|
|
84
|
+
expect(
|
|
85
|
+
screen.queryByRole('button', { name: 'Set password for admin@example.com' }),
|
|
86
|
+
).not.toBeInTheDocument();
|
|
87
|
+
expect(
|
|
88
|
+
screen.queryByRole('button', { name: 'Delete account admin@example.com' }),
|
|
89
|
+
).not.toBeInTheDocument();
|
|
80
90
|
});
|
|
81
91
|
|
|
82
92
|
it('sets a password for a user WITHOUT touching their name', async () => {
|
|
83
93
|
renderPage();
|
|
84
94
|
await waitFor(() => screen.getByText('Alice'));
|
|
85
|
-
await userEvent.click(screen.getByRole('button', { name: 'Set password' }));
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
95
|
+
await userEvent.click(screen.getByRole('button', { name: 'Set password for alice@example.com' }));
|
|
96
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
97
|
+
// Empty password → the confirm button stays disabled; nothing is sent.
|
|
98
|
+
expect(dialog.getByRole('button', { name: 'Set password' })).toBeDisabled();
|
|
99
|
+
await userEvent.type(dialog.getByLabelText('New password'), 'fresh-password-1');
|
|
100
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Set password' }));
|
|
89
101
|
await waitFor(() =>
|
|
90
102
|
expect(createAccount).toHaveBeenCalledWith('alice@example.com', '', 'fresh-password-1'),
|
|
91
103
|
);
|
|
@@ -97,15 +109,26 @@ describe('UserAccountsPage', () => {
|
|
|
97
109
|
it('deletes an account after confirmation', async () => {
|
|
98
110
|
renderPage();
|
|
99
111
|
await waitFor(() => screen.getByText('Alice'));
|
|
100
|
-
await userEvent.click(screen.getByRole('button', { name: 'Delete account' }));
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
await userEvent.click(buttons[buttons.length - 1]);
|
|
112
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
113
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
114
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Delete account' }));
|
|
104
115
|
await waitFor(() => expect(deleteAccount).toHaveBeenCalledWith('u-alice'));
|
|
105
116
|
// List reloaded after the delete.
|
|
106
117
|
expect(listAccounts).toHaveBeenCalledTimes(2);
|
|
107
118
|
});
|
|
108
119
|
|
|
120
|
+
it('a failed delete closes the dialog, surfaces the error, and does not reload', async () => {
|
|
121
|
+
vi.mocked(deleteAccount).mockRejectedValueOnce(new Error('Failed to erase user'));
|
|
122
|
+
renderPage();
|
|
123
|
+
await waitFor(() => screen.getByText('Alice'));
|
|
124
|
+
await userEvent.click(screen.getByRole('button', { name: 'Delete account alice@example.com' }));
|
|
125
|
+
const dialog = within(screen.getByRole('dialog'));
|
|
126
|
+
await userEvent.click(dialog.getByRole('button', { name: 'Delete account' }));
|
|
127
|
+
await waitFor(() => expect(screen.queryByRole('dialog')).not.toBeInTheDocument());
|
|
128
|
+
expect(screen.getByText('Failed to erase user')).toBeInTheDocument();
|
|
129
|
+
expect(listAccounts).toHaveBeenCalledTimes(1);
|
|
130
|
+
});
|
|
131
|
+
|
|
109
132
|
it('adds a new account and refreshes the list', async () => {
|
|
110
133
|
renderPage();
|
|
111
134
|
await waitFor(() => screen.getByText('Alice'));
|
|
@@ -51,7 +51,11 @@ export function UserAccountsPage() {
|
|
|
51
51
|
setAccounts(rows);
|
|
52
52
|
setError(null);
|
|
53
53
|
})
|
|
54
|
-
.catch((err) =>
|
|
54
|
+
.catch((err) => {
|
|
55
|
+
setError(err instanceof Error ? err.message : "Couldn't load accounts.");
|
|
56
|
+
// Leave no eternal "Loading…" next to the error banner.
|
|
57
|
+
setAccounts((prev) => prev ?? []);
|
|
58
|
+
});
|
|
55
59
|
}, []);
|
|
56
60
|
|
|
57
61
|
useEffect(() => {
|
|
@@ -82,7 +86,7 @@ export function UserAccountsPage() {
|
|
|
82
86
|
}
|
|
83
87
|
|
|
84
88
|
async function confirmSetPassword() {
|
|
85
|
-
if (!passwordTarget || savingPassword) return;
|
|
89
|
+
if (!passwordTarget || savingPassword || newPassword.length === 0) return;
|
|
86
90
|
setSavingPassword(true);
|
|
87
91
|
setPasswordError(null);
|
|
88
92
|
try {
|
|
@@ -181,6 +185,7 @@ export function UserAccountsPage() {
|
|
|
181
185
|
onClick={() => openPasswordDialog(account)}
|
|
182
186
|
className="text-xs px-2 py-1 rounded text-slate-700 hover:bg-slate-100 border border-slate-200"
|
|
183
187
|
title="Set a new sign-in password for this account."
|
|
188
|
+
aria-label={`Set password for ${account.email}`}
|
|
184
189
|
>
|
|
185
190
|
Set password
|
|
186
191
|
</button>
|
|
@@ -190,6 +195,7 @@ export function UserAccountsPage() {
|
|
|
190
195
|
onClick={() => setPendingDelete(account)}
|
|
191
196
|
className="text-xs px-2 py-1 rounded text-red-700 hover:bg-red-50 border border-red-200"
|
|
192
197
|
title="Permanently delete this account and its personal data."
|
|
198
|
+
aria-label={`Delete account ${account.email}`}
|
|
193
199
|
>
|
|
194
200
|
Delete account
|
|
195
201
|
</button>
|
|
@@ -271,7 +277,7 @@ export function UserAccountsPage() {
|
|
|
271
277
|
</button>
|
|
272
278
|
<button
|
|
273
279
|
onClick={confirmSetPassword}
|
|
274
|
-
disabled={savingPassword}
|
|
280
|
+
disabled={savingPassword || newPassword.length === 0}
|
|
275
281
|
className="px-3 py-1.5 text-sm rounded bg-bevel hover:bg-bevel-deep text-white disabled:opacity-50"
|
|
276
282
|
>
|
|
277
283
|
{savingPassword ? 'Saving…' : 'Set password'}
|
|
@@ -336,8 +342,10 @@ export function UserAccountsPage() {
|
|
|
336
342
|
{pendingDelete?.name} ({pendingDelete?.email})
|
|
337
343
|
</span>
|
|
338
344
|
? This removes their personal data for good and anonymizes their past review activity.
|
|
339
|
-
Their saves in the knowledge base keep their history.
|
|
340
|
-
|
|
345
|
+
Their saves in the knowledge base keep their history.{' '}
|
|
346
|
+
{pendingDelete?.hasPassword
|
|
347
|
+
? 'To sign in again they will need an admin to create a new account for them.'
|
|
348
|
+
: 'They can sign in again later with single sign-on, but will start fresh.'}
|
|
341
349
|
</p>
|
|
342
350
|
</Dialog>
|
|
343
351
|
</>
|