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,5 +1,5 @@
import { expect, test } from "@playwright/test";
import uaParser from "ua-parser-js";
import { awaitBootstrapTest } from "../../utils/await-bootstrap-test";
test(
"user must be able to interact with table input component",
@ -7,39 +7,12 @@ test(
tag: ["@release", "@workspace"],
},
async ({ page }) => {
await page.goto("/");
await page.waitForSelector('[data-testid="mainpage_title"]', {
timeout: 30000,
});
await page.waitForSelector('[id="new-project-btn"]', {
timeout: 30000,
});
let modalCount = 0;
try {
const modalTitleElement = await page?.getByTestId("modal-title");
if (modalTitleElement) {
modalCount = await modalTitleElement.count();
}
} catch (error) {
modalCount = 0;
}
const randomText = Math.random().toString(36).substring(7);
const secondRandomText = Math.random().toString(36).substring(7);
const thirdRandomText = Math.random().toString(36).substring(7);
const getUA = await page.evaluate(() => navigator.userAgent);
const userAgentInfo = uaParser(getUA);
await awaitBootstrapTest(page);
while (modalCount === 0) {
await page.getByText("New Flow", { exact: true }).click();
await page.waitForSelector('[data-testid="modal-title"]', {
timeout: 3000,
});
modalCount = await page.getByTestId("modal-title")?.count();
}
await page.waitForSelector('[data-testid="blank-flow"]', {
timeout: 30000,
});