test: Add utility functions to streamline test setup and improve maintainability (#5168)

* change tests to use utils libs

* 🔧 (frontend): add data-testid attribute to buttons in baseModal and secretKeyModal components
🔧 (frontend): add data-testid attribute to buttons in various test files for improved testing
🔧 (frontend): refactor awaitBootstrapTest function to remove skipNewFlow option and improve modal handling

* ✅ (userSettings.spec.ts): add a 1-second timeout before checking for the "Please save" text to ensure it is rendered on the page before interacting with it

* ✅ (userSettings.spec.ts): add comment to clarify waiting for API key creation to complete before proceeding to the next form element

* ✨ (freeze-path.spec.ts): refactor adjustScreenView function to accept a parameter for the number of zoom outs to perform, improving flexibility and reusability in test scenarios.
🔧 (freeze-path.spec.ts): replace adjustScreenView function with initialGPTsetup function for setting up initial GPT configuration in the test scenario.
This commit is contained in:
Cristhian Zanforlin Lousa 2024-12-09 17:30:56 -03:00 • committed by GitHub
commit ab68e13493
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
94 changed files with 344 additions and 3058 deletions

View file

@ -1,8 +1,16 @@
import { Page } from "playwright/test";
export async function adjustScreenView(page: Page) {
export async function adjustScreenView(
page: Page,
{
numberOfZoomOut = 3,
}: {
numberOfZoomOut?: number;
} = {},
) {
await page.getByTestId("fit_view").click();
await page.getByTestId("zoom_out").click();
await page.getByTestId("zoom_out").click();
await page.getByTestId("zoom_out").click();
for (let i = 0; i < numberOfZoomOut; i++) {
await page.getByTestId("zoom_out").click();
}
}

View file

@ -1,6 +1,15 @@
import { Page } from "playwright/test";
export const awaitBootstrapTest = async (page: Page) => {
export const awaitBootstrapTest = async (
page: Page,
options?: {
skipGoto?: boolean;
},
) => {
if (!options?.skipGoto) {
await page.goto("/");
}
await page.waitForSelector('[data-testid="mainpage_title"]', {
timeout: 30000,
});