test(calendar): e2e for task-modal translation + fix two translate-feature bugs#987
Merged
Merged
Conversation
…ature bugs Add a Playwright e2e covering the calendar task-modal translation feature and fix two bugs that kept it from working in the calendar flow. CI/test hook: the backend docker run gains "/api-key=FAKE_TRANSLATE_E2E"; the (already-merged) frontend TranslationService short-circuits that sentinel to return deterministic "[<lang>] <text>" so the translate flow is testable without a real Google Translate key. Fixes in task-create-edit-modal.component.ts: - Active languages were read from the appSettings.languagesModel store, which is only populated by the settings/profile pages (empty in the calendar flow), so the translate icon never appeared. Fetch via AppSettingsStateService.getLanguages() instead (mirrors the device-users modal). - recomputeTargetLanguages() collapsed the per-language fields whenever the target set was momentarily empty (edit mode: assignee valueChanges fires before the async languages list loads) and never re-expanded, hiding saved translations. Re-expand when a current target language already has text. e2e spec (m/calendar-translation.spec.ts): seeds a property with Deutsch + Dansk workers; asserts the icon is hidden for Danish-only and shown for a Deutsch assignee; and asserts auto-fill + save persists translates[] with the Danish (languageId 1) source and Deutsch (languageId 3) "[de-DE] ..." values, and that the edit modal prefills the Deutsch field. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR adds end-to-end coverage for the calendar task create/edit modal’s translation feature and fixes two issues that prevented the translation UI/behavior from working correctly in the actual calendar flow (not just settings-driven flows). It also adjusts CI container startup to provide a sentinel API key so translation behavior can be exercised deterministically in automated tests.
Changes:
- Calendar modal: load active languages via
AppSettingsStateService.getLanguages()(instead of relying on an app-settings store slice that may be unpopulated in the calendar flow). - Calendar modal: ensure translated fields re-expand in edit mode when saved translations exist but the initial language resolution pass temporarily yields an empty target set.
- Playwright: add a serial e2e suite validating translate-icon visibility, deterministic auto-translation, request payload contents, and edit-mode prefill; update CI container start args to include the sentinel API key.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar/modals/task-create-edit-modal/task-create-edit-modal.component.ts | Fixes language-resolution source for the translate feature and improves edit-mode translated-field expansion behavior. |
| eform-client/playwright/e2e/plugins/backend-configuration-pn/m/calendar-translation.spec.ts | Adds Playwright coverage for calendar task-modal translation (visibility, auto-fill, payload, edit prefill). |
| .github/workflows/dotnet-core-pr.yml | Passes a sentinel /api-key=FAKE_TRANSLATE_E2E argument to the container in PR CI runs for deterministic translation behavior. |
| .github/workflows/dotnet-core-master.yml | Passes a sentinel /api-key=FAKE_TRANSLATE_E2E argument to the container in master CI runs for deterministic translation behavior. |
Comments suppressed due to low confidence (1)
eform-client/src/app/plugins/modules/backend-configuration-pn/modules/calendar/modals/task-create-edit-modal/task-create-edit-modal.component.ts:259
getLanguages()results are used without checkingres.success. Elsewhere in the plugin,AppSettingsStateService.getLanguages()is typically gated bydata.success && data.model(e.g. task-tracker-container.component.ts:492-498) to avoid silently treating failed calls as empty/partial data.
this.appSettingsStateService.getLanguages().pipe(take(1)).subscribe(res => {
this.activeLanguages = (res?.model?.languages ?? [])
.filter(l => l.isActive)
.map(l => ({id: l.id, code: l.languageCode, name: l.name}));
this.recomputeTargetLanguages();
});
Comment on lines
+235
to
+237
| const saveBtn = page.locator('#calendarEventSaveBtn'); | ||
| await saveBtn.scrollIntoViewIfNeeded(); | ||
| await saveBtn.dispatchEvent('click'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Playwright e2e for the calendar task-modal translation feature and fixes two bugs that kept it from working in the real calendar flow (the feature was merged earlier but never functioned outside the settings pages).
Changes
Test/CI hook —
dotnet-core-pr.yml/dotnet-core-master.ymldocker rungains"/api-key=FAKE_TRANSLATE_E2E". The frontendTranslationService(already merged toeform-angular-frontendstable) short-circuits this sentinel key and returns deterministic"[<targetLang>] <sourceText>"instead of calling Google Translate — so the translate flow is testable in CI without a real API key.Bug fixes —
task-create-edit-modal.component.tsappSettings.languagesModelngrx store, which is only populated by the settings/profile/device-users pages — empty in the calendar flow — sorecomputeTargetLanguages()could never resolve a target and the icon stayed hidden. Now fetched directly viaAppSettingsStateService.getLanguages()(mirrors the device-users modal).recomputeTargetLanguages()collapsed the per-language fields whenever the target set was momentarily empty — which happens in edit mode because the assignee'svalueChangesfires before the async languages list loads — and never re-expanded. Now re-expands when a current target language already has text intitleByLang/descByLang.New e2e —
m/calendar-translation.spec.ts(3 serial tests)translates[]carries the Danish (languageId 1) source and the Deutsch (languageId 3)"[de-DE] ..."values, and reopening in edit mode prefills the Deutsch field.Validation
All three tests pass locally against a backend started with the sentinel key. The two component fixes were also manually verified in the running app.
🤖 Generated with Claude Code