refactor(clickTtPlayerRegistrationService): enhance search form handling and error reporting

- Updated the _fillSearchForm method to include trace logging and improved error handling for missing search forms, ensuring better feedback during the registration process.
- Enhanced the _openApplicationEntry method to streamline application entry checks and improve error messaging for missing elements, contributing to a more robust registration flow.
This commit is contained in:
Torsten Schulz (local)
2026-03-11 16:25:34 +01:00
parent cf376a8f68
commit 6a18d4ce0f

View File

@@ -102,7 +102,7 @@ class ClickTtPlayerRegistrationService {
await this._openAuthenticatedClickTt(page, { username, password, trace });
await this._selectClubContext(page, associationMemberNumber, trace);
await this._openApplicationEntry(page, trace);
await this._fillSearchForm(page, memberJson);
await this._fillSearchForm(page, memberJson, trace);
await this._clickByText(page, 'Personen suchen', trace);
await page.waitForLoadState('domcontentloaded');
@@ -318,6 +318,10 @@ class ClickTtPlayerRegistrationService {
async _openApplicationEntry(page, trace) {
await this._dismissConsentOverlays(page, trace);
if (await page.locator('form.search-query').count()) {
return true;
}
const labels = [
'Spielberechtigungen beantragen',
'Spielberechtigungen'
@@ -326,11 +330,28 @@ class ClickTtPlayerRegistrationService {
for (const label of labels) {
if (await this._hasTextTarget(page, label)) {
await this._clickByText(page, label, trace);
return true;
await page.waitForLoadState('domcontentloaded');
await this._dismissConsentOverlays(page, trace);
break;
}
}
throw new HttpError('Click-TT-Element nicht gefunden: Spielberechtigungen', 500);
if (await page.locator('form.search-query').count()) {
return true;
}
if (await this._hasTextTarget(page, 'Spielberechtigungen beantragen...')) {
await this._clickByText(page, 'Spielberechtigungen beantragen...', trace);
await page.waitForLoadState('domcontentloaded');
await this._dismissConsentOverlays(page, trace);
return true;
}
if (await page.locator('form.search-query').count()) {
return true;
}
throw new HttpError('Click-TT-Element nicht gefunden: Spielberechtigungen / Spielberechtigungen beantragen...', 500);
}
async _selectClubContext(page, associationMemberNumber, trace) {
@@ -356,13 +377,17 @@ class ClickTtPlayerRegistrationService {
return false;
}
async _fillSearchForm(page, member) {
await this._fillFirstAvailable(page, [
'input[name*=".1"]',
'input[type="text"]'
], member.lastName);
await this._fillNthTextInput(page, 1, member.firstName);
await this._fillNthTextInput(page, 2, formatGermanDate(member.birthDate));
async _fillSearchForm(page, member, trace) {
const searchForm = page.locator('form.search-query').first();
if (!(await searchForm.count())) {
throw new HttpError('Click-TT-Suchformular für Spielberechtigungen nicht gefunden', 500);
}
this._trace(trace, 'step', { name: 'fill-search-form' });
await searchForm.locator('input[name$=".1"]').first().fill(member.lastName);
await searchForm.locator('input[name$=".3"]').first().fill(member.firstName);
await searchForm.locator('input[name$=".5"]').first().fill(formatGermanDate(member.birthDate));
}
async _fillApplicationForm(page, member, email) {