@knotpad/app 0.1.0 → 0.1.2
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/bin/brief.js +165 -78
- package/package.json +6 -86
- package/app/(app)/calendar/page.tsx +0 -57
- package/app/(app)/error.tsx +0 -35
- package/app/(app)/graph/page.tsx +0 -32
- package/app/(app)/guide/page.tsx +0 -21
- package/app/(app)/kanban/loading.tsx +0 -24
- package/app/(app)/kanban/page.tsx +0 -59
- package/app/(app)/layout.tsx +0 -122
- package/app/(app)/list/loading.tsx +0 -21
- package/app/(app)/list/page.tsx +0 -137
- package/app/(app)/loading.tsx +0 -18
- package/app/(app)/notes/[noteId]/page.tsx +0 -84
- package/app/(app)/notes/layout.tsx +0 -30
- package/app/(app)/notes/page.tsx +0 -39
- package/app/(app)/page.tsx +0 -5
- package/app/(app)/settings/agent-token/page.tsx +0 -59
- package/app/(app)/settings/backup/page.tsx +0 -49
- package/app/(app)/settings/billing/page.tsx +0 -53
- package/app/(app)/settings/calendar/page.tsx +0 -41
- package/app/(app)/settings/layout.test.tsx +0 -39
- package/app/(app)/settings/layout.tsx +0 -71
- package/app/(app)/settings/page.tsx +0 -4
- package/app/(app)/settings/security/page.tsx +0 -43
- package/app/(app)/settings/team/page.tsx +0 -74
- package/app/(app)/settings/workspace/page.tsx +0 -27
- package/app/(app)/tasks/[taskId]/page.tsx +0 -79
- package/app/(auth)/forgot-password/page.tsx +0 -106
- package/app/(auth)/guest/page.tsx +0 -56
- package/app/(auth)/layout.tsx +0 -13
- package/app/(auth)/login/page.tsx +0 -14
- package/app/(auth)/register/page.tsx +0 -193
- package/app/(auth)/reset-password/page.tsx +0 -138
- package/app/api/account/claim/route.tsx +0 -135
- package/app/api/admin/backfill-encryption/route.tsx +0 -43
- package/app/api/admin/license/route.tsx +0 -42
- package/app/api/auth/2fa/route.tsx +0 -148
- package/app/api/auth/[...nextauth]/route.tsx +0 -3
- package/app/api/auth/change-password/route.tsx +0 -61
- package/app/api/auth/check-2fa/route.tsx +0 -19
- package/app/api/auth/forgot-password/route.tsx +0 -65
- package/app/api/auth/reset-password/route.tsx +0 -52
- package/app/api/auth/verify-2fa/route.tsx +0 -88
- package/app/api/backup/download/db/route.ts +0 -29
- package/app/api/backup/download/notes/route.ts +0 -25
- package/app/api/backup/settings/route.ts +0 -92
- package/app/api/billing/checkout/route.tsx +0 -81
- package/app/api/billing/migrate/route.tsx +0 -163
- package/app/api/billing/portal/route.tsx +0 -24
- package/app/api/billing/setup-intent/route.tsx +0 -55
- package/app/api/billing/status/route.tsx +0 -36
- package/app/api/billing/subscribe/route.tsx +0 -85
- package/app/api/billing/webhook/route.tsx +0 -199
- package/app/api/calendar-feeds/[feedId]/route.tsx +0 -67
- package/app/api/calendar-feeds/[feedId]/sync/route.tsx +0 -37
- package/app/api/calendar-feeds/events/route.tsx +0 -82
- package/app/api/calendar-feeds/route.tsx +0 -52
- package/app/api/calendar-feeds/sync-all/route.tsx +0 -34
- package/app/api/cron/calendar-feeds/route.tsx +0 -31
- package/app/api/cron/stale-tasks/route.tsx +0 -51
- package/app/api/cron/sync/route.tsx +0 -34
- package/app/api/devices/[deviceId]/route.tsx +0 -25
- package/app/api/devices/route.tsx +0 -41
- package/app/api/export/route.tsx +0 -40
- package/app/api/feedback/route.tsx +0 -54
- package/app/api/folders/[folderId]/route.tsx +0 -51
- package/app/api/folders/route.tsx +0 -37
- package/app/api/graph/route.tsx +0 -242
- package/app/api/guest/route.tsx +0 -58
- package/app/api/health/route.tsx +0 -10
- package/app/api/holidays/countries/route.tsx +0 -14
- package/app/api/holidays/route.tsx +0 -49
- package/app/api/holidays/states/route.tsx +0 -21
- package/app/api/invites/[token]/route.tsx +0 -131
- package/app/api/invites/route.tsx +0 -74
- package/app/api/mcp/generate-token/route.tsx +0 -55
- package/app/api/mcp/revoke-token/[tokenId]/route.tsx +0 -30
- package/app/api/mcp/update-alias/[tokenId]/route.tsx +0 -22
- package/app/api/notes/[noteId]/export/route.tsx +0 -45
- package/app/api/notes/[noteId]/route.tsx +0 -360
- package/app/api/notes/route.tsx +0 -112
- package/app/api/notifications/route.tsx +0 -44
- package/app/api/register/route.tsx +0 -67
- package/app/api/restore/route.tsx +0 -148
- package/app/api/sync/conflicts/[conflictId]/route.tsx +0 -134
- package/app/api/sync/conflicts/route.tsx +0 -48
- package/app/api/sync/status/route.tsx +0 -49
- package/app/api/sync/trigger/route.tsx +0 -15
- package/app/api/tasks/[taskId]/detail/route.tsx +0 -68
- package/app/api/tasks/[taskId]/route.tsx +0 -259
- package/app/api/tasks/bulk/route.tsx +0 -133
- package/app/api/tasks/route.tsx +0 -36
- package/app/api/workspace/active/route.tsx +0 -39
- package/app/api/workspace/create-team/route.tsx +0 -42
- package/app/api/workspace/kanban-statuses/route.tsx +0 -71
- package/app/api/workspace/members/[memberId]/route.tsx +0 -69
- package/app/api/workspace/route.tsx +0 -24
- package/app/download/page.tsx +0 -170
- package/app/favicon.ico +0 -0
- package/app/generated/prisma/client.d.ts +0 -1
- package/app/generated/prisma/client.js +0 -5
- package/app/generated/prisma/default.d.ts +0 -1
- package/app/generated/prisma/default.js +0 -5
- package/app/generated/prisma/edge.d.ts +0 -1
- package/app/generated/prisma/edge.js +0 -497
- package/app/generated/prisma/index-browser.js +0 -523
- package/app/generated/prisma/index.d.ts +0 -46376
- package/app/generated/prisma/index.js +0 -497
- package/app/generated/prisma/package.json +0 -144
- package/app/generated/prisma/query_compiler_fast_bg.js +0 -2
- package/app/generated/prisma/query_compiler_fast_bg.wasm +0 -0
- package/app/generated/prisma/query_compiler_fast_bg.wasm-base64.js +0 -2
- package/app/generated/prisma/runtime/client.d.ts +0 -3386
- package/app/generated/prisma/runtime/client.js +0 -86
- package/app/generated/prisma/runtime/index-browser.d.ts +0 -90
- package/app/generated/prisma/runtime/index-browser.js +0 -6
- package/app/generated/prisma/runtime/wasm-compiler-edge.js +0 -76
- package/app/generated/prisma/schema.prisma +0 -456
- package/app/generated/prisma/wasm-edge-light-loader.mjs +0 -5
- package/app/generated/prisma/wasm-worker-loader.mjs +0 -5
- package/app/globals.css +0 -54
- package/app/invite/[token]/page.tsx +0 -52
- package/app/layout.tsx +0 -90
- package/app/mcp/route.tsx +0 -430
- package/app/opengraph-image.tsx +0 -120
- package/app/page.tsx +0 -398
- package/app/privacy/page.tsx +0 -69
- package/app/robots.tsx +0 -25
- package/app/sitemap.tsx +0 -36
- package/app/terms/page.tsx +0 -69
- package/app/upgrade/page.tsx +0 -75
- package/auth.config.ts +0 -33
- package/auth.ts +0 -79
- package/components/auth/login-form.tsx +0 -302
- package/components/auth/password-checklist.tsx +0 -31
- package/components/auth/password-input.tsx +0 -36
- package/components/auth/switch-account-button.test.tsx +0 -22
- package/components/auth/switch-account-button.tsx +0 -19
- package/components/auth/two-factor-input.tsx +0 -116
- package/components/billing/billing-dashboard.tsx +0 -265
- package/components/billing/card-form.tsx +0 -210
- package/components/billing/claim-account-form.tsx +0 -99
- package/components/branding/app-logo.test.tsx +0 -20
- package/components/branding/app-logo.tsx +0 -25
- package/components/calendar/calendar-agenda.tsx +0 -150
- package/components/calendar/calendar-drag.test.tsx +0 -177
- package/components/calendar/calendar-grid.tsx +0 -357
- package/components/calendar/calendar-hooks.test.tsx +0 -27
- package/components/calendar/calendar-hooks.ts +0 -351
- package/components/calendar/calendar-toolbar.test.tsx +0 -68
- package/components/calendar/calendar-toolbar.tsx +0 -291
- package/components/calendar/calendar-types.ts +0 -148
- package/components/calendar/calendar-view.test.tsx +0 -295
- package/components/calendar/calendar-view.tsx +0 -307
- package/components/calendar/day-detail-popover.tsx +0 -174
- package/components/calendar/task-chip.tsx +0 -86
- package/components/command/command-palette.test.tsx +0 -33
- package/components/command/command-palette.tsx +0 -310
- package/components/download-cta.tsx +0 -87
- package/components/feedback/feedback-popup.tsx +0 -207
- package/components/graph/graph-draw.ts +0 -337
- package/components/graph/graph-overlays.tsx +0 -160
- package/components/graph/graph-page.test.tsx +0 -131
- package/components/graph/graph-page.tsx +0 -263
- package/components/graph/graph-types.ts +0 -47
- package/components/graph/graph-view.tsx +0 -322
- package/components/guide/guide-view.tsx +0 -522
- package/components/kanban/kanban-board.test.tsx +0 -128
- package/components/kanban/kanban-board.tsx +0 -361
- package/components/kanban/kanban-card-menu.tsx +0 -102
- package/components/kanban/kanban-card.tsx +0 -227
- package/components/kanban/kanban-column.tsx +0 -49
- package/components/kanban/kanban-status-context.tsx +0 -28
- package/components/landing/calendar-sandbox.test.tsx +0 -15
- package/components/landing/calendar-sandbox.tsx +0 -107
- package/components/landing/graph-sandbox.test.tsx +0 -27
- package/components/landing/graph-sandbox.tsx +0 -80
- package/components/landing/kanban-sandbox.test.tsx +0 -24
- package/components/landing/kanban-sandbox.tsx +0 -101
- package/components/landing/landing-showcase.test.tsx +0 -21
- package/components/landing/landing-showcase.tsx +0 -54
- package/components/landing/list-sandbox.tsx +0 -86
- package/components/landing/mock-workspace.ts +0 -168
- package/components/landing/notes-sandbox.test.tsx +0 -14
- package/components/landing/notes-sandbox.tsx +0 -88
- package/components/layout/app-shell.tsx +0 -83
- package/components/layout/backup-scheduler.tsx +0 -122
- package/components/layout/bottom-nav.tsx +0 -43
- package/components/layout/icon-bar.test.tsx +0 -29
- package/components/layout/icon-bar.tsx +0 -118
- package/components/layout/mobile-top-bar.tsx +0 -68
- package/components/layout/notes-panel-folder.tsx +0 -127
- package/components/layout/notes-panel-note-item.tsx +0 -140
- package/components/layout/notes-panel-task-tab.tsx +0 -63
- package/components/layout/notes-panel-types.ts +0 -44
- package/components/layout/notes-panel.tsx +0 -476
- package/components/layout/notification-bell.tsx +0 -251
- package/components/layout/paywall-screen.tsx +0 -41
- package/components/layout/pro-banner.tsx +0 -76
- package/components/layout/sw-register.tsx +0 -27
- package/components/layout/workspace-switcher.tsx +0 -90
- package/components/notes/mobile-bottom-sheet.tsx +0 -99
- package/components/notes/note-editor-context-menu.tsx +0 -47
- package/components/notes/note-editor-dom.ts +0 -33
- package/components/notes/note-editor-dropdowns.tsx +0 -484
- package/components/notes/note-editor-hooks.ts +0 -692
- package/components/notes/note-editor-keyboard.ts +0 -305
- package/components/notes/note-editor-overlay.tsx +0 -90
- package/components/notes/note-editor.test.tsx +0 -372
- package/components/notes/note-editor.tsx +0 -662
- package/components/notes/note-preview-pane.tsx +0 -156
- package/components/notes/note-tabs.tsx +0 -120
- package/components/notes/note-types.tsx +0 -157
- package/components/settings/accept-invite.tsx +0 -108
- package/components/settings/agent-token-settings.tsx +0 -369
- package/components/settings/backup-restore-settings.test.tsx +0 -25
- package/components/settings/backup-restore-settings.tsx +0 -327
- package/components/settings/calendar-feeds-settings.tsx +0 -489
- package/components/settings/calendar-general-settings.tsx +0 -174
- package/components/settings/confirm-danger-action.test.tsx +0 -215
- package/components/settings/confirm-danger-action.tsx +0 -65
- package/components/settings/security-settings.tsx +0 -252
- package/components/settings/settings-guidance.test.tsx +0 -98
- package/components/settings/team-settings.tsx +0 -319
- package/components/settings/two-factor-auth.tsx +0 -296
- package/components/settings/workspace-settings-client.tsx +0 -363
- package/components/settings/workspace-settings-form.tsx +0 -73
- package/components/sync/conflict-viewer.tsx +0 -247
- package/components/sync/sync-indicator.tsx +0 -171
- package/components/tasks/snippet-thread.tsx +0 -119
- package/components/tasks/status-dot.tsx +0 -47
- package/components/tasks/task-badge.tsx +0 -43
- package/components/tasks/task-detail.test.tsx +0 -187
- package/components/tasks/task-detail.tsx +0 -458
- package/components/tasks/task-list-filters.test.tsx +0 -75
- package/components/tasks/task-list-filters.tsx +0 -163
- package/components/tasks/task-list-types.ts +0 -20
- package/components/tasks/task-list.test.tsx +0 -175
- package/components/tasks/task-list.tsx +0 -481
- package/components/tasks/task-row.tsx +0 -85
- package/components/tasks/task-table-row.tsx +0 -259
- package/components/ui/skeleton.tsx +0 -3
- package/components/ui/toast.test.tsx +0 -42
- package/components/ui/toast.tsx +0 -70
- package/electron/main.ts +0 -251
- package/electron/preload.ts +0 -56
- package/instrumentation.tsx +0 -23
- package/lib/api-error.ts +0 -50
- package/lib/backup/backup-runner.test.ts +0 -32
- package/lib/backup/backup-runner.ts +0 -19
- package/lib/backup/backup-schedule.test.ts +0 -23
- package/lib/backup/backup-schedule.ts +0 -55
- package/lib/backup/backup-settings.test.ts +0 -30
- package/lib/backup/backup-settings.ts +0 -27
- package/lib/backup/export-notes-zip.test.ts +0 -26
- package/lib/backup/export-notes-zip.ts +0 -82
- package/lib/backup/export-workspace-backup.test.ts +0 -17
- package/lib/backup/export-workspace-backup.ts +0 -77
- package/lib/backup/restore-workspace-from-export.test.ts +0 -18
- package/lib/backup/restore-workspace-from-export.ts +0 -183
- package/lib/backup/types.ts +0 -14
- package/lib/brand-icons.ts +0 -1
- package/lib/calendar-feed-crypto.ts +0 -38
- package/lib/calendar-feed.ts +0 -239
- package/lib/client/online-status.ts +0 -47
- package/lib/conflict-resolver.test.ts +0 -57
- package/lib/conflict-resolver.ts +0 -240
- package/lib/db-init.ts +0 -79
- package/lib/email.ts +0 -159
- package/lib/encryption.test.ts +0 -41
- package/lib/encryption.ts +0 -98
- package/lib/extract-snippet.test.ts +0 -123
- package/lib/extract-snippet.ts +0 -69
- package/lib/kanban-status.ts +0 -55
- package/lib/license.ts +0 -21
- package/lib/limits.ts +0 -31
- package/lib/mcp-auth.test.ts +0 -58
- package/lib/mcp-auth.ts +0 -65
- package/lib/mcp-contract.test.ts +0 -25
- package/lib/mcp-contract.ts +0 -210
- package/lib/mcp-handler.ts +0 -31
- package/lib/mcp-url.test.ts +0 -12
- package/lib/mcp-url.ts +0 -7
- package/lib/mentions.test.ts +0 -45
- package/lib/mentions.ts +0 -73
- package/lib/note-crypto.ts +0 -108
- package/lib/note-sync.ts +0 -201
- package/lib/note-title.ts +0 -93
- package/lib/prisma.ts +0 -193
- package/lib/pro-flush.ts +0 -292
- package/lib/rate-limit.ts +0 -57
- package/lib/stripe.ts +0 -38
- package/lib/sync-worker.ts +0 -388
- package/lib/task-parser.test.ts +0 -91
- package/lib/task-parser.ts +0 -81
- package/lib/task-utils.ts +0 -52
- package/lib/use-is-electron.ts +0 -19
- package/lib/use-is-mobile.ts +0 -22
- package/lib/validation/calendar-feed.ts +0 -31
- package/lib/validation/note.ts +0 -27
- package/lib/validation/task.ts +0 -26
- package/lib/view-preferences.test.ts +0 -54
- package/lib/view-preferences.ts +0 -28
- package/lib/workspace.ts +0 -66
- package/next.config.ts +0 -21
- package/postcss.config.mjs +0 -7
- package/prisma/migrations/20260519021916_init/migration.sql +0 -388
- package/prisma/migrations/20260519061113_drop_sync_password/migration.sql +0 -8
- package/prisma/migrations/20260520065016_add_task_start_date/migration.sql +0 -2
- package/prisma/migrations/20260529010600_remove_encryption_fields/migration.sql +0 -12
- package/prisma/migrations/20260529020000_restore_encryption_salt/migration.sql +0 -3
- package/prisma/migrations/20260529030000_add_folders/migration.sql +0 -17
- package/prisma/migrations/20260605000000_deferred_fixes/migration.sql +0 -31
- package/prisma/migrations/20260605020806_add_pending_sync_to_note_and_task/migration.sql +0 -5
- package/prisma/migrations/20260605063634_add_stripe_webhook_event_sync_lock/migration.sql +0 -14
- package/prisma/migrations/20260605100000_add_prod_indexes/migration.sql +0 -26
- package/prisma/migrations/20260608081404_add_kanban_statuses/migration.sql +0 -23
- package/prisma/migrations/20260611032723_add_calendar_feeds/migration.sql +0 -43
- package/prisma/migrations/20260611040000_add_calendar_feed_color/migration.sql +0 -2
- package/prisma/migrations/20260611050000_add_task_priority/migration.sql +0 -14
- package/prisma/migrations/20260612060000_add_critical_priority/migration.sql +0 -2
- package/prisma/migrations/20260613090000_add_backup_settings/migration.sql +0 -25
- package/prisma/migrations/20260614160000_add_feedback/migration.sql +0 -20
- package/prisma/migrations/20260614210000_add_2fa/migration.sql +0 -4
- package/prisma/migrations/migration_lock.toml +0 -3
- package/prisma/schema.prisma +0 -457
- package/public/Logo_icon.svg +0 -1
- package/public/file.svg +0 -1
- package/public/globe.svg +0 -1
- package/public/icon-192.png +0 -0
- package/public/icon-512.png +0 -0
- package/public/icon.svg +0 -4
- package/public/icon_dark.svg +0 -1
- package/public/knotpad_icon.svg +0 -1
- package/public/knotpad_logo_full.svg +0 -1
- package/public/manifest.json +0 -14
- package/public/next.svg +0 -1
- package/public/sw.js +0 -137
- package/public/vercel.svg +0 -1
- package/public/window.svg +0 -1
- package/tsconfig.json +0 -35
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react";
|
|
3
|
-
import userEvent from "@testing-library/user-event";
|
|
4
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
5
|
-
import { AgentTokenSettings } from "@/components/settings/agent-token-settings";
|
|
6
|
-
import { BackupRestoreSettings } from "@/components/settings/backup-restore-settings";
|
|
7
|
-
import { ConfirmDangerAction } from "@/components/settings/confirm-danger-action";
|
|
8
|
-
|
|
9
|
-
const { refreshMock } = vi.hoisted(() => ({
|
|
10
|
-
refreshMock: vi.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
vi.mock("next/navigation", () => ({
|
|
14
|
-
useRouter: () => ({ refresh: refreshMock }),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
describe("ConfirmDangerAction", () => {
|
|
18
|
-
beforeEach(() => {
|
|
19
|
-
vi.stubGlobal("fetch", vi.fn());
|
|
20
|
-
refreshMock.mockReset();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
afterEach(() => {
|
|
24
|
-
cleanup();
|
|
25
|
-
vi.unstubAllGlobals();
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it("requires explicit confirmation before calling onConfirm", async () => {
|
|
29
|
-
const user = userEvent.setup();
|
|
30
|
-
const onConfirm = vi.fn();
|
|
31
|
-
|
|
32
|
-
render(
|
|
33
|
-
<ConfirmDangerAction
|
|
34
|
-
open
|
|
35
|
-
title="Delete"
|
|
36
|
-
body="Irreversible."
|
|
37
|
-
onConfirm={onConfirm}
|
|
38
|
-
onClose={vi.fn()}
|
|
39
|
-
/>
|
|
40
|
-
);
|
|
41
|
-
|
|
42
|
-
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
|
43
|
-
|
|
44
|
-
expect(onConfirm).toHaveBeenCalledTimes(1);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it("confirms before regenerating an existing token", async () => {
|
|
48
|
-
const user = userEvent.setup();
|
|
49
|
-
const fetchMock = vi.mocked(fetch);
|
|
50
|
-
fetchMock.mockResolvedValue({
|
|
51
|
-
ok: true,
|
|
52
|
-
json: async () => ({ token: "mcp_tok_new", id: "tok-2", alias: null }),
|
|
53
|
-
} as Response);
|
|
54
|
-
|
|
55
|
-
render(
|
|
56
|
-
<AgentTokenSettings
|
|
57
|
-
workspaces={[
|
|
58
|
-
{
|
|
59
|
-
id: "ws-1",
|
|
60
|
-
name: "Workspace One",
|
|
61
|
-
slug: "workspace-one",
|
|
62
|
-
existingToken: { id: "tok-1", alias: "Existing token", lastUsed: null },
|
|
63
|
-
},
|
|
64
|
-
]}
|
|
65
|
-
mcpUrl="https://example.com/mcp"
|
|
66
|
-
appUrl="https://example.com"
|
|
67
|
-
userId="user-1"
|
|
68
|
-
/>
|
|
69
|
-
);
|
|
70
|
-
|
|
71
|
-
await user.click(screen.getByRole("button", { name: "Regenerate" }));
|
|
72
|
-
|
|
73
|
-
expect(fetchMock).not.toHaveBeenCalled();
|
|
74
|
-
expect(screen.getByText("Regenerate token")).toBeInTheDocument();
|
|
75
|
-
|
|
76
|
-
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
|
77
|
-
|
|
78
|
-
await waitFor(() =>
|
|
79
|
-
expect(fetchMock).toHaveBeenCalledWith("/api/mcp/generate-token", {
|
|
80
|
-
method: "POST",
|
|
81
|
-
headers: { "Content-Type": "application/json" },
|
|
82
|
-
body: JSON.stringify({ workspaceId: "ws-1" }),
|
|
83
|
-
})
|
|
84
|
-
);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("confirms before revoking a token", async () => {
|
|
88
|
-
const user = userEvent.setup();
|
|
89
|
-
const fetchMock = vi.mocked(fetch);
|
|
90
|
-
fetchMock.mockResolvedValue({
|
|
91
|
-
ok: true,
|
|
92
|
-
json: async () => ({}),
|
|
93
|
-
} as Response);
|
|
94
|
-
|
|
95
|
-
render(
|
|
96
|
-
<AgentTokenSettings
|
|
97
|
-
workspaces={[
|
|
98
|
-
{
|
|
99
|
-
id: "ws-1",
|
|
100
|
-
name: "Workspace One",
|
|
101
|
-
slug: "workspace-one",
|
|
102
|
-
existingToken: { id: "tok-1", alias: "Existing token", lastUsed: null },
|
|
103
|
-
},
|
|
104
|
-
]}
|
|
105
|
-
mcpUrl="https://example.com/mcp"
|
|
106
|
-
appUrl="https://example.com"
|
|
107
|
-
userId="user-1"
|
|
108
|
-
/>
|
|
109
|
-
);
|
|
110
|
-
|
|
111
|
-
await user.click(screen.getByRole("button", { name: "Revoke" }));
|
|
112
|
-
|
|
113
|
-
expect(fetchMock).not.toHaveBeenCalled();
|
|
114
|
-
expect(screen.getByText("Revoke token")).toBeInTheDocument();
|
|
115
|
-
|
|
116
|
-
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
|
117
|
-
|
|
118
|
-
await waitFor(() =>
|
|
119
|
-
expect(fetchMock).toHaveBeenCalledWith("/api/mcp/revoke-token/tok-1", {
|
|
120
|
-
method: "DELETE",
|
|
121
|
-
})
|
|
122
|
-
);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it("shows reusable setup guidance for an existing token without revealing the secret", () => {
|
|
126
|
-
render(
|
|
127
|
-
<AgentTokenSettings
|
|
128
|
-
workspaces={[
|
|
129
|
-
{
|
|
130
|
-
id: "ws-1",
|
|
131
|
-
name: "Workspace One",
|
|
132
|
-
slug: "workspace-one",
|
|
133
|
-
existingToken: { id: "tok-1", alias: "Laptop", lastUsed: null },
|
|
134
|
-
},
|
|
135
|
-
]}
|
|
136
|
-
mcpUrl="https://example.com/mcp"
|
|
137
|
-
appUrl="https://example.com"
|
|
138
|
-
userId="user-1"
|
|
139
|
-
/>
|
|
140
|
-
);
|
|
141
|
-
|
|
142
|
-
expect(screen.getByText("Quick Setup")).toBeInTheDocument();
|
|
143
|
-
expect(screen.getAllByText(/<your-existing-token>/)).toHaveLength(2);
|
|
144
|
-
expect(screen.queryByText(/won't be shown again/i)).not.toBeInTheDocument();
|
|
145
|
-
});
|
|
146
|
-
|
|
147
|
-
it("copies the reusable MCP config template for an existing token", async () => {
|
|
148
|
-
const user = userEvent.setup();
|
|
149
|
-
const writeText = vi.fn();
|
|
150
|
-
Object.assign(navigator, {
|
|
151
|
-
clipboard: {
|
|
152
|
-
writeText,
|
|
153
|
-
},
|
|
154
|
-
});
|
|
155
|
-
|
|
156
|
-
render(
|
|
157
|
-
<AgentTokenSettings
|
|
158
|
-
workspaces={[
|
|
159
|
-
{
|
|
160
|
-
id: "ws-1",
|
|
161
|
-
name: "Workspace One",
|
|
162
|
-
slug: "workspace-one",
|
|
163
|
-
existingToken: { id: "tok-1", alias: "Laptop", lastUsed: null },
|
|
164
|
-
},
|
|
165
|
-
]}
|
|
166
|
-
mcpUrl="https://example.com/mcp"
|
|
167
|
-
appUrl="https://example.com"
|
|
168
|
-
userId="user-1"
|
|
169
|
-
/>
|
|
170
|
-
);
|
|
171
|
-
|
|
172
|
-
await user.click(screen.getByRole("button", { name: "Copy MCP config" }));
|
|
173
|
-
|
|
174
|
-
expect(writeText).toHaveBeenCalledWith(
|
|
175
|
-
expect.stringContaining('"Authorization": "Bearer <your-existing-token>"')
|
|
176
|
-
);
|
|
177
|
-
});
|
|
178
|
-
|
|
179
|
-
it("waits for confirmation before restoring a selected backup", async () => {
|
|
180
|
-
const user = userEvent.setup();
|
|
181
|
-
const fetchMock = vi.mocked(fetch);
|
|
182
|
-
fetchMock.mockResolvedValue({
|
|
183
|
-
ok: true,
|
|
184
|
-
json: async () => ({ notesRestored: 2, tasksRestored: 1 }),
|
|
185
|
-
} as Response);
|
|
186
|
-
|
|
187
|
-
const { container } = render(
|
|
188
|
-
<BackupRestoreSettings
|
|
189
|
-
isCloudWorkspace
|
|
190
|
-
isOwner
|
|
191
|
-
initialSettings={null}
|
|
192
|
-
/>
|
|
193
|
-
);
|
|
194
|
-
|
|
195
|
-
const fileInput = container.querySelector('input[type="file"]') as HTMLInputElement;
|
|
196
|
-
const file = new File([JSON.stringify({ version: 1 })], "backup.json", {
|
|
197
|
-
type: "application/json",
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
fireEvent.change(fileInput, { target: { files: [file] } });
|
|
201
|
-
|
|
202
|
-
expect(fetchMock).not.toHaveBeenCalled();
|
|
203
|
-
expect(screen.getByText("Restore backup")).toBeInTheDocument();
|
|
204
|
-
|
|
205
|
-
await user.click(screen.getByRole("button", { name: "Confirm" }));
|
|
206
|
-
|
|
207
|
-
await waitFor(() =>
|
|
208
|
-
expect(fetchMock).toHaveBeenCalledWith("/api/restore", {
|
|
209
|
-
method: "POST",
|
|
210
|
-
headers: { "Content-Type": "application/json" },
|
|
211
|
-
body: JSON.stringify({ type: "file-replace", data: { version: 1 } }),
|
|
212
|
-
})
|
|
213
|
-
);
|
|
214
|
-
});
|
|
215
|
-
});
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
type ConfirmDangerActionProps = {
|
|
4
|
-
open: boolean;
|
|
5
|
-
title: string;
|
|
6
|
-
body: string;
|
|
7
|
-
confirmLabel?: string;
|
|
8
|
-
cancelLabel?: string;
|
|
9
|
-
busy?: boolean;
|
|
10
|
-
onConfirm: () => void | Promise<void>;
|
|
11
|
-
onClose: () => void;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
export function ConfirmDangerAction({
|
|
15
|
-
open,
|
|
16
|
-
title,
|
|
17
|
-
body,
|
|
18
|
-
confirmLabel = "Confirm",
|
|
19
|
-
cancelLabel = "Cancel",
|
|
20
|
-
busy = false,
|
|
21
|
-
onConfirm,
|
|
22
|
-
onClose,
|
|
23
|
-
}: ConfirmDangerActionProps) {
|
|
24
|
-
if (!open) return null;
|
|
25
|
-
|
|
26
|
-
return (
|
|
27
|
-
<div className="fixed inset-0 z-50 flex items-center justify-center bg-black/60 p-4">
|
|
28
|
-
<div
|
|
29
|
-
role="dialog"
|
|
30
|
-
aria-modal="true"
|
|
31
|
-
aria-labelledby="confirm-danger-action-title"
|
|
32
|
-
aria-describedby="confirm-danger-action-body"
|
|
33
|
-
className="w-full max-w-md rounded-xl border border-red-900/40 bg-zinc-950 p-4 shadow-2xl"
|
|
34
|
-
>
|
|
35
|
-
<h3 id="confirm-danger-action-title" className="text-sm font-medium text-red-200">
|
|
36
|
-
{title}
|
|
37
|
-
</h3>
|
|
38
|
-
<p
|
|
39
|
-
id="confirm-danger-action-body"
|
|
40
|
-
className="mt-2 whitespace-pre-line text-sm text-zinc-400"
|
|
41
|
-
>
|
|
42
|
-
{body}
|
|
43
|
-
</p>
|
|
44
|
-
<div className="mt-4 flex justify-end gap-2">
|
|
45
|
-
<button
|
|
46
|
-
type="button"
|
|
47
|
-
onClick={onClose}
|
|
48
|
-
disabled={busy}
|
|
49
|
-
className="rounded-md border border-zinc-800 px-3 py-1.5 text-xs text-zinc-300 transition-colors hover:bg-zinc-900 disabled:opacity-50"
|
|
50
|
-
>
|
|
51
|
-
{cancelLabel}
|
|
52
|
-
</button>
|
|
53
|
-
<button
|
|
54
|
-
type="button"
|
|
55
|
-
onClick={() => void onConfirm()}
|
|
56
|
-
disabled={busy}
|
|
57
|
-
className="rounded-md bg-red-900/70 px-3 py-1.5 text-xs text-red-100 transition-colors hover:bg-red-900 disabled:opacity-50"
|
|
58
|
-
>
|
|
59
|
-
{confirmLabel}
|
|
60
|
-
</button>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</div>
|
|
64
|
-
);
|
|
65
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { useState } from "react"
|
|
4
|
-
import { TwoFactorAuth } from "@/components/settings/two-factor-auth";
|
|
5
|
-
import { useRouter } from "next/navigation";
|
|
6
|
-
import { Laptop, Trash2, CloudDownload, Loader2, KeyRound } from "lucide-react";
|
|
7
|
-
import { PasswordInput } from "@/components/auth/password-input";
|
|
8
|
-
import { PasswordChecklist } from "@/components/auth/password-checklist";
|
|
9
|
-
import { ConfirmDangerAction } from "@/components/settings/confirm-danger-action";
|
|
10
|
-
|
|
11
|
-
type Device = { id: string; deviceName: string; deviceId: string; lastActive: string };
|
|
12
|
-
|
|
13
|
-
type Props = {
|
|
14
|
-
isPro: boolean;
|
|
15
|
-
isOwner: boolean;
|
|
16
|
-
devices: Device[];
|
|
17
|
-
hasPassword: boolean;
|
|
18
|
-
twoFactorEnabled?: boolean;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export function SecuritySettings({ isPro, isOwner, devices, hasPassword, twoFactorEnabled }: Props) {
|
|
22
|
-
const router = useRouter();
|
|
23
|
-
const [revoking, setRevoking] = useState<string | null>(null);
|
|
24
|
-
const [restoring, setRestoring] = useState(false);
|
|
25
|
-
const [restoreMsg, setRestoreMsg] = useState<{ type: "ok" | "err"; text: string } | null>(null);
|
|
26
|
-
const [restoreConfirm, setRestoreConfirm] = useState(false);
|
|
27
|
-
|
|
28
|
-
const [currentPw, setCurrentPw] = useState("");
|
|
29
|
-
const [newPw, setNewPw] = useState("");
|
|
30
|
-
const [confirmPw, setConfirmPw] = useState("");
|
|
31
|
-
const [changingPw, setChangingPw] = useState(false);
|
|
32
|
-
const [pwMsg, setPwMsg] = useState<{ type: "ok" | "err"; text: string } | null>(null);
|
|
33
|
-
|
|
34
|
-
async function handleChangePassword(e: React.FormEvent) {
|
|
35
|
-
e.preventDefault();
|
|
36
|
-
setPwMsg(null);
|
|
37
|
-
|
|
38
|
-
if (newPw !== confirmPw) {
|
|
39
|
-
setPwMsg({ type: "err", text: "New passwords do not match." });
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
if (newPw.length < 8) {
|
|
43
|
-
setPwMsg({ type: "err", text: "New password must be at least 8 characters." });
|
|
44
|
-
return;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
setChangingPw(true);
|
|
48
|
-
try {
|
|
49
|
-
const res = await fetch("/api/auth/change-password", {
|
|
50
|
-
method: "POST",
|
|
51
|
-
headers: { "Content-Type": "application/json" },
|
|
52
|
-
body: JSON.stringify({ currentPassword: currentPw, newPassword: newPw }),
|
|
53
|
-
});
|
|
54
|
-
const data = await res.json();
|
|
55
|
-
if (res.ok) {
|
|
56
|
-
setPwMsg({ type: "ok", text: "Password updated successfully." });
|
|
57
|
-
setCurrentPw("");
|
|
58
|
-
setNewPw("");
|
|
59
|
-
setConfirmPw("");
|
|
60
|
-
} else {
|
|
61
|
-
setPwMsg({ type: "err", text: data.error ?? "Failed to update password." });
|
|
62
|
-
}
|
|
63
|
-
} finally {
|
|
64
|
-
setChangingPw(false);
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
async function handleCloudRestore() {
|
|
69
|
-
setRestoreConfirm(true);
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
async function confirmCloudRestore() {
|
|
73
|
-
setRestoring(true);
|
|
74
|
-
setRestoreMsg(null);
|
|
75
|
-
try {
|
|
76
|
-
const res = await fetch("/api/restore", {
|
|
77
|
-
method: "POST",
|
|
78
|
-
headers: { "Content-Type": "application/json" },
|
|
79
|
-
body: JSON.stringify({ type: "cloud" }),
|
|
80
|
-
});
|
|
81
|
-
const data = await res.json();
|
|
82
|
-
if (res.ok) {
|
|
83
|
-
setRestoreMsg({ type: "ok", text: `Cloud restore complete. ${data.notesProcessed ?? 0} notes synced.` });
|
|
84
|
-
router.refresh();
|
|
85
|
-
} else {
|
|
86
|
-
setRestoreMsg({ type: "err", text: data.error ?? "Cloud restore failed." });
|
|
87
|
-
}
|
|
88
|
-
} finally {
|
|
89
|
-
setRestoring(false);
|
|
90
|
-
setRestoreConfirm(false);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
async function revokeDevice(deviceId: string) {
|
|
95
|
-
setRevoking(deviceId);
|
|
96
|
-
await fetch(`/api/devices/${deviceId}`, { method: "DELETE" });
|
|
97
|
-
router.refresh();
|
|
98
|
-
setRevoking(null);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<div className="space-y-8">
|
|
103
|
-
{/* Device sessions */}
|
|
104
|
-
<div className="space-y-3">
|
|
105
|
-
<h3 className="text-sm font-semibold text-zinc-300">Connected devices</h3>
|
|
106
|
-
{devices.length === 0 ? (
|
|
107
|
-
<p className="text-xs text-zinc-600">No active device sessions.</p>
|
|
108
|
-
) : (
|
|
109
|
-
<div className="space-y-1 rounded-lg border border-zinc-800 overflow-hidden">
|
|
110
|
-
{devices.map((d) => (
|
|
111
|
-
<div
|
|
112
|
-
key={d.id}
|
|
113
|
-
className="flex items-center justify-between px-4 py-3 bg-zinc-900 border-b border-zinc-800 last:border-0"
|
|
114
|
-
>
|
|
115
|
-
<div className="flex items-center gap-2 min-w-0">
|
|
116
|
-
<Laptop size={14} className="shrink-0 text-zinc-500" />
|
|
117
|
-
<div className="min-w-0">
|
|
118
|
-
<p className="text-sm text-zinc-300 truncate">{d.deviceName}</p>
|
|
119
|
-
<p className="text-xs text-zinc-600">
|
|
120
|
-
Last active {new Date(d.lastActive).toLocaleDateString()}
|
|
121
|
-
</p>
|
|
122
|
-
</div>
|
|
123
|
-
</div>
|
|
124
|
-
<button
|
|
125
|
-
onClick={() => revokeDevice(d.id)}
|
|
126
|
-
disabled={revoking === d.id}
|
|
127
|
-
className="shrink-0 text-zinc-600 hover:text-red-400 transition-colors disabled:opacity-50"
|
|
128
|
-
title="Revoke device"
|
|
129
|
-
>
|
|
130
|
-
<Trash2 size={13} />
|
|
131
|
-
</button>
|
|
132
|
-
</div>
|
|
133
|
-
))}
|
|
134
|
-
</div>
|
|
135
|
-
)}
|
|
136
|
-
<p className="text-xs text-zinc-700">
|
|
137
|
-
Revoking a device removes its session. It will need to log in again to reconnect.
|
|
138
|
-
</p>
|
|
139
|
-
</div>
|
|
140
|
-
|
|
141
|
-
{/* Change password */}
|
|
142
|
-
{hasPassword && (
|
|
143
|
-
<div className="space-y-3">
|
|
144
|
-
<h3 className="text-sm font-semibold text-zinc-300">Change password</h3>
|
|
145
|
-
<form onSubmit={handleChangePassword} className="space-y-3">
|
|
146
|
-
<div className="space-y-1.5">
|
|
147
|
-
<label className="text-xs text-zinc-400">Current password</label>
|
|
148
|
-
<PasswordInput
|
|
149
|
-
value={currentPw}
|
|
150
|
-
onChange={(e) => setCurrentPw(e.target.value)}
|
|
151
|
-
placeholder="Enter current password"
|
|
152
|
-
required
|
|
153
|
-
/>
|
|
154
|
-
</div>
|
|
155
|
-
<div className="space-y-1.5">
|
|
156
|
-
<label className="text-xs text-zinc-400">New password</label>
|
|
157
|
-
<PasswordInput
|
|
158
|
-
value={newPw}
|
|
159
|
-
onChange={(e) => setNewPw(e.target.value)}
|
|
160
|
-
placeholder="Enter new password"
|
|
161
|
-
required
|
|
162
|
-
/>
|
|
163
|
-
<PasswordChecklist password={newPw} />
|
|
164
|
-
</div>
|
|
165
|
-
<div className="space-y-1.5">
|
|
166
|
-
<label className="text-xs text-zinc-400">Confirm new password</label>
|
|
167
|
-
<PasswordInput
|
|
168
|
-
value={confirmPw}
|
|
169
|
-
onChange={(e) => setConfirmPw(e.target.value)}
|
|
170
|
-
placeholder="Re-enter new password"
|
|
171
|
-
required
|
|
172
|
-
/>
|
|
173
|
-
</div>
|
|
174
|
-
<button
|
|
175
|
-
type="submit"
|
|
176
|
-
disabled={changingPw || !currentPw || !newPw || !confirmPw}
|
|
177
|
-
className="flex items-center gap-1.5 rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-zinc-300 hover:bg-zinc-700 disabled:opacity-50 transition-colors"
|
|
178
|
-
>
|
|
179
|
-
{changingPw ? (
|
|
180
|
-
<Loader2 size={13} className="animate-spin" />
|
|
181
|
-
) : (
|
|
182
|
-
<KeyRound size={13} />
|
|
183
|
-
)}
|
|
184
|
-
Update password
|
|
185
|
-
</button>
|
|
186
|
-
{pwMsg && (
|
|
187
|
-
<p className={`text-xs ${pwMsg.type === "ok" ? "text-emerald-400" : "text-red-400"}`}>
|
|
188
|
-
{pwMsg.text}
|
|
189
|
-
</p>
|
|
190
|
-
)}
|
|
191
|
-
</form>
|
|
192
|
-
</div>
|
|
193
|
-
)}
|
|
194
|
-
|
|
195
|
-
{/* 2FA */}
|
|
196
|
-
{hasPassword && (
|
|
197
|
-
<div className="space-y-3">
|
|
198
|
-
<TwoFactorAuth initialEnabled={twoFactorEnabled ?? false} />
|
|
199
|
-
</div>
|
|
200
|
-
)}
|
|
201
|
-
|
|
202
|
-
{/* Restore */}
|
|
203
|
-
{isOwner && (
|
|
204
|
-
<div className="space-y-3">
|
|
205
|
-
<h3 className="text-sm font-semibold text-zinc-300">Restore data</h3>
|
|
206
|
-
<p className="text-xs text-zinc-500">
|
|
207
|
-
Restore your workspace from the cloud. File restore now lives under Backup & Restore.
|
|
208
|
-
</p>
|
|
209
|
-
|
|
210
|
-
<div className="flex flex-wrap gap-2">
|
|
211
|
-
{isPro && (
|
|
212
|
-
<button
|
|
213
|
-
onClick={handleCloudRestore}
|
|
214
|
-
disabled={restoring}
|
|
215
|
-
className="flex items-center gap-1.5 rounded-md bg-zinc-800 px-3 py-1.5 text-xs font-medium text-zinc-300 hover:bg-zinc-700 disabled:opacity-50 transition-colors"
|
|
216
|
-
>
|
|
217
|
-
{restoring ? (
|
|
218
|
-
<Loader2 size={13} className="animate-spin" />
|
|
219
|
-
) : (
|
|
220
|
-
<CloudDownload size={13} />
|
|
221
|
-
)}
|
|
222
|
-
Restore from cloud
|
|
223
|
-
</button>
|
|
224
|
-
)}
|
|
225
|
-
</div>
|
|
226
|
-
|
|
227
|
-
{restoreMsg && (
|
|
228
|
-
<p
|
|
229
|
-
className={`text-xs ${restoreMsg.type === "ok" ? "text-emerald-400" : "text-red-400"}`}
|
|
230
|
-
>
|
|
231
|
-
{restoreMsg.text}
|
|
232
|
-
</p>
|
|
233
|
-
)}
|
|
234
|
-
<p className="text-xs text-zinc-700">
|
|
235
|
-
Cloud restore pulls all data from your cloud backup.
|
|
236
|
-
</p>
|
|
237
|
-
</div>
|
|
238
|
-
)}
|
|
239
|
-
|
|
240
|
-
{/* Confirmation dialog */}
|
|
241
|
-
<ConfirmDangerAction
|
|
242
|
-
open={restoreConfirm}
|
|
243
|
-
title="Restore from Cloud"
|
|
244
|
-
body="Pull all data from cloud to this device. Local changes may be overwritten. Continue?"
|
|
245
|
-
confirmLabel="Restore"
|
|
246
|
-
cancelLabel="Cancel"
|
|
247
|
-
onConfirm={confirmCloudRestore}
|
|
248
|
-
onClose={() => setRestoreConfirm(false)}
|
|
249
|
-
/>
|
|
250
|
-
</div>
|
|
251
|
-
);
|
|
252
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
// @vitest-environment jsdom
|
|
2
|
-
import { cleanup, render, screen } from "@testing-library/react";
|
|
3
|
-
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
4
|
-
import SettingsLayout from "@/app/(app)/settings/layout";
|
|
5
|
-
import { AgentTokenSettings } from "@/components/settings/agent-token-settings";
|
|
6
|
-
import { BackupRestoreSettings } from "@/components/settings/backup-restore-settings";
|
|
7
|
-
import { TeamSettings } from "@/components/settings/team-settings";
|
|
8
|
-
|
|
9
|
-
const { mockUsePathname } = vi.hoisted(() => ({
|
|
10
|
-
mockUsePathname: vi.fn(),
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
vi.mock("next/navigation", () => ({
|
|
14
|
-
usePathname: mockUsePathname,
|
|
15
|
-
useRouter: () => ({ refresh: vi.fn() }),
|
|
16
|
-
}));
|
|
17
|
-
|
|
18
|
-
describe("settings guidance", () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
mockUsePathname.mockReset();
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
afterEach(() => {
|
|
24
|
-
cleanup();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it("shows route-specific intro copy in the shared settings layout", () => {
|
|
28
|
-
mockUsePathname.mockReturnValue("/settings/agent-token");
|
|
29
|
-
|
|
30
|
-
render(
|
|
31
|
-
<SettingsLayout>
|
|
32
|
-
<div>Content</div>
|
|
33
|
-
</SettingsLayout>
|
|
34
|
-
);
|
|
35
|
-
|
|
36
|
-
expect(
|
|
37
|
-
screen.getByText("Create and revoke agent access with clear operational consequences.")
|
|
38
|
-
).toBeInTheDocument();
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
it("shows a danger zone in agent token settings", () => {
|
|
42
|
-
render(
|
|
43
|
-
<AgentTokenSettings
|
|
44
|
-
workspaces={[
|
|
45
|
-
{
|
|
46
|
-
id: "ws-1",
|
|
47
|
-
name: "Workspace One",
|
|
48
|
-
slug: "workspace-one",
|
|
49
|
-
existingToken: null,
|
|
50
|
-
},
|
|
51
|
-
]}
|
|
52
|
-
mcpUrl="https://example.com/mcp"
|
|
53
|
-
appUrl="https://example.com"
|
|
54
|
-
userId="user-1"
|
|
55
|
-
/>
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
expect(screen.getByText("Danger zone")).toBeInTheDocument();
|
|
59
|
-
expect(
|
|
60
|
-
screen.getByText("Revoking or regenerating a token disconnects any agent currently using it.")
|
|
61
|
-
).toBeInTheDocument();
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
it("explains backup export and restore outcomes before destructive actions", () => {
|
|
65
|
-
render(
|
|
66
|
-
<BackupRestoreSettings
|
|
67
|
-
isCloudWorkspace
|
|
68
|
-
isOwner
|
|
69
|
-
initialSettings={null}
|
|
70
|
-
/>
|
|
71
|
-
);
|
|
72
|
-
|
|
73
|
-
expect(
|
|
74
|
-
screen.getByText(
|
|
75
|
-
"Export creates a portable backup of the current workspace state. Restore replaces current local data with the uploaded backup."
|
|
76
|
-
)
|
|
77
|
-
).toBeInTheDocument();
|
|
78
|
-
expect(screen.getByText("Danger zone")).toBeInTheDocument();
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
it("explains pending invites and immediate revocation outcomes", () => {
|
|
82
|
-
render(
|
|
83
|
-
<TeamSettings
|
|
84
|
-
members={[]}
|
|
85
|
-
pendingInvites={[]}
|
|
86
|
-
canManage
|
|
87
|
-
currentUserId="user-1"
|
|
88
|
-
workspaceId="ws-1"
|
|
89
|
-
/>
|
|
90
|
-
);
|
|
91
|
-
|
|
92
|
-
expect(
|
|
93
|
-
screen.getByText(
|
|
94
|
-
"Invites stay pending until accepted. Revoking an invite immediately invalidates the link."
|
|
95
|
-
)
|
|
96
|
-
).toBeInTheDocument();
|
|
97
|
-
});
|
|
98
|
-
});
|