feat(clickTtTournamentRegistrationService): implement competition registration saving logic
- Added a new method `_saveCompetitionRegistration` to handle the saving of competition registrations, improving code organization and readability. - Replaced direct calls to clickTtPlayerRegistrationService for saving with the new method, enhancing maintainability. - Implemented error handling to verify successful registration and provide feedback if the registration confirmation is not displayed.
This commit is contained in:
@@ -161,8 +161,7 @@ class ClickTtTournamentRegistrationService {
|
||||
await this._selectCompetitionMembers(page, group.entries, trace);
|
||||
await this._openControlStep(page, trace);
|
||||
await this._verifyControlPage(page, group.entries);
|
||||
await clickTtPlayerRegistrationService._clickByText(page, 'Speichern', trace);
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
await this._saveCompetitionRegistration(page, group.entries, trace);
|
||||
|
||||
for (const entry of group.entries) {
|
||||
entry.registered = true;
|
||||
@@ -469,6 +468,24 @@ class ClickTtTournamentRegistrationService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async _saveCompetitionRegistration(page, entries, trace) {
|
||||
await clickTtPlayerRegistrationService._clickByText(page, 'Speichern', trace);
|
||||
await page.waitForLoadState('domcontentloaded');
|
||||
|
||||
const bodyText = normalizeText(await page.locator('body').innerText().catch(() => ''));
|
||||
const stillOnControlPage = bodyText.includes('folgende spieler werden zum turnier angemeldet')
|
||||
|| bodyText.includes('turnier-teilnehmeranmeldung')
|
||||
|| await page.locator('input[type="submit"][value="Speichern"]').count().catch(() => 0);
|
||||
|
||||
if (stillOnControlPage) {
|
||||
const expectedNames = entries.map((entry) => `${entry.member.firstName} ${entry.member.lastName}`);
|
||||
throw new HttpError(
|
||||
`Click-TT-Turnieranmeldung wurde nach "Speichern" nicht bestätigt: ${expectedNames.join(', ')}`,
|
||||
500
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default new ClickTtTournamentRegistrationService();
|
||||
|
||||
Reference in New Issue
Block a user