fix: livechat tags.save rejected by response validation on edit (+ e2e deflakes and Playwright GitHub annotations)

Merged
GG
3mo ago
+50-30

Proposed changes (including videos or screenshots)

Fixes flaky patterns spotted in recent CI runs.

1. Omnichannel UI: save → reopen contextual bar race

Saving via the contextual bar closes it asynchronously once the save request resolves. Tests that clicked btnSave and immediately searched/reopened the panel could have the freshly reopened panel detached by the delayed close, making the next click retry until the test times out.

Example failure (CI run):

OC - Manage Agents [CE]- Edit and Remove › expect removing "user1" via sidebar
Test timeout of 60000ms exceeded.
locator.click: ... element was detached from the DOM, retrying
  • omnichannel-agents.spec.ts: use editAgent.save() (click + waitForDismissal) instead of raw btnSave.click() before reopening the agent info panel — same race already documented and worked around in the "Manage departments" test in this file.
  • omnichannel-tags.spec.ts: same, via editTag.save().
  • omnichannel-business-hours.spec.ts: no FlexTab here, so assert btnSave is gone after saving — same guard already used by the "Toggle BH active status" test in this file.

All remaining btnSave.click() call sites were audited: they are followed by assertions that implicitly wait for the save to take effect, so no race window.

2. Rooms API: username rename propagation (failure on this PR's run)

update group dms name tests waited a fixed sleep(300) for the rename to propagate to DM subscription names, which is not enough on slower runners (failed on FIPS). Replaced with a poll on subscriptions.getOne (up to ~5s).

3. E2EE file encryption: message sent before room key is ready (failure on this PR's run)

With E2E_Allow_Unencrypted_Messages on, sending right after opening a freshly created encrypted room can go out unencrypted if the room key is still being set up — the key icon assertion then fails. Added the same encryptionNotReadyIndicator guard the encryption-decryption spec already uses to the file-encryption spec's beforeEach.

4. Threads: first assertion after opening the thread panel (failure on another run)

Opening the thread contextual bar fetches the thread messages; on coverage-instrumented runners this can exceed the default 5s expect timeout while the panel still shows its loading state (confirmed via the run's trace screenshot). Extended the first content assertion to 15s in both tests of the hideFlexTab describe.

5. CI: Playwright github reporter

Enabled conditionally (GITHUB_ACTIONS === 'true'), so failed tests become check-run annotations — visible in the PR diff and queryable via gh api repos/.../check-runs/<job_id>/annotations — instead of requiring log archaeology.

6. Product bug: livechat/tags.save always failed response validation on edit (failure on this PR's run)

The dismissal wait added in item 1 exposed a real bug: BaseRaw.updateOne/insertOne mutate the update object via setUpdatedAt, so LivechatTag.createOrUpdateTag returned its local record with an injected _updatedAt. The tags.save response schema declares additionalProperties: false (its type intentionally omits _updatedAt), so every tag edit returned error-invalid-body 400 while the write itself succeeded — the UI kept the contextual bar open with an error toast, and the old test flow passed without ever saving anything (trace evidence: request payload correct, response 400 with the saved tag embedded in the error body).

Fixed by rebuilding the declared return shape in createOrUpdateTag instead of returning the mutated record. Changeset added.

Issue(s)

Steps to test or reproduce

Run the affected specs; the races are timing-dependent (reproduce under CI load):

yarn test:e2e tests/e2e/omnichannel/omnichannel-agents.spec.ts tests/e2e/omnichannel/omnichannel-tags.spec.ts tests/e2e/omnichannel/omnichannel-business-hours.spec.ts tests/e2e/e2e-encryption/e2ee-file-encryption.spec.ts

Further comments

Summary by CodeRabbit

  • Tests
    • Improved end-to-end reliability for omnichannel “Edit and Remove” flows by persisting edits through the save action and tightening post-save assertions.
    • Updated business-hours and tag-department scenarios to confirm the edit form dismisses and selection state updates before proceeding.
    • Strengthened end-to-end encryption coverage by waiting for room encryption readiness before validating messages and files.
    • Reduced flakiness in API room direct-message rename tests by polling for subscription updates instead of fixed delays.
    • Added a page-object helper to verify the currently selected department during tag editing.
  • Chores / Configuration
    • Enabled the GitHub test reporter automatically when running in GitHub Actions.

Task: ARCH-2291