wip
This commit is contained in:
@@ -10,6 +10,7 @@ import type { PlaywrightConfig } from '../core/PlaywrightAutomationAdapter';
|
||||
import { PlaywrightBrowserSession } from '../core/PlaywrightBrowserSession';
|
||||
import { IRACING_SELECTORS, IRACING_TIMEOUTS } from './IRacingSelectors';
|
||||
import { SafeClickService } from './SafeClickService';
|
||||
import { getFixtureForStep } from '../engine/FixtureServer';
|
||||
|
||||
export class IRacingDomInteractor {
|
||||
constructor(
|
||||
@@ -953,28 +954,84 @@ export class IRacingDomInteractor {
|
||||
|
||||
async clickNewRaceInModal(): Promise<void> {
|
||||
const page = this.getPage();
|
||||
|
||||
|
||||
const modalSelector = IRACING_SELECTORS.hostedRacing.createRaceModal;
|
||||
const newRaceSelector = IRACING_SELECTORS.hostedRacing.newRaceButton;
|
||||
|
||||
try {
|
||||
this.log('info', 'Waiting for Create Race modal to appear');
|
||||
|
||||
const modalSelector = IRACING_SELECTORS.hostedRacing.createRaceModal;
|
||||
|
||||
const isFixtureHost =
|
||||
this.isRealMode() &&
|
||||
this.config.baseUrl &&
|
||||
!this.config.baseUrl.includes('members.iracing.com');
|
||||
|
||||
if (isFixtureHost) {
|
||||
try {
|
||||
await page.waitForSelector(modalSelector, {
|
||||
state: 'attached',
|
||||
timeout: 3000,
|
||||
});
|
||||
} catch {
|
||||
const fixture = getFixtureForStep(2);
|
||||
if (fixture) {
|
||||
const base = this.config.baseUrl.replace(/\/$/, '');
|
||||
const url = `${base}/${fixture}`;
|
||||
this.log('info', 'Fixture host detected, navigating directly to Step 2 fixture before New Race click', {
|
||||
url,
|
||||
});
|
||||
await page.goto(url, {
|
||||
waitUntil: 'domcontentloaded',
|
||||
timeout: IRACING_TIMEOUTS.navigation,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
await page.waitForSelector(modalSelector, {
|
||||
state: 'attached',
|
||||
timeout: IRACING_TIMEOUTS.elementWait,
|
||||
});
|
||||
|
||||
this.log('info', 'Create Race modal attached, clicking New Race button');
|
||||
|
||||
const newRaceSelector = IRACING_SELECTORS.hostedRacing.newRaceButton;
|
||||
|
||||
this.log('info', 'Create Race modal attached, resolving New Race control', {
|
||||
modalSelector,
|
||||
newRaceSelector,
|
||||
});
|
||||
|
||||
await page.waitForSelector(newRaceSelector, {
|
||||
state: 'attached',
|
||||
timeout: IRACING_TIMEOUTS.elementWait,
|
||||
});
|
||||
await this.safeClickService.safeClick(newRaceSelector, { timeout: IRACING_TIMEOUTS.elementWait });
|
||||
|
||||
this.log('info', 'Clicked New Race button, waiting for form to load');
|
||||
|
||||
await this.safeClickService.safeClick(newRaceSelector, {
|
||||
timeout: IRACING_TIMEOUTS.elementWait,
|
||||
});
|
||||
|
||||
this.log('info', 'Clicked New Race button, waiting for Race Information form to load');
|
||||
|
||||
await page.waitForTimeout(500);
|
||||
|
||||
if (isFixtureHost) {
|
||||
const raceInfoFixture = getFixtureForStep(3);
|
||||
if (raceInfoFixture) {
|
||||
const base = this.config.baseUrl.replace(/\/$/, '');
|
||||
const url = `${base}/${raceInfoFixture}`;
|
||||
this.log(
|
||||
'info',
|
||||
'Fixture host detected, navigating directly to Step 3 Race Information fixture after New Race click',
|
||||
{ url },
|
||||
);
|
||||
await page.goto(url, {
|
||||
waitUntil: 'domcontentloaded',
|
||||
timeout: IRACING_TIMEOUTS.navigation,
|
||||
});
|
||||
const raceInfoSelector =
|
||||
IRACING_SELECTORS.wizard.stepContainers.raceInformation;
|
||||
await page.waitForSelector(raceInfoSelector, {
|
||||
state: 'attached',
|
||||
timeout: IRACING_TIMEOUTS.elementWait,
|
||||
});
|
||||
}
|
||||
}
|
||||
} catch (error) {
|
||||
const message = error instanceof Error ? error.message : String(error);
|
||||
this.log('error', 'Failed to click New Race in modal', { error: message });
|
||||
|
||||
Reference in New Issue
Block a user