LibreChat/e2e/specs/landing.spec.ts

43 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

import { expect, test } from '@playwright/test';
2023-03-27 17:00:59 -07:00
test.describe('Landing suite', () => {
test('Landing title', async ({ page }) => {
await page.goto('http://localhost:3080/', { timeout: 5000 });
Added Settings Modal (#342) * Improve UI with style changes and add Settings button - Improved the UI of the `Input` and `Message` components. - Added a `Settings` button to the `NavLinks` component. - Introduced a `Settings` component to handle user settings. - Refactored the `Dialog` component for consistency. * Revert not needed changes * Updated style.css to only work for select * feat: Remove Dark Mode component and add theme selection feature This commit removes the Dark Mode component from the navigation bar and replaces it with a theme selection dropdown menu in the Settings dialog. The implementation of the theme selection feature includes a function that allows the user to set the theme based on the system, light, or dark mode. * Add auto theme setting to Settings component. This commit adds a new state variable to keep track of whether the auto theme is enabled or not. It also registers an event listener to update the theme based on system preference changes. The event listener is removed when the component is unmounted. * Improve user experience by allowing customized themes - Create `selectedOption` state to track user-selected theme - Remove unused `isAutoTheme` state variable * feat(Nav): Add SVG icon to settings gear This commit adds an SVG icon to the settings gear in the Navigation component's Settings file. The new SVG icon replaces the previous GearIcon component. * refactor(ui): Update overlay background color This commit updates the background color of the overlay in the AlertDialog and Dialog components by changing the classes applied to the elements. The new color is a transition from `bg-black/50 backdrop-blur-sm` to `bg-gray-500/90 dark:bg-gray-800/90`. This change improves the readability of the dialog boxes. * Refactor ThemeContext to include system theme and fix bug in Settings The ThemeContext now includes a "system" theme and ClearConvos no longer relies on the "selected option" state to update the theme. The bug is now fixed if the system theme changes. * Refactor DialogTemplate styles and color scheme Adjusted the color scheme of the DialogTemplate component to dark mode, updated the background color to gray-900 and removed unnecessary classes. * Refactor: Change button logic to require confirmation before clearing convos This commit refactors the code by adding a confirmation dialog to prompt for a user's confirmation before clearing all conversations in the Settings.jsx file. The change ensures the user is aware of the irreversible action before initiating the clearConvos function. Additionally, the commit updates the clear chat button's class name and changes the button's onClick logic to call the confirmClearConvos function instead of directly invoking the clearConvos method. * Refactor component name to reflect functionality change. - Changed component name from ClearConvos to Settings to support potential future use cases. * Refactor conversation clearing functionality in `Settings.jsx` This commit optimizes the conversation clearing functionality in the `Settings.jsx` component by removing the `confirmClearConvos` function and directly calling the `clearConvos` function on confirmation. This change will simplify the code and improve the user experience. * Refactor Input component UI styles Simplify Input component styles by simplifying the gradient background, removing border color styles, and updating button styles. * feat: Add e2e test for Settings modal This commit adds an e2e test to verify whether the Settings modal is displayed on the landing page. It uses a headless browser to navigate to the page and interacts with it to verify if the dialog and its components are visible. * test: Add Navigation and Settings tests Add Navigation and Settings tests to verify that the navigation bar and Settings button are visible and that the Settings modal displays the expected content. The settings modal verification includes checking whether the modal is visible, if the modal title, tab list, clear conversation button and theme are present, and if the theme option can be selected to change the mode. * Quick fix * feat(navbar): Add confirmation before clearing conversations Adding confirmation modal to prevent accidentally clearing conversations. Before, once you clicked on the "Clear" button it immediately clears all conversations. With this change, if you click on "Clear" the first time, it will change the text to "Confirm Clear" and if you click it again, it will clear all conversations. * Add click functionality to the navigation bar and improve UI design The code introduced click functionality to the nav bar and improved the user interface. It also used the new theme select feature to change the theme to dark. * test: Add test for dark mode theme change Refactor the test for Navigation suite to check for the 'dark' class in the HTML element when the 'dark' theme is selected in the modal. This ensures that the dark mode theme change works correctly, and improves test coverage. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Hotfix * Removed repetation * Refactor: Change text-gray-400 to text-white/50 to make tailwind more cleaner * style: Update CSS classes to improve the conversation UI - Update Conversation component to improve UX - Changed styling for group hover effect using shades of gray - Improved color contrast of the Message component for easy readability - Replaced class names in buildTree.js with a new class name - Added a new color theme (gray-1000) in tailwind.config to replace an old background color. * Refactor EndpointItem, EndpointItems, and NewConversationMenu for better user experience - The `EndpointItem` component now accepts an `isSelected` prop instead of `onSelect` to better reflect its usage in `EndpointItems` and `NewConversationMenu`. - `EndpointItems` component now has a `selectedEndpoint` prop to highlight the selected item in the list. - `NewConversationMenu` now has a gap between the endpoint options to improve user experience. * Added error messages * refactor: Improve endpoint menu highlighting and error handling In the UI, when the user selects an endpoint, the active class is now properly set. In the error handling function, `isJson` is now a private function called by `getError`, which provides better parsing of error messages, and returns more succinct messages upon encountering specific errors. Finally, a new end-to-end test has been added to check if the active class is properly set on selecting an endpoint in the new conversation menu. * test: Add Conversation and Change Path of Auth JSON In the Landing spec, test the functionality to create conversations and check that the number of items has increased. In the Popup spec, change the path of the Auth JSON used by the context. * Fixed logo issues * Make everything not rounded * Added time --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
2023-06-02 10:02:35 +05:30
const pageTitle = await page.textContent('#landing-title');
ci: add e2e workflow, optimize client code for testing (#771) * refactor(e2e): fix tests with latest changes, convert to TS, use test Ids * chore(EndpointMenu.jsx): add data-testid attribute to new-conversation-menu button * refactor(EndpointItem): add data-testid attr., convert to TS * refactor(e2e): remove unnecessary awaits and convert to TS * chore(playwright.config.local.ts): add absolute path to server index.js file chore(playwright.config.local.ts): add dotenv configuration chore(playwright.config.local.ts): change webServer command to use absolute path chore(playwright.config.local.ts): add NODE_ENV and process.env to webServer env chore(playwright.config.local.ts): remove unused import chore(login.spec.js): delete login.spec.js file * chore(.gitignore): add 'my.secrets' to the list of ignored files fix(Registration.tsx): add 'data-testid' attribute to the error message div fix(Registration.spec.tsx): comment out test case that calls 'registerUser.mutate' * chore(ConvoIcon.tsx): add data-testid attribute to svg element chore(messages.spec.ts): refactor conversation navigation logic * chore(playwright.config.ts): add support for absolute path to server index.js file feat(playwright.config.ts): add support for dotenv configuration feat(playwright.config.ts): set NODE_ENV to 'production' in webServer environment variables * chore(workflows): comment out push event and specify paths for pull_request event in backend-review.yml chore(workflows): comment out push event and specify paths for pull_request event in frontend-review.yml * chore(install.js): add check to skip install script in CI environment * chore: complete playwright workflow * chore(Landing.tsx): add data-testid attribute to landing title element chore(authenticate.ts): update selector to wait for landing title element by test id instead of text content * chore(playwright.yml): add step to upload screenshot artifact on failure fix(authenticate.ts): capture screenshot before waiting for landing title and increase timeout due to GH Actions load time * chore(playwright.yml): rename artifact name from 'screenshot' to 'login-screenshot' feat(LoginForm.tsx): add data-testid attribute to login button fix(authenticate.ts): change screenshot name to 'login-screenshot.png' and conditionally take screenshot only in CI environment * chore(playwright.yml): add CI environment variable and set it to true * chore(playwright.yml): update Playwright installation command chore(playwright.config.ts): update storageState path to use process.cwd() * fix(playwright.yml): update node version to 18 in setup-node action fix(playwright.yml): update actions/cache to v3 in Cache Node.js modules step fix(playwright.yml): update actions/cache to v3 in Cache Playwright installations step fix(authenticate.ts): change login button click to press 'Enter' on password input * chore(playwright.yml): update E2E_USER_EMAIL and E2E_USER_PASSWORD values for testing purposes chore(authenticate.ts): add console.dir to log user object for debugging * chore(playwright.yml): add step to upload storageState artifact The storageState artifact is now uploaded as part of the workflow. This artifact contains the state of the storage used during the end-to-end tests. It will be retained for 2 days. * chore(playwright.yml): comment out upload screenshot step chore(playwright.config.ts): change NODE_ENV to development chore(authenticate.ts): comment out screenshot related code * chore(playwright.config.ts): add SESSION_EXPIRY environment variable with value 86400000 * chore(playwright.yml): update environment variables in Playwright workflow fix(General.tsx): add data-testid attributes to clear conversations buttons test(messages.spec.ts): add setup and teardown steps for clearing conversations before and after tests * fix(messages.spec.ts): fix clearing conversations before and after message tests feat(messages.spec.ts): add beforeEach and afterEach hooks to create and close new page for each test * chore: remove storageStage upload artifact
2023-08-08 11:17:15 -04:00
expect(pageTitle?.length).toBeGreaterThan(0);
});
Added Settings Modal (#342) * Improve UI with style changes and add Settings button - Improved the UI of the `Input` and `Message` components. - Added a `Settings` button to the `NavLinks` component. - Introduced a `Settings` component to handle user settings. - Refactored the `Dialog` component for consistency. * Revert not needed changes * Updated style.css to only work for select * feat: Remove Dark Mode component and add theme selection feature This commit removes the Dark Mode component from the navigation bar and replaces it with a theme selection dropdown menu in the Settings dialog. The implementation of the theme selection feature includes a function that allows the user to set the theme based on the system, light, or dark mode. * Add auto theme setting to Settings component. This commit adds a new state variable to keep track of whether the auto theme is enabled or not. It also registers an event listener to update the theme based on system preference changes. The event listener is removed when the component is unmounted. * Improve user experience by allowing customized themes - Create `selectedOption` state to track user-selected theme - Remove unused `isAutoTheme` state variable * feat(Nav): Add SVG icon to settings gear This commit adds an SVG icon to the settings gear in the Navigation component's Settings file. The new SVG icon replaces the previous GearIcon component. * refactor(ui): Update overlay background color This commit updates the background color of the overlay in the AlertDialog and Dialog components by changing the classes applied to the elements. The new color is a transition from `bg-black/50 backdrop-blur-sm` to `bg-gray-500/90 dark:bg-gray-800/90`. This change improves the readability of the dialog boxes. * Refactor ThemeContext to include system theme and fix bug in Settings The ThemeContext now includes a "system" theme and ClearConvos no longer relies on the "selected option" state to update the theme. The bug is now fixed if the system theme changes. * Refactor DialogTemplate styles and color scheme Adjusted the color scheme of the DialogTemplate component to dark mode, updated the background color to gray-900 and removed unnecessary classes. * Refactor: Change button logic to require confirmation before clearing convos This commit refactors the code by adding a confirmation dialog to prompt for a user's confirmation before clearing all conversations in the Settings.jsx file. The change ensures the user is aware of the irreversible action before initiating the clearConvos function. Additionally, the commit updates the clear chat button's class name and changes the button's onClick logic to call the confirmClearConvos function instead of directly invoking the clearConvos method. * Refactor component name to reflect functionality change. - Changed component name from ClearConvos to Settings to support potential future use cases. * Refactor conversation clearing functionality in `Settings.jsx` This commit optimizes the conversation clearing functionality in the `Settings.jsx` component by removing the `confirmClearConvos` function and directly calling the `clearConvos` function on confirmation. This change will simplify the code and improve the user experience. * Refactor Input component UI styles Simplify Input component styles by simplifying the gradient background, removing border color styles, and updating button styles. * feat: Add e2e test for Settings modal This commit adds an e2e test to verify whether the Settings modal is displayed on the landing page. It uses a headless browser to navigate to the page and interacts with it to verify if the dialog and its components are visible. * test: Add Navigation and Settings tests Add Navigation and Settings tests to verify that the navigation bar and Settings button are visible and that the Settings modal displays the expected content. The settings modal verification includes checking whether the modal is visible, if the modal title, tab list, clear conversation button and theme are present, and if the theme option can be selected to change the mode. * Quick fix * feat(navbar): Add confirmation before clearing conversations Adding confirmation modal to prevent accidentally clearing conversations. Before, once you clicked on the "Clear" button it immediately clears all conversations. With this change, if you click on "Clear" the first time, it will change the text to "Confirm Clear" and if you click it again, it will clear all conversations. * Add click functionality to the navigation bar and improve UI design The code introduced click functionality to the nav bar and improved the user interface. It also used the new theme select feature to change the theme to dark. * test: Add test for dark mode theme change Refactor the test for Navigation suite to check for the 'dark' class in the HTML element when the 'dark' theme is selected in the modal. This ensures that the dark mode theme change works correctly, and improves test coverage. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Hotfix * Removed repetation * Refactor: Change text-gray-400 to text-white/50 to make tailwind more cleaner * style: Update CSS classes to improve the conversation UI - Update Conversation component to improve UX - Changed styling for group hover effect using shades of gray - Improved color contrast of the Message component for easy readability - Replaced class names in buildTree.js with a new class name - Added a new color theme (gray-1000) in tailwind.config to replace an old background color. * Refactor EndpointItem, EndpointItems, and NewConversationMenu for better user experience - The `EndpointItem` component now accepts an `isSelected` prop instead of `onSelect` to better reflect its usage in `EndpointItems` and `NewConversationMenu`. - `EndpointItems` component now has a `selectedEndpoint` prop to highlight the selected item in the list. - `NewConversationMenu` now has a gap between the endpoint options to improve user experience. * Added error messages * refactor: Improve endpoint menu highlighting and error handling In the UI, when the user selects an endpoint, the active class is now properly set. In the error handling function, `isJson` is now a private function called by `getError`, which provides better parsing of error messages, and returns more succinct messages upon encountering specific errors. Finally, a new end-to-end test has been added to check if the active class is properly set on selecting an endpoint in the new conversation menu. * test: Add Conversation and Change Path of Auth JSON In the Landing spec, test the functionality to create conversations and check that the number of items has increased. In the Popup spec, change the path of the Auth JSON used by the context. * Fixed logo issues * Make everything not rounded * Added time --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
2023-06-02 10:02:35 +05:30
test('Create Conversation', async ({ page }) => {
await page.goto('http://localhost:3080/', { timeout: 5000 });
Added Settings Modal (#342) * Improve UI with style changes and add Settings button - Improved the UI of the `Input` and `Message` components. - Added a `Settings` button to the `NavLinks` component. - Introduced a `Settings` component to handle user settings. - Refactored the `Dialog` component for consistency. * Revert not needed changes * Updated style.css to only work for select * feat: Remove Dark Mode component and add theme selection feature This commit removes the Dark Mode component from the navigation bar and replaces it with a theme selection dropdown menu in the Settings dialog. The implementation of the theme selection feature includes a function that allows the user to set the theme based on the system, light, or dark mode. * Add auto theme setting to Settings component. This commit adds a new state variable to keep track of whether the auto theme is enabled or not. It also registers an event listener to update the theme based on system preference changes. The event listener is removed when the component is unmounted. * Improve user experience by allowing customized themes - Create `selectedOption` state to track user-selected theme - Remove unused `isAutoTheme` state variable * feat(Nav): Add SVG icon to settings gear This commit adds an SVG icon to the settings gear in the Navigation component's Settings file. The new SVG icon replaces the previous GearIcon component. * refactor(ui): Update overlay background color This commit updates the background color of the overlay in the AlertDialog and Dialog components by changing the classes applied to the elements. The new color is a transition from `bg-black/50 backdrop-blur-sm` to `bg-gray-500/90 dark:bg-gray-800/90`. This change improves the readability of the dialog boxes. * Refactor ThemeContext to include system theme and fix bug in Settings The ThemeContext now includes a "system" theme and ClearConvos no longer relies on the "selected option" state to update the theme. The bug is now fixed if the system theme changes. * Refactor DialogTemplate styles and color scheme Adjusted the color scheme of the DialogTemplate component to dark mode, updated the background color to gray-900 and removed unnecessary classes. * Refactor: Change button logic to require confirmation before clearing convos This commit refactors the code by adding a confirmation dialog to prompt for a user's confirmation before clearing all conversations in the Settings.jsx file. The change ensures the user is aware of the irreversible action before initiating the clearConvos function. Additionally, the commit updates the clear chat button's class name and changes the button's onClick logic to call the confirmClearConvos function instead of directly invoking the clearConvos method. * Refactor component name to reflect functionality change. - Changed component name from ClearConvos to Settings to support potential future use cases. * Refactor conversation clearing functionality in `Settings.jsx` This commit optimizes the conversation clearing functionality in the `Settings.jsx` component by removing the `confirmClearConvos` function and directly calling the `clearConvos` function on confirmation. This change will simplify the code and improve the user experience. * Refactor Input component UI styles Simplify Input component styles by simplifying the gradient background, removing border color styles, and updating button styles. * feat: Add e2e test for Settings modal This commit adds an e2e test to verify whether the Settings modal is displayed on the landing page. It uses a headless browser to navigate to the page and interacts with it to verify if the dialog and its components are visible. * test: Add Navigation and Settings tests Add Navigation and Settings tests to verify that the navigation bar and Settings button are visible and that the Settings modal displays the expected content. The settings modal verification includes checking whether the modal is visible, if the modal title, tab list, clear conversation button and theme are present, and if the theme option can be selected to change the mode. * Quick fix * feat(navbar): Add confirmation before clearing conversations Adding confirmation modal to prevent accidentally clearing conversations. Before, once you clicked on the "Clear" button it immediately clears all conversations. With this change, if you click on "Clear" the first time, it will change the text to "Confirm Clear" and if you click it again, it will clear all conversations. * Add click functionality to the navigation bar and improve UI design The code introduced click functionality to the nav bar and improved the user interface. It also used the new theme select feature to change the theme to dark. * test: Add test for dark mode theme change Refactor the test for Navigation suite to check for the 'dark' class in the HTML element when the 'dark' theme is selected in the modal. This ensures that the dark mode theme change works correctly, and improves test coverage. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Hotfix * Removed repetation * Refactor: Change text-gray-400 to text-white/50 to make tailwind more cleaner * style: Update CSS classes to improve the conversation UI - Update Conversation component to improve UX - Changed styling for group hover effect using shades of gray - Improved color contrast of the Message component for easy readability - Replaced class names in buildTree.js with a new class name - Added a new color theme (gray-1000) in tailwind.config to replace an old background color. * Refactor EndpointItem, EndpointItems, and NewConversationMenu for better user experience - The `EndpointItem` component now accepts an `isSelected` prop instead of `onSelect` to better reflect its usage in `EndpointItems` and `NewConversationMenu`. - `EndpointItems` component now has a `selectedEndpoint` prop to highlight the selected item in the list. - `NewConversationMenu` now has a gap between the endpoint options to improve user experience. * Added error messages * refactor: Improve endpoint menu highlighting and error handling In the UI, when the user selects an endpoint, the active class is now properly set. In the error handling function, `isJson` is now a private function called by `getError`, which provides better parsing of error messages, and returns more succinct messages upon encountering specific errors. Finally, a new end-to-end test has been added to check if the active class is properly set on selecting an endpoint in the new conversation menu. * test: Add Conversation and Change Path of Auth JSON In the Landing spec, test the functionality to create conversations and check that the number of items has increased. In the Popup spec, change the path of the Auth JSON used by the context. * Fixed logo issues * Make everything not rounded * Added time --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
2023-06-02 10:02:35 +05:30
async function getItems() {
const navDiv = await page.waitForSelector('nav > div');
if (!navDiv) {
return [];
}
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' });
ci: add e2e workflow, optimize client code for testing (#771) * refactor(e2e): fix tests with latest changes, convert to TS, use test Ids * chore(EndpointMenu.jsx): add data-testid attribute to new-conversation-menu button * refactor(EndpointItem): add data-testid attr., convert to TS * refactor(e2e): remove unnecessary awaits and convert to TS * chore(playwright.config.local.ts): add absolute path to server index.js file chore(playwright.config.local.ts): add dotenv configuration chore(playwright.config.local.ts): change webServer command to use absolute path chore(playwright.config.local.ts): add NODE_ENV and process.env to webServer env chore(playwright.config.local.ts): remove unused import chore(login.spec.js): delete login.spec.js file * chore(.gitignore): add 'my.secrets' to the list of ignored files fix(Registration.tsx): add 'data-testid' attribute to the error message div fix(Registration.spec.tsx): comment out test case that calls 'registerUser.mutate' * chore(ConvoIcon.tsx): add data-testid attribute to svg element chore(messages.spec.ts): refactor conversation navigation logic * chore(playwright.config.ts): add support for absolute path to server index.js file feat(playwright.config.ts): add support for dotenv configuration feat(playwright.config.ts): set NODE_ENV to 'production' in webServer environment variables * chore(workflows): comment out push event and specify paths for pull_request event in backend-review.yml chore(workflows): comment out push event and specify paths for pull_request event in frontend-review.yml * chore(install.js): add check to skip install script in CI environment * chore: complete playwright workflow * chore(Landing.tsx): add data-testid attribute to landing title element chore(authenticate.ts): update selector to wait for landing title element by test id instead of text content * chore(playwright.yml): add step to upload screenshot artifact on failure fix(authenticate.ts): capture screenshot before waiting for landing title and increase timeout due to GH Actions load time * chore(playwright.yml): rename artifact name from 'screenshot' to 'login-screenshot' feat(LoginForm.tsx): add data-testid attribute to login button fix(authenticate.ts): change screenshot name to 'login-screenshot.png' and conditionally take screenshot only in CI environment * chore(playwright.yml): add CI environment variable and set it to true * chore(playwright.yml): update Playwright installation command chore(playwright.config.ts): update storageState path to use process.cwd() * fix(playwright.yml): update node version to 18 in setup-node action fix(playwright.yml): update actions/cache to v3 in Cache Node.js modules step fix(playwright.yml): update actions/cache to v3 in Cache Playwright installations step fix(authenticate.ts): change login button click to press 'Enter' on password input * chore(playwright.yml): update E2E_USER_EMAIL and E2E_USER_PASSWORD values for testing purposes chore(authenticate.ts): add console.dir to log user object for debugging * chore(playwright.yml): add step to upload storageState artifact The storageState artifact is now uploaded as part of the workflow. This artifact contains the state of the storage used during the end-to-end tests. It will be retained for 2 days. * chore(playwright.yml): comment out upload screenshot step chore(playwright.config.ts): change NODE_ENV to development chore(authenticate.ts): comment out screenshot related code * chore(playwright.config.ts): add SESSION_EXPIRY environment variable with value 86400000 * chore(playwright.yml): update environment variables in Playwright workflow fix(General.tsx): add data-testid attributes to clear conversations buttons test(messages.spec.ts): add setup and teardown steps for clearing conversations before and after tests * fix(messages.spec.ts): fix clearing conversations before and after message tests feat(messages.spec.ts): add beforeEach and afterEach hooks to create and close new page for each test * chore: remove storageStage upload artifact
2023-08-08 11:17:15 -04:00
const beforeAdding = (await getItems()).length;
Added Settings Modal (#342) * Improve UI with style changes and add Settings button - Improved the UI of the `Input` and `Message` components. - Added a `Settings` button to the `NavLinks` component. - Introduced a `Settings` component to handle user settings. - Refactored the `Dialog` component for consistency. * Revert not needed changes * Updated style.css to only work for select * feat: Remove Dark Mode component and add theme selection feature This commit removes the Dark Mode component from the navigation bar and replaces it with a theme selection dropdown menu in the Settings dialog. The implementation of the theme selection feature includes a function that allows the user to set the theme based on the system, light, or dark mode. * Add auto theme setting to Settings component. This commit adds a new state variable to keep track of whether the auto theme is enabled or not. It also registers an event listener to update the theme based on system preference changes. The event listener is removed when the component is unmounted. * Improve user experience by allowing customized themes - Create `selectedOption` state to track user-selected theme - Remove unused `isAutoTheme` state variable * feat(Nav): Add SVG icon to settings gear This commit adds an SVG icon to the settings gear in the Navigation component's Settings file. The new SVG icon replaces the previous GearIcon component. * refactor(ui): Update overlay background color This commit updates the background color of the overlay in the AlertDialog and Dialog components by changing the classes applied to the elements. The new color is a transition from `bg-black/50 backdrop-blur-sm` to `bg-gray-500/90 dark:bg-gray-800/90`. This change improves the readability of the dialog boxes. * Refactor ThemeContext to include system theme and fix bug in Settings The ThemeContext now includes a "system" theme and ClearConvos no longer relies on the "selected option" state to update the theme. The bug is now fixed if the system theme changes. * Refactor DialogTemplate styles and color scheme Adjusted the color scheme of the DialogTemplate component to dark mode, updated the background color to gray-900 and removed unnecessary classes. * Refactor: Change button logic to require confirmation before clearing convos This commit refactors the code by adding a confirmation dialog to prompt for a user's confirmation before clearing all conversations in the Settings.jsx file. The change ensures the user is aware of the irreversible action before initiating the clearConvos function. Additionally, the commit updates the clear chat button's class name and changes the button's onClick logic to call the confirmClearConvos function instead of directly invoking the clearConvos method. * Refactor component name to reflect functionality change. - Changed component name from ClearConvos to Settings to support potential future use cases. * Refactor conversation clearing functionality in `Settings.jsx` This commit optimizes the conversation clearing functionality in the `Settings.jsx` component by removing the `confirmClearConvos` function and directly calling the `clearConvos` function on confirmation. This change will simplify the code and improve the user experience. * Refactor Input component UI styles Simplify Input component styles by simplifying the gradient background, removing border color styles, and updating button styles. * feat: Add e2e test for Settings modal This commit adds an e2e test to verify whether the Settings modal is displayed on the landing page. It uses a headless browser to navigate to the page and interacts with it to verify if the dialog and its components are visible. * test: Add Navigation and Settings tests Add Navigation and Settings tests to verify that the navigation bar and Settings button are visible and that the Settings modal displays the expected content. The settings modal verification includes checking whether the modal is visible, if the modal title, tab list, clear conversation button and theme are present, and if the theme option can be selected to change the mode. * Quick fix * feat(navbar): Add confirmation before clearing conversations Adding confirmation modal to prevent accidentally clearing conversations. Before, once you clicked on the "Clear" button it immediately clears all conversations. With this change, if you click on "Clear" the first time, it will change the text to "Confirm Clear" and if you click it again, it will clear all conversations. * Add click functionality to the navigation bar and improve UI design The code introduced click functionality to the nav bar and improved the user interface. It also used the new theme select feature to change the theme to dark. * test: Add test for dark mode theme change Refactor the test for Navigation suite to check for the 'dark' class in the HTML element when the 'dark' theme is selected in the modal. This ensures that the dark mode theme change works correctly, and improves test coverage. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Hotfix * Removed repetation * Refactor: Change text-gray-400 to text-white/50 to make tailwind more cleaner * style: Update CSS classes to improve the conversation UI - Update Conversation component to improve UX - Changed styling for group hover effect using shades of gray - Improved color contrast of the Message component for easy readability - Replaced class names in buildTree.js with a new class name - Added a new color theme (gray-1000) in tailwind.config to replace an old background color. * Refactor EndpointItem, EndpointItems, and NewConversationMenu for better user experience - The `EndpointItem` component now accepts an `isSelected` prop instead of `onSelect` to better reflect its usage in `EndpointItems` and `NewConversationMenu`. - `EndpointItems` component now has a `selectedEndpoint` prop to highlight the selected item in the list. - `NewConversationMenu` now has a gap between the endpoint options to improve user experience. * Added error messages * refactor: Improve endpoint menu highlighting and error handling In the UI, when the user selects an endpoint, the active class is now properly set. In the error handling function, `isJson` is now a private function called by `getError`, which provides better parsing of error messages, and returns more succinct messages upon encountering specific errors. Finally, a new end-to-end test has been added to check if the active class is properly set on selecting an endpoint in the new conversation menu. * test: Add Conversation and Change Path of Auth JSON In the Landing spec, test the functionality to create conversations and check that the number of items has increased. In the Popup spec, change the path of the Auth JSON used by the context. * Fixed logo issues * Make everything not rounded * Added time --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
2023-06-02 10:02:35 +05:30
const input = await 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
await page.waitForTimeout(3500);
ci: add e2e workflow, optimize client code for testing (#771) * refactor(e2e): fix tests with latest changes, convert to TS, use test Ids * chore(EndpointMenu.jsx): add data-testid attribute to new-conversation-menu button * refactor(EndpointItem): add data-testid attr., convert to TS * refactor(e2e): remove unnecessary awaits and convert to TS * chore(playwright.config.local.ts): add absolute path to server index.js file chore(playwright.config.local.ts): add dotenv configuration chore(playwright.config.local.ts): change webServer command to use absolute path chore(playwright.config.local.ts): add NODE_ENV and process.env to webServer env chore(playwright.config.local.ts): remove unused import chore(login.spec.js): delete login.spec.js file * chore(.gitignore): add 'my.secrets' to the list of ignored files fix(Registration.tsx): add 'data-testid' attribute to the error message div fix(Registration.spec.tsx): comment out test case that calls 'registerUser.mutate' * chore(ConvoIcon.tsx): add data-testid attribute to svg element chore(messages.spec.ts): refactor conversation navigation logic * chore(playwright.config.ts): add support for absolute path to server index.js file feat(playwright.config.ts): add support for dotenv configuration feat(playwright.config.ts): set NODE_ENV to 'production' in webServer environment variables * chore(workflows): comment out push event and specify paths for pull_request event in backend-review.yml chore(workflows): comment out push event and specify paths for pull_request event in frontend-review.yml * chore(install.js): add check to skip install script in CI environment * chore: complete playwright workflow * chore(Landing.tsx): add data-testid attribute to landing title element chore(authenticate.ts): update selector to wait for landing title element by test id instead of text content * chore(playwright.yml): add step to upload screenshot artifact on failure fix(authenticate.ts): capture screenshot before waiting for landing title and increase timeout due to GH Actions load time * chore(playwright.yml): rename artifact name from 'screenshot' to 'login-screenshot' feat(LoginForm.tsx): add data-testid attribute to login button fix(authenticate.ts): change screenshot name to 'login-screenshot.png' and conditionally take screenshot only in CI environment * chore(playwright.yml): add CI environment variable and set it to true * chore(playwright.yml): update Playwright installation command chore(playwright.config.ts): update storageState path to use process.cwd() * fix(playwright.yml): update node version to 18 in setup-node action fix(playwright.yml): update actions/cache to v3 in Cache Node.js modules step fix(playwright.yml): update actions/cache to v3 in Cache Playwright installations step fix(authenticate.ts): change login button click to press 'Enter' on password input * chore(playwright.yml): update E2E_USER_EMAIL and E2E_USER_PASSWORD values for testing purposes chore(authenticate.ts): add console.dir to log user object for debugging * chore(playwright.yml): add step to upload storageState artifact The storageState artifact is now uploaded as part of the workflow. This artifact contains the state of the storage used during the end-to-end tests. It will be retained for 2 days. * chore(playwright.yml): comment out upload screenshot step chore(playwright.config.ts): change NODE_ENV to development chore(authenticate.ts): comment out screenshot related code * chore(playwright.config.ts): add SESSION_EXPIRY environment variable with value 86400000 * chore(playwright.yml): update environment variables in Playwright workflow fix(General.tsx): add data-testid attributes to clear conversations buttons test(messages.spec.ts): add setup and teardown steps for clearing conversations before and after tests * fix(messages.spec.ts): fix clearing conversations before and after message tests feat(messages.spec.ts): add beforeEach and afterEach hooks to create and close new page for each test * chore: remove storageStage upload artifact
2023-08-08 11:17:15 -04:00
const afterAdding = (await getItems()).length;
Added Settings Modal (#342) * Improve UI with style changes and add Settings button - Improved the UI of the `Input` and `Message` components. - Added a `Settings` button to the `NavLinks` component. - Introduced a `Settings` component to handle user settings. - Refactored the `Dialog` component for consistency. * Revert not needed changes * Updated style.css to only work for select * feat: Remove Dark Mode component and add theme selection feature This commit removes the Dark Mode component from the navigation bar and replaces it with a theme selection dropdown menu in the Settings dialog. The implementation of the theme selection feature includes a function that allows the user to set the theme based on the system, light, or dark mode. * Add auto theme setting to Settings component. This commit adds a new state variable to keep track of whether the auto theme is enabled or not. It also registers an event listener to update the theme based on system preference changes. The event listener is removed when the component is unmounted. * Improve user experience by allowing customized themes - Create `selectedOption` state to track user-selected theme - Remove unused `isAutoTheme` state variable * feat(Nav): Add SVG icon to settings gear This commit adds an SVG icon to the settings gear in the Navigation component's Settings file. The new SVG icon replaces the previous GearIcon component. * refactor(ui): Update overlay background color This commit updates the background color of the overlay in the AlertDialog and Dialog components by changing the classes applied to the elements. The new color is a transition from `bg-black/50 backdrop-blur-sm` to `bg-gray-500/90 dark:bg-gray-800/90`. This change improves the readability of the dialog boxes. * Refactor ThemeContext to include system theme and fix bug in Settings The ThemeContext now includes a "system" theme and ClearConvos no longer relies on the "selected option" state to update the theme. The bug is now fixed if the system theme changes. * Refactor DialogTemplate styles and color scheme Adjusted the color scheme of the DialogTemplate component to dark mode, updated the background color to gray-900 and removed unnecessary classes. * Refactor: Change button logic to require confirmation before clearing convos This commit refactors the code by adding a confirmation dialog to prompt for a user's confirmation before clearing all conversations in the Settings.jsx file. The change ensures the user is aware of the irreversible action before initiating the clearConvos function. Additionally, the commit updates the clear chat button's class name and changes the button's onClick logic to call the confirmClearConvos function instead of directly invoking the clearConvos method. * Refactor component name to reflect functionality change. - Changed component name from ClearConvos to Settings to support potential future use cases. * Refactor conversation clearing functionality in `Settings.jsx` This commit optimizes the conversation clearing functionality in the `Settings.jsx` component by removing the `confirmClearConvos` function and directly calling the `clearConvos` function on confirmation. This change will simplify the code and improve the user experience. * Refactor Input component UI styles Simplify Input component styles by simplifying the gradient background, removing border color styles, and updating button styles. * feat: Add e2e test for Settings modal This commit adds an e2e test to verify whether the Settings modal is displayed on the landing page. It uses a headless browser to navigate to the page and interacts with it to verify if the dialog and its components are visible. * test: Add Navigation and Settings tests Add Navigation and Settings tests to verify that the navigation bar and Settings button are visible and that the Settings modal displays the expected content. The settings modal verification includes checking whether the modal is visible, if the modal title, tab list, clear conversation button and theme are present, and if the theme option can be selected to change the mode. * Quick fix * feat(navbar): Add confirmation before clearing conversations Adding confirmation modal to prevent accidentally clearing conversations. Before, once you clicked on the "Clear" button it immediately clears all conversations. With this change, if you click on "Clear" the first time, it will change the text to "Confirm Clear" and if you click it again, it will clear all conversations. * Add click functionality to the navigation bar and improve UI design The code introduced click functionality to the nav bar and improved the user interface. It also used the new theme select feature to change the theme to dark. * test: Add test for dark mode theme change Refactor the test for Navigation suite to check for the 'dark' class in the HTML element when the 'dark' theme is selected in the modal. This ensures that the dark mode theme change works correctly, and improves test coverage. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Hotfix * Removed repetation * Refactor: Change text-gray-400 to text-white/50 to make tailwind more cleaner * style: Update CSS classes to improve the conversation UI - Update Conversation component to improve UX - Changed styling for group hover effect using shades of gray - Improved color contrast of the Message component for easy readability - Replaced class names in buildTree.js with a new class name - Added a new color theme (gray-1000) in tailwind.config to replace an old background color. * Refactor EndpointItem, EndpointItems, and NewConversationMenu for better user experience - The `EndpointItem` component now accepts an `isSelected` prop instead of `onSelect` to better reflect its usage in `EndpointItems` and `NewConversationMenu`. - `EndpointItems` component now has a `selectedEndpoint` prop to highlight the selected item in the list. - `NewConversationMenu` now has a gap between the endpoint options to improve user experience. * Added error messages * refactor: Improve endpoint menu highlighting and error handling In the UI, when the user selects an endpoint, the active class is now properly set. In the error handling function, `isJson` is now a private function called by `getError`, which provides better parsing of error messages, and returns more succinct messages upon encountering specific errors. Finally, a new end-to-end test has been added to check if the active class is properly set on selecting an endpoint in the new conversation menu. * test: Add Conversation and Change Path of Auth JSON In the Landing spec, test the functionality to create conversations and check that the number of items has increased. In the Popup spec, change the path of the Auth JSON used by the context. * Fixed logo issues * Make everything not rounded * Added time --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
2023-06-02 10:02:35 +05:30
expect(afterAdding).toBeGreaterThanOrEqual(beforeAdding);
Added Settings Modal (#342) * Improve UI with style changes and add Settings button - Improved the UI of the `Input` and `Message` components. - Added a `Settings` button to the `NavLinks` component. - Introduced a `Settings` component to handle user settings. - Refactored the `Dialog` component for consistency. * Revert not needed changes * Updated style.css to only work for select * feat: Remove Dark Mode component and add theme selection feature This commit removes the Dark Mode component from the navigation bar and replaces it with a theme selection dropdown menu in the Settings dialog. The implementation of the theme selection feature includes a function that allows the user to set the theme based on the system, light, or dark mode. * Add auto theme setting to Settings component. This commit adds a new state variable to keep track of whether the auto theme is enabled or not. It also registers an event listener to update the theme based on system preference changes. The event listener is removed when the component is unmounted. * Improve user experience by allowing customized themes - Create `selectedOption` state to track user-selected theme - Remove unused `isAutoTheme` state variable * feat(Nav): Add SVG icon to settings gear This commit adds an SVG icon to the settings gear in the Navigation component's Settings file. The new SVG icon replaces the previous GearIcon component. * refactor(ui): Update overlay background color This commit updates the background color of the overlay in the AlertDialog and Dialog components by changing the classes applied to the elements. The new color is a transition from `bg-black/50 backdrop-blur-sm` to `bg-gray-500/90 dark:bg-gray-800/90`. This change improves the readability of the dialog boxes. * Refactor ThemeContext to include system theme and fix bug in Settings The ThemeContext now includes a "system" theme and ClearConvos no longer relies on the "selected option" state to update the theme. The bug is now fixed if the system theme changes. * Refactor DialogTemplate styles and color scheme Adjusted the color scheme of the DialogTemplate component to dark mode, updated the background color to gray-900 and removed unnecessary classes. * Refactor: Change button logic to require confirmation before clearing convos This commit refactors the code by adding a confirmation dialog to prompt for a user's confirmation before clearing all conversations in the Settings.jsx file. The change ensures the user is aware of the irreversible action before initiating the clearConvos function. Additionally, the commit updates the clear chat button's class name and changes the button's onClick logic to call the confirmClearConvos function instead of directly invoking the clearConvos method. * Refactor component name to reflect functionality change. - Changed component name from ClearConvos to Settings to support potential future use cases. * Refactor conversation clearing functionality in `Settings.jsx` This commit optimizes the conversation clearing functionality in the `Settings.jsx` component by removing the `confirmClearConvos` function and directly calling the `clearConvos` function on confirmation. This change will simplify the code and improve the user experience. * Refactor Input component UI styles Simplify Input component styles by simplifying the gradient background, removing border color styles, and updating button styles. * feat: Add e2e test for Settings modal This commit adds an e2e test to verify whether the Settings modal is displayed on the landing page. It uses a headless browser to navigate to the page and interacts with it to verify if the dialog and its components are visible. * test: Add Navigation and Settings tests Add Navigation and Settings tests to verify that the navigation bar and Settings button are visible and that the Settings modal displays the expected content. The settings modal verification includes checking whether the modal is visible, if the modal title, tab list, clear conversation button and theme are present, and if the theme option can be selected to change the mode. * Quick fix * feat(navbar): Add confirmation before clearing conversations Adding confirmation modal to prevent accidentally clearing conversations. Before, once you clicked on the "Clear" button it immediately clears all conversations. With this change, if you click on "Clear" the first time, it will change the text to "Confirm Clear" and if you click it again, it will clear all conversations. * Add click functionality to the navigation bar and improve UI design The code introduced click functionality to the nav bar and improved the user interface. It also used the new theme select feature to change the theme to dark. * test: Add test for dark mode theme change Refactor the test for Navigation suite to check for the 'dark' class in the HTML element when the 'dark' theme is selected in the modal. This ensures that the dark mode theme change works correctly, and improves test coverage. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Improve navigation test clarity This commit improves code clarity and adds more detailed test assertions to the navigation suite. New assert statements are added to check whether the modal theme selection changes the theme and that the HTML element receives the 'dark' class. A new function `changeMode` was introduced to avoid code repetition. A short description was added to the commit message to adhere to best practices. * Hotfix * Removed repetation * Refactor: Change text-gray-400 to text-white/50 to make tailwind more cleaner * style: Update CSS classes to improve the conversation UI - Update Conversation component to improve UX - Changed styling for group hover effect using shades of gray - Improved color contrast of the Message component for easy readability - Replaced class names in buildTree.js with a new class name - Added a new color theme (gray-1000) in tailwind.config to replace an old background color. * Refactor EndpointItem, EndpointItems, and NewConversationMenu for better user experience - The `EndpointItem` component now accepts an `isSelected` prop instead of `onSelect` to better reflect its usage in `EndpointItems` and `NewConversationMenu`. - `EndpointItems` component now has a `selectedEndpoint` prop to highlight the selected item in the list. - `NewConversationMenu` now has a gap between the endpoint options to improve user experience. * Added error messages * refactor: Improve endpoint menu highlighting and error handling In the UI, when the user selects an endpoint, the active class is now properly set. In the error handling function, `isJson` is now a private function called by `getError`, which provides better parsing of error messages, and returns more succinct messages upon encountering specific errors. Finally, a new end-to-end test has been added to check if the active class is properly set on selecting an endpoint in the new conversation menu. * test: Add Conversation and Change Path of Auth JSON In the Landing spec, test the functionality to create conversations and check that the number of items has increased. In the Popup spec, change the path of the Auth JSON used by the context. * Fixed logo issues * Make everything not rounded * Added time --------- Co-authored-by: Danny Avila <110412045+danny-avila@users.noreply.github.com>
2023-06-02 10:02:35 +05:30
});
});