Files
automaker/apps/app/tests/utils/helpers/concurrency.ts
Kacper 0b1123e3ce refactor: restructure test utilities and enhance context view tests
- Refactored test utilities by consolidating and organizing helper functions into dedicated modules for better maintainability and clarity.
- Introduced new utility functions for interactions, waiting, and element retrieval, improving the readability of test cases.
- Updated context view tests to utilize the new utility functions, enhancing test reliability and reducing code duplication.
- Removed deprecated utility functions and ensured all tests are aligned with the new structure.
2025-12-15 02:40:09 +01:00

51 lines
1.4 KiB
TypeScript

import { Page, Locator } from "@playwright/test";
/**
* Get the concurrency slider container
*/
export async function getConcurrencySliderContainer(
page: Page
): Promise<Locator> {
return page.locator('[data-testid="concurrency-slider-container"]');
}
/**
* Get the concurrency slider
*/
export async function getConcurrencySlider(page: Page): Promise<Locator> {
return page.locator('[data-testid="concurrency-slider"]');
}
/**
* Get the displayed concurrency value
*/
export async function getConcurrencyValue(page: Page): Promise<string | null> {
const valueElement = page.locator('[data-testid="concurrency-value"]');
return await valueElement.textContent();
}
/**
* Change the concurrency slider value by clicking on the slider track
*/
export async function setConcurrencyValue(
page: Page,
targetValue: number,
min: number = 1,
max: number = 10
): Promise<void> {
const slider = page.locator('[data-testid="concurrency-slider"]');
const sliderBounds = await slider.boundingBox();
if (!sliderBounds) {
throw new Error("Concurrency slider not found or not visible");
}
// Calculate position for target value
const percentage = (targetValue - min) / (max - min);
const targetX = sliderBounds.x + sliderBounds.width * percentage;
const centerY = sliderBounds.y + sliderBounds.height / 2;
// Click at the target position to set the value
await page.mouse.click(targetX, centerY);
}