mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-28 21:30:18 +01:00
e2e: refactoring and making it work.
This commit is contained in:
parent
2a506df443
commit
88c32b9ec6
8 changed files with 446 additions and 400 deletions
|
|
@ -1,42 +1,41 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
import { acceptTermsIfPresent } from '../utils/acceptTermsIfPresent';
|
||||
|
||||
// Selector for the "New chat" button (used in the landing page)
|
||||
const initialNewChatSelector = '[data-testid="nav-new-chat-button"]';
|
||||
// Selector for the landing title (assume the first <h2> contains the title)
|
||||
const landingTitleSelector = 'h2';
|
||||
|
||||
test.describe('Landing suite', () => {
|
||||
test('Landing title', async ({ page }) => {
|
||||
// Navigate to the app.
|
||||
await page.goto('http://localhost:3080/', { timeout: 5000 });
|
||||
const pageTitle = await page.textContent('#landing-title');
|
||||
expect(pageTitle?.length).toBeGreaterThan(0);
|
||||
// Accept the Terms & Conditions modal.
|
||||
await acceptTermsIfPresent(page);
|
||||
|
||||
// Assert that the landing title is present.
|
||||
const pageTitle = await page.textContent(landingTitleSelector);
|
||||
expect(pageTitle?.trim()).toContain('How can I help you today?');
|
||||
});
|
||||
|
||||
test('Create Conversation', async ({ page }) => {
|
||||
await page.goto('http://localhost:3080/', { timeout: 5000 });
|
||||
|
||||
async function getItems() {
|
||||
const navDiv = await page.waitForSelector('nav > div');
|
||||
if (!navDiv) {
|
||||
return [];
|
||||
}
|
||||
// Wait for and click the "New chat" button.
|
||||
await page.waitForSelector(initialNewChatSelector);
|
||||
const convoItemsBefore = await page.locator('[data-testid="convo-item"]').count();
|
||||
await page.locator(initialNewChatSelector).click();
|
||||
|
||||
const items = await navDiv.$$('a.group');
|
||||
return items || [];
|
||||
}
|
||||
|
||||
// Wait for the page to load and the SVG loader to disappear
|
||||
await page.waitForSelector('nav > div');
|
||||
await page.waitForSelector('nav > div > div > svg', { state: 'detached' });
|
||||
|
||||
const beforeAdding = (await getItems()).length;
|
||||
|
||||
const input = await page.locator('form').getByRole('textbox');
|
||||
// Assume a new conversation is created once the textarea appears.
|
||||
const input = page.locator('form').getByRole('textbox');
|
||||
await input.click();
|
||||
await input.fill('Hi!');
|
||||
|
||||
// Send the message
|
||||
await page.locator('form').getByRole('button').nth(1).click();
|
||||
|
||||
// Wait for the message to be sent
|
||||
// Click the send button.
|
||||
await page.getByTestId('send-button').click();
|
||||
// Wait for the message to be processed.
|
||||
await page.waitForTimeout(3500);
|
||||
const afterAdding = (await getItems()).length;
|
||||
|
||||
expect(afterAdding).toBeGreaterThanOrEqual(beforeAdding);
|
||||
const convoItemsAfter = await page.locator('[data-testid="convo-item"]').count();
|
||||
expect(convoItemsAfter).toBeGreaterThanOrEqual(convoItemsBefore);
|
||||
});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue