mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-02-18 18:44:42 -05:00
- Resolves - https://github.com/Significant-Gravitas/AutoGPT/issues/10426 - Need to review this pr, once this issue is fixed - https://github.com/Significant-Gravitas/AutoGPT/issues/10404 I’ve created additional tests for the main page, divided into two parts: one for basic functionality and the other for edge cases. **Basic functionality:** - Users can access the marketplace page when logged out. - Users can access the marketplace page when logged in. - Featured agents, top agents, and featured creators are visible. - Users can navigate and interact with marketplace elements. - The complete search flow works correctly. **Edge cases:** - Searching for a non-existent item shows no results. ### Changes - Introduced a new test suite for the marketplace, covering basic functionality and edge cases. - Implemented the MarketplacePage class to encapsulate interactions with the marketplace page. - Added utility functions for assertions, including visibility checks and URL matching. - Enhanced the LoginPage class with a goto method for navigation. - Established a comprehensive search flow test to validate search functionality. #### For code changes: - [x] I have clearly listed my changes in the PR description - [x] I have made a test plan - [x] I have tested my changes according to the test plan: - [x] I have done all the tests and they are working perfectly --------- Co-authored-by: Nicholas Tindle <nicholas.tindle@agpt.co> Co-authored-by: Lluis Agusti <hi@llu.lu> Co-authored-by: Zamil Majdy <zamil.majdy@agpt.co> Co-authored-by: Ubbe <hi@ubbe.dev>
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import { Locator, Page, expect } from "@playwright/test";
|
|
|
|
export async function isVisible(el: Locator, timeout?: number) {
|
|
await expect(el).toBeVisible(timeout ? { timeout } : undefined);
|
|
}
|
|
|
|
export async function hasAttribute(
|
|
el: Locator,
|
|
label: string,
|
|
val: string | RegExp,
|
|
) {
|
|
await expect(el).toHaveAttribute(label, val);
|
|
}
|
|
|
|
export async function hasTextContent(el: Locator, text: string | RegExp) {
|
|
await expect(el).toContainText(text);
|
|
}
|
|
|
|
export async function isHidden(el: Locator, timeout?: number) {
|
|
await expect(el).toBeHidden(timeout ? { timeout } : undefined);
|
|
}
|
|
|
|
export async function hasUrl(
|
|
page: Page,
|
|
url: string | RegExp,
|
|
opts?: { decoded?: boolean },
|
|
) {
|
|
if (opts?.decoded) {
|
|
return expect(decodeURIComponent(page.url())).toBe(url);
|
|
}
|
|
|
|
await expect(page).toHaveURL(url);
|
|
}
|
|
|
|
export async function hasFieldValue(el: Locator, value: string | RegExp) {
|
|
await expect(el).toHaveValue(value);
|
|
}
|
|
|
|
export async function isDisabled(el: Locator) {
|
|
await expect(el).toBeDisabled();
|
|
}
|
|
|
|
export async function isEnabled(el: Locator) {
|
|
await expect(el).toBeEnabled();
|
|
}
|
|
|
|
export async function hasMinCount(el: Locator, minCount: number) {
|
|
const count = await el.count();
|
|
expect(count).toBeGreaterThanOrEqual(minCount);
|
|
}
|
|
|
|
export async function matchesUrl(page: Page, pattern: RegExp) {
|
|
expect(page.url()).toMatch(pattern);
|
|
}
|