You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
84 lines
3.0 KiB
TypeScript
84 lines
3.0 KiB
TypeScript
/**
|
|
* E2E test: Admin providers management.
|
|
*
|
|
* Validates that an admin user can:
|
|
* 1. Navigate to /admin/providers
|
|
* 2. See the Gemini provider card
|
|
* 3. Toggle enable if needed
|
|
* 4. Save changes
|
|
* 5. Verify the provider appears in the settings dropdown
|
|
*/
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
import { loginAsAdmin } from '../helpers/auth';
|
|
|
|
test.describe('Admin providers', () => {
|
|
test('should see Gemini provider and verify it appears in settings', async ({
|
|
page,
|
|
}) => {
|
|
// Step 1: Login as admin via cookie injection
|
|
await loginAsAdmin(page);
|
|
|
|
// Step 2: Navigate to admin providers page
|
|
await page.goto('/admin/providers');
|
|
|
|
// Step 3: Wait for the page to load and verify the Gemini provider card is visible
|
|
await expect(
|
|
page.locator('h2', { hasText: 'Google Gemini' }),
|
|
).toBeVisible({ timeout: 10_000 });
|
|
|
|
// Step 4: Find the Gemini card. Check if the enable toggle shows "Active"
|
|
const geminiCard = page
|
|
.locator('.bg-white.shadow-sm.border')
|
|
.filter({ hasText: 'Google Gemini' });
|
|
await expect(geminiCard).toBeVisible();
|
|
|
|
// Check the toggle state. If it shows "Desactive", click it to enable.
|
|
const statusText = geminiCard.locator('span', { hasText: /Active|Desactive/ });
|
|
const currentStatus = await statusText.textContent();
|
|
|
|
if (currentStatus?.trim() === 'Desactive') {
|
|
// Click the toggle switch (role="switch") within the Gemini card
|
|
await geminiCard.locator('button[role="switch"]').click();
|
|
// Verify it now shows "Active"
|
|
await expect(
|
|
geminiCard.locator('span', { hasText: 'Active' }),
|
|
).toBeVisible();
|
|
}
|
|
|
|
// Step 5: Click save on the Gemini card
|
|
const saveButton = geminiCard.locator('button', {
|
|
hasText: 'Enregistrer',
|
|
});
|
|
await saveButton.click();
|
|
|
|
// Wait for save confirmation (toast or page update)
|
|
// The save triggers a toast; just wait briefly for the API call
|
|
await page.waitForTimeout(1000);
|
|
|
|
// Step 6: Navigate to settings to verify the provider appears in dropdown
|
|
await page.goto('/settings');
|
|
|
|
// Wait for settings page to load
|
|
await expect(
|
|
page.locator('h1', { hasText: 'Parametres de generation' }),
|
|
).toBeVisible({ timeout: 10_000 });
|
|
|
|
// The provider should appear in the model dropdown.
|
|
// When there's a single enabled provider, it's auto-selected and the
|
|
// provider dropdown may be hidden. Check for the model dropdown instead.
|
|
// The research model dropdown (#aiModel) should have Gemini model options.
|
|
const modelDropdown = page.locator('#aiModel');
|
|
await expect(modelDropdown).toBeVisible({ timeout: 5_000 });
|
|
|
|
// Verify Gemini models are available in the dropdown
|
|
const options = modelDropdown.locator('option');
|
|
const optionCount = await options.count();
|
|
expect(optionCount).toBeGreaterThan(0);
|
|
|
|
// Check that at least one option mentions a Gemini model
|
|
const allText = await modelDropdown.textContent();
|
|
expect(allText).toContain('Gemini');
|
|
});
|
|
});
|