Files
proffesor-for-testing__agen…/tests/e2e/pages/BasePage.ts
Profa 2253d05618 feat: flatten project structure — archive v2, promote v3 to root
Remove the nested v3/ subdirectory by moving all active source code,
tests, configs, and assets directly to the project root. Archive v2/
(dead code, 847MB) to v2-archive.tar.gz.

Key changes:
- Move v3/src/ → src/, v3/tests/ → tests/, v3/packages/ → packages/
- Move v3/tsconfig.json, v3/vitest.config.ts to root
- Merge v3/package.json into root package.json (ESM, scripts, deps, exports)
- Merge v3/scripts/ into scripts/, v3/implementation/ into docs/implementation/
- Update all CI workflows to remove "cd v3 &&" and v3/ path prefixes
- Fix all init installer path resolution (3-level-up → 2-level-up)
- Fix hooks to use "node ./dist/cli/bundle.js" instead of bare "aqe"
- Update settings.json ADR/DDD directories to docs/implementation/
- Fix helper scripts (statusline, adr-compliance, ddd-tracker, guidance-hooks)
- Update 58 agent definitions: aqe/v3/ → aqe/ memory namespaces
- Update 15 guidance shards: v3/src/ → src/ path references
- Fix sync interfaces: remove v3/ and v2/ path references
- Fix test path calculations (process.cwd() + '..' no longer needed)
- Fix flaky perf test threshold (500ms → 1000ms for CI environments)
- Fix complexity-analyzer test to match ADR-051 keyword-based eligibility

Build passes, 17,901 tests pass, CLI and MCP bundles verified.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 11:35:41 +00:00

160 lines
4.0 KiB
TypeScript

import { Page, Locator, expect } from '@playwright/test';
/**
* Base Page Object Model
* Provides common functionality for all page objects
*
* Generated by: qe-queen-coordinator
* Pattern: Page Object Model with Shopify theme selectors
*/
export class BasePage {
readonly page: Page;
// Common Shopify theme selectors
readonly header: Locator;
readonly footer: Locator;
readonly cartIcon: Locator;
readonly cartCount: Locator;
readonly searchLink: Locator;
readonly loginLink: Locator;
readonly logo: Locator;
readonly navigationMenu: Locator;
constructor(page: Page) {
this.page = page;
// Header elements - Shopify Sauce theme selectors
this.header = page.locator('header, #header, .site-header');
this.footer = page.locator('footer, #footer, .site-footer');
this.cartIcon = page.locator('[href="/cart"], .cart-link, #cart-icon');
this.cartCount = page.locator('.cart-count, .cart-item-count, [data-cart-count]');
this.searchLink = page.locator('[href="/search"], .search-link, [data-search]');
this.loginLink = page.locator('[href="/account/login"], .account-link');
this.logo = page.locator('.site-logo, .header-logo, [data-logo]');
this.navigationMenu = page.locator('nav, .main-nav, .site-nav');
}
/**
* Navigate to a specific path
*/
async goto(path: string = '/') {
await this.page.goto(path, { waitUntil: 'domcontentloaded' });
}
/**
* Wait for page to be fully loaded
*/
async waitForPageLoad() {
await this.page.waitForLoadState('networkidle');
}
/**
* Get current URL
*/
async getCurrentUrl(): Promise<string> {
return this.page.url();
}
/**
* Get page title
*/
async getPageTitle(): Promise<string> {
return this.page.title();
}
/**
* Navigate to cart
*/
async goToCart() {
await this.cartIcon.click();
await this.page.waitForURL('**/cart');
}
/**
* Navigate to login page
*/
async goToLogin() {
await this.loginLink.click();
await this.page.waitForURL('**/account/login');
}
/**
* Get cart item count from header
*/
async getCartItemCount(): Promise<number> {
const countText = await this.cartCount.textContent();
if (!countText) return 0;
const match = countText.match(/\d+/);
return match ? parseInt(match[0], 10) : 0;
}
/**
* Take a screenshot with descriptive name
*/
async takeScreenshot(name: string) {
await this.page.screenshot({
path: `test-results/screenshots/${name}.png`,
fullPage: true
});
}
/**
* Wait for element to be visible
*/
async waitForElement(selector: string, timeout: number = 10000) {
await this.page.locator(selector).waitFor({
state: 'visible',
timeout
});
}
/**
* Check if element exists on page
*/
async elementExists(selector: string): Promise<boolean> {
const count = await this.page.locator(selector).count();
return count > 0;
}
/**
* Scroll to bottom of page
*/
async scrollToBottom() {
await this.page.evaluate(() => {
window.scrollTo(0, document.body.scrollHeight);
});
}
/**
* Accept cookies if banner present
*/
async acceptCookiesIfPresent() {
const cookieBanner = this.page.locator('[data-cookie-banner], .cookie-banner, #cookie-consent');
if (await cookieBanner.isVisible({ timeout: 2000 }).catch(() => false)) {
const acceptButton = cookieBanner.locator('button, [data-accept]').first();
if (await acceptButton.isVisible()) {
await acceptButton.click();
}
}
}
/**
* Verify page loaded without errors
*/
async verifyNoErrors() {
const errors: string[] = [];
this.page.on('pageerror', (error) => {
errors.push(error.message);
});
await this.page.waitForLoadState('load');
if (errors.length > 0) {
console.warn('Page errors detected:', errors);
}
return errors;
}
}