Second of three commits porting the vanilla settings.html. This one
delivers the two Integrations sub-sections, rendered below the Security
block and shown to every authenticated user (not gated by canLocalAuth —
SSO users also integrate Nextcloud and manage documents).
client/src/pages/Settings.tsx — NextcloudCard
Form + status line driven by /api/auth/me. Connect POSTs
/api/nextcloud/connect (nextcloudUrl / username / appPassword), which
does a PROPFIND probe against the remote, creates the target folder
via MKCOL, and encrypts the app password at rest. On success we
invalidate the ['auth-me'] query so the status line flips to
"Connected to …" without a reload. Disconnect goes through a
ConfirmModal (not a native confirm) and POSTs /api/nextcloud/disconnect.
When connected, a second row exposes the "Learning Hub — Default
Browse Path" input backed by POST /api/user/webdav-path. (That handler
lives inline in server.ts, not in userPreferences.ts — a quirk of the
existing codebase that the port preserves.)
client/src/pages/Settings.tsx — DocumentsCard
React Query feed off /api/documents. When S3 is not configured the
server returns { s3_configured: false } and we render a static notice
instead of the upload area (same branch as vanilla documents.js). The
upload form bypasses the JSON api wrapper to send multipart FormData
directly via fetch with credentials: 'include' (cookie auth continues
to work). Downloads hit /api/documents/:id/download to receive a 5-min
presigned URL which we open in a new tab. Delete goes through the
shared ConfirmModal — replaces the vanilla showConfirm({ danger, … }).
Downloading-state spinner is per-row (useMutation.variables === doc.id)
so other rows stay clickable while one is in flight.
shared/types.ts + client/src/shared/types.ts
Additive only:
- AuthUser gains webdav_learning_path — already returned by
/api/auth/me but missing from the type.
- New response shapes: NextcloudConnectOk, UserDocument,
DocumentsListOk, DocumentUploadOk, DocumentDownloadOk.
e2e/tests/settings-react-integrations.spec.js
Four smoke tests: field presence, empty-form validation error, the
S3-configured-or-notice branch renders, and a repeat of the
no-native-dialog guard covering the Integrations interactions.
Client tsc -b, server tsc --noEmit, and vite build all pass locally.
Bundle 404.56 kB / 117.12 kB gzipped (+9 kB over commit 1). The e2e
container still predates /app/*; running these specs needs a rebuild.
58 lines
2.8 KiB
JavaScript
58 lines
2.8 KiB
JavaScript
// ============================================================
|
|
// SETTINGS (React port) — Integrations sub-section smoke tests.
|
|
//
|
|
// Commit 2 of the Settings port. Covers:
|
|
// • Nextcloud connect form (URL / user / app-password / Connect btn)
|
|
// • Documents upload area (file input / description / Upload btn)
|
|
// • Disconnect and Delete flows use the styled ConfirmModal, not
|
|
// window.confirm() — the no-native-dialog guard is repeated here
|
|
// so any future regression is caught in this file too.
|
|
// ============================================================
|
|
|
|
const { test, expect, E2E_BASE } = require('../fixtures');
|
|
|
|
async function openReactSettings(page) {
|
|
await page.goto(E2E_BASE + '/app/settings');
|
|
await page.waitForSelector('[data-testid="nextcloud-section"], [data-testid="documents-section"]', {
|
|
timeout: 15000,
|
|
});
|
|
}
|
|
|
|
test.describe('React Settings — Integrations render', () => {
|
|
|
|
test('Nextcloud section: URL / user / app-password fields + Connect button', async ({ authedPage: _, page }) => {
|
|
await openReactSettings(page);
|
|
await expect(page.locator('[data-testid="nc-url"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="nc-user"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="nc-pass"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="btn-nc-connect"]')).toBeVisible();
|
|
await expect(page.locator('[data-testid="nc-status"]')).toBeVisible();
|
|
});
|
|
|
|
test('Nextcloud connect validation — missing fields shows inline error', async ({ authedPage: _, page }) => {
|
|
await openReactSettings(page);
|
|
// Don't fill any fields — just submit.
|
|
await page.click('[data-testid="btn-nc-connect"]');
|
|
await expect(page.getByText('Fill all Nextcloud fields')).toBeVisible();
|
|
});
|
|
|
|
test('Documents section: either upload area or S3-not-configured notice renders', async ({ authedPage: _, page }) => {
|
|
await openReactSettings(page);
|
|
await expect(page.locator('[data-testid="documents-section"]')).toBeVisible();
|
|
// Depending on whether S3 is configured, we see either the upload area or the not-configured message.
|
|
const uploadArea = await page.locator('[data-testid="doc-upload-area"]').count();
|
|
const notice = await page.getByText('S3 storage not configured').count();
|
|
expect(uploadArea + notice).toBeGreaterThan(0);
|
|
});
|
|
|
|
test('no native dialog fires on Nextcloud / Documents interactions', async ({ authedPage: _, page }) => {
|
|
let nativeDialogFired = false;
|
|
page.on('dialog', async (d) => { nativeDialogFired = true; await d.dismiss(); });
|
|
|
|
await openReactSettings(page);
|
|
// Exercise the inline validation path; this path never calls alert().
|
|
await page.click('[data-testid="btn-nc-connect"]');
|
|
await expect(page.getByText('Fill all Nextcloud fields')).toBeVisible();
|
|
expect(nativeDialogFired).toBe(false);
|
|
});
|
|
});
|