// ============================================================ // 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); }); });