LibreChat/e2e/specs/nav.spec.js
Danny Avila 88683b9cc5
fix(Chat.jsx): Improve Message Creation UX by Eliminating Screen Flicker (#577)
* fix(Chat.jsx): conversation no longer navigates upon message creation, which would cause re-render/flicker

* chore(.gitignore): ignore storageState.json in all directories
chore(storageState.json): delete e2e/storageState.json file

* test(e2e): fix old tests with new playwright setup & add helper script for codegen

* fix(Conversation.jsx): add data-testid attribute to <a> element
test(messages.spec.js): add test for expected navigation after receiving message
test(messages.spec.js): add test for page navigations

* chore(Plugin.jsx): import Spinner from '~/components' instead of '../svg/Spinner'
chore(index.jsx): import Spinner from '~/components' instead of '../svg/Spinner'
chore(Spinner.jsx): change classProp prop to className prop in Spinner component
feat(index.ts): export Spinner component from './Spinner'
2023-07-03 16:00:04 -04:00

49 lines
1.9 KiB
JavaScript

import { expect, test } from '@playwright/test';
test.describe('Navigation suite', () => {
test('Navigation bar', async ({ page }) => {
await page.goto('http://localhost:3080/');
await page.locator('[id="headlessui-menu-button-\\:r0\\:"]').click();
const navBar = await page.locator('[id="headlessui-menu-button-\\:r0\\:"]').isVisible();
expect(navBar).toBeTruthy();
});
test('Settings modal', async ({ page }) => {
await page.goto('http://localhost:3080/');
await page.locator('[id="headlessui-menu-button-\\:r0\\:"]').click();
await page.getByText('Settings').click();
const modal = await page.getByRole('dialog', { name: 'Settings' }).isVisible();
expect(modal).toBeTruthy();
const modalTitle = await page.getByRole('heading', { name: 'Settings' }).textContent();
expect(modalTitle.length).toBeGreaterThan(0);
expect(modalTitle).toEqual('Settings');
const modalTabList = await page.getByRole('tablist', { name: 'Settings' }).isVisible();
expect(modalTabList).toBeTruthy();
const generalTabPanel = await page.getByRole('tabpanel', { name: 'General' }).isVisible();
expect(generalTabPanel).toBeTruthy();
const modalClearConvos = await page.getByRole('button', { name: 'Clear' }).isVisible();
expect(modalClearConvos).toBeTruthy();
const modalTheme = await page.getByRole('combobox');
expect(modalTheme.isVisible()).toBeTruthy();
async function changeMode(theme) {
// change the value to 'dark' and 'light' and see if the theme changes
await modalTheme.selectOption({ label: theme });
await page.waitForTimeout(1000);
// Check if the HTML element has the theme class
const html = await page.$eval('html', (element, theme) => element.classList.contains(theme.toLowerCase()), theme);
expect(html).toBeTruthy();
}
await changeMode('Dark');
await changeMode('Light');
});
});