import { test, expect } from '../fixtures/base'; import { HomePage } from '../pages/home.page'; import { createSettingsStorage } from '../fixtures/test-data/settings'; /** * #620 — server-configured providers are admin-managed and not client-overridable. * On the public learner deployment, provider settings are not exposed at all; * both managed and unmanaged provider details stay behind the operator surface. * * Playwright Chromium locale is en-US. */ const SCREENSHOT_DIR = 'e2e/screenshots'; function serverProvidersBody(providers: Record) { return JSON.stringify({ providers, tts: {}, asr: {}, pdf: {}, image: {}, video: {}, webSearch: {}, }); } test.describe.configure({ mode: 'serial' }); test.describe('#620 managed providers stay behind the operator surface', () => { test.beforeEach(async ({ page }) => { await page.route('**/api/server-providers', (route) => route.fulfill({ status: 200, headers: { 'Content-Type': 'application/json' }, // Only openai is server-configured (managed); anthropic is not. body: serverProvidersBody({ openai: { models: ['gpt-4o', 'gpt-4o-mini'] } }), }), ); await page.addInitScript( (settings) => { localStorage.setItem('maic:account:settings-storage', settings); }, createSettingsStorage({ modelId: '', providerId: 'openai', providersConfig: { openai: { apiKey: '' }, anthropic: { apiKey: 'sk-ant-local' }, }, autoConfigApplied: true, }), ); }); test('managed provider (openai) stays behind the operator surface', async ({ page }) => { const home = new HomePage(page); await Promise.all([page.waitForResponse('**/api/server-providers'), home.goto()]); await expect(home.textarea).toBeVisible(); await expect(page.locator('button:has(svg.lucide-settings)')).toHaveCount(0); await expect(page.locator('button[aria-label*=" / "]')).toHaveCount(0); await expect(page.getByRole('dialog')).toHaveCount(0); await page.screenshot({ path: `${SCREENSHOT_DIR}/620-managed-openai-readonly.png`, fullPage: true, animations: 'disabled', caret: 'hide', }); }); test('unmanaged provider (anthropic) also stays behind the operator surface', async ({ page, }) => { const home = new HomePage(page); await Promise.all([page.waitForResponse('**/api/server-providers'), home.goto()]); await expect(home.textarea).toBeVisible(); await expect(page.locator('button:has(svg.lucide-settings)')).toHaveCount(0); await expect(page.locator('button[aria-label*=" / "]')).toHaveCount(0); await expect(page.getByRole('dialog')).toHaveCount(0); await page.screenshot({ path: `${SCREENSHOT_DIR}/620-unmanaged-anthropic-editable.png`, fullPage: true, animations: 'disabled', caret: 'hide', }); }); });