Skip to content

test(calendar): e2e for task-modal translation + fix two translate-feature bugs#987

Merged
renemadsen merged 1 commit into
stablefrom
feat/calendar-translation-e2e
Jun 8, 2026
Merged

test(calendar): e2e for task-modal translation + fix two translate-feature bugs#987
renemadsen merged 1 commit into
stablefrom
feat/calendar-translation-e2e

Conversation

@renemadsen

Copy link
Copy Markdown
Member

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 hookdotnet-core-pr.yml / dotnet-core-master.yml

  • The backend docker run gains "/api-key=FAKE_TRANSLATE_E2E". The frontend TranslationService (already merged to eform-angular-frontend stable) 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 fixestask-create-edit-modal.component.ts

  1. Translate icon never appeared in the calendar. Active languages were read from the appSettings.languagesModel ngrx store, which is only populated by the settings/profile/device-users pages — empty in the calendar flow — so recomputeTargetLanguages() could never resolve a target and the icon stayed hidden. Now fetched directly via AppSettingsStateService.getLanguages() (mirrors the device-users modal).
  2. Edit mode hid saved translations. recomputeTargetLanguages() collapsed the per-language fields whenever the target set was momentarily empty — which happens in edit mode because the assignee's valueChanges fires before the async languages list loads — and never re-expanded. Now re-expands when a current target language already has text in titleByLang/descByLang.

New e2em/calendar-translation.spec.ts (3 serial tests)

  • Seeds a property with a Deutsch and a Dansk worker.
  • Icon visibility: hidden for Danish-only, shown when a Deutsch worker is assigned.
  • Auto-fill + save + edit-prefill: clicking translate auto-fills the Deutsch fields from the sentinel backend, the create POST 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

…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>
Copilot AI review requested due to automatic review settings June 8, 2026 13:27

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 checking res.success. Elsewhere in the plugin, AppSettingsStateService.getLanguages() is typically gated by data.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');
@renemadsen renemadsen merged commit 3dc0e63 into stable Jun 8, 2026
27 checks passed
@renemadsen renemadsen deleted the feat/calendar-translation-e2e branch June 8, 2026 13:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants