e2e: refactoring and making it work.

This commit is contained in:
Ruben Talstra 2025-02-12 17:40:38 +01:00
parent 2a506df443
commit 88c32b9ec6
Failed to extract signature
8 changed files with 446 additions and 400 deletions

View file

@ -1,16 +1,31 @@
import { expect, test } from '@playwright/test';
import { acceptTermsIfPresent } from '../utils/acceptTermsIfPresent';
const initialNewChatSelector = '[data-testid="nav-new-chat-button"]';
test.describe('Endpoints Presets suite', () => {
test('Endpoints Suite', async ({ page }) => {
// Navigate to the application.
await page.goto('http://localhost:3080/', { timeout: 5000 });
await page.getByTestId('new-conversation-menu').click();
// includes the icon + endpoint names in obj property
const endpointItem = page.getByRole('menuitemradio', { name: 'ChatGPT OpenAI' });
await endpointItem.click();
// Accept the Terms & Conditions modal if needed.
await acceptTermsIfPresent(page);
await page.getByTestId('new-conversation-menu').click();
// Check if the active class is set on the selected endpoint
expect(await endpointItem.getAttribute('class')).toContain('active');
// Click the New Chat button.
await page.locator(initialNewChatSelector).click();
// Open the endpoint menu by clicking the combobox with label "LLM Endpoint Menu".
const llmComboBox = page.getByRole('combobox', { name: 'LLM Endpoint Menu' });
await llmComboBox.click();
// Wait for the Azure OpenAI endpoint item to appear using its test ID.
const azureEndpoint = page.getByTestId('endpoint-item-azureOpenAI');
await azureEndpoint.waitFor({ state: 'visible', timeout: 5000 });
// Verify that the Azure endpoint item is visible.
expect(await azureEndpoint.isVisible()).toBeTruthy();
// Optionally, close the endpoint menu by clicking the New Chat button again.
await page.locator(initialNewChatSelector).click();
});
});
});