wip
This commit is contained in:
@@ -2,6 +2,7 @@ import { Result } from '../../../shared/result/Result';
|
||||
import { CheckoutPrice } from '../../../domain/value-objects/CheckoutPrice';
|
||||
import { CheckoutState } from '../../../domain/value-objects/CheckoutState';
|
||||
import { CheckoutInfo } from '../../../application/ports/ICheckoutService';
|
||||
import { IRACING_SELECTORS } from './IRacingSelectors';
|
||||
|
||||
interface Page {
|
||||
locator(selector: string): Locator;
|
||||
@@ -14,14 +15,15 @@ interface Locator {
|
||||
}
|
||||
|
||||
export class CheckoutPriceExtractor {
|
||||
private readonly selector = '.wizard-footer a.btn:has(span.label-pill)';
|
||||
// Use the price action selector from IRACING_SELECTORS
|
||||
private readonly selector = IRACING_SELECTORS.BLOCKED_SELECTORS.priceAction;
|
||||
|
||||
constructor(private readonly page: Page) {}
|
||||
|
||||
async extractCheckoutInfo(): Promise<Result<CheckoutInfo>> {
|
||||
try {
|
||||
// Prefer the explicit pill element which contains the price
|
||||
const pillLocator = this.page.locator('span.label-pill');
|
||||
const pillLocator = this.page.locator('.label-pill, .label-inverse');
|
||||
const pillText = await pillLocator.first().textContent().catch(() => null);
|
||||
|
||||
let price: CheckoutPrice | null = null;
|
||||
@@ -68,7 +70,7 @@ export class CheckoutPriceExtractor {
|
||||
// Additional fallback: search the wizard-footer for any price text if pill was not present or parsing failed
|
||||
if (!price) {
|
||||
try {
|
||||
const footerLocator = this.page.locator('.wizard-footer').first();
|
||||
const footerLocator = this.page.locator('.wizard-footer, .modal-footer').first();
|
||||
const footerText = await footerLocator.textContent().catch(() => null);
|
||||
if (footerText) {
|
||||
const match = footerText.match(/\$\d+\.\d{2}/);
|
||||
|
||||
Reference in New Issue
Block a user