Skip to content

Add unit tests for lookupTranslation and maskChannelStringsWithIdentifiers notification logic#3965

Merged
stephenhand merged 4 commits intoCHI-3736-mask_notificationsfrom
copilot/sub-pr-3964
Feb 26, 2026
Merged

Add unit tests for lookupTranslation and maskChannelStringsWithIdentifiers notification logic#3965
stephenhand merged 4 commits intoCHI-3736-mask_notificationsfrom
copilot/sub-pr-3964

Conversation

Copy link
Contributor

Copilot AI commented Feb 26, 2026

Addresses review feedback on #3964. Adds missing unit tests for two new methods introduced in that PR.

Description

  • translations/index.test.ts: Added lookupTranslation test suite covering:

    • Returns compiled string from Manager.strings[code] when key exists
    • Falls back to using code itself as the Handlebars template when key is absent
    • Correctly interpolates parameters into the template
    • Mocks @twilio/flex-ui Manager.getInstance() and sets up global.Handlebars via the real handlebars package
  • maskIdentifiers/index.test.ts: Added coverage for notification masking logic as part of maskChannelStringsWithIdentifiers (since maskNotifications is a private function called internally):

    • Verifies NewChatMessage override handler is registered when VIEW_IDENTIFIERS is denied
    • Verifies the override handler sets notification.options.browser.title via lookupTranslation('BrowserNotification-ChatMessage-MaskedTitle')
    • Verifies notification override is absent when VIEW_IDENTIFIERS is granted
    • Added module-level mocks for ../../translations and @twilio/flex-ui (NotificationIds, Manager, DefaultTaskChannels) to avoid hrmConfig import chain failures in the test environment

Checklist

  • Corresponding issue has been opened
  • New tests added
  • Feature flags added
  • Strings are localized
  • Tested for chat contacts
  • Tested for call contacts

Other Related Issues

Original PR: #3964

Verification steps

Run node_modules/.bin/jest --testPathPattern="(translations|maskIdentifiers)/index" in plugin-hrm-form — all 29 tests should pass.

AFTER YOU MERGE

  1. Cut a release tag using the Github workflow. Wait for it to complete and notify in the #aselo-deploys Slack channel.
  2. Comment on the ticket with the release tag version AND any additional instructions required to configure an environment to test the changes.
  3. Only then move the ticket into the QA column in JIRA

You are responsible for ensuring the above steps are completed. If you move a ticket into QA without advising what version to test, the QA team will assume the latest tag has the changes. If it does not, the following confusion is on you! :-P


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Copilot AI changed the title [WIP] Add and update unit tests for masking identifiers Add unit tests for lookupTranslation and maskNotifications Feb 26, 2026
Copy link
Collaborator

@stephenhand stephenhand left a comment

Choose a reason for hiding this comment

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

maskNotifications is now a private function called by maskChannelStringsWithIdentifiers, update the unit tests to test the maskNotifications functionality as part of the maskChannelStringsWithIdentifiers functiob rather than calling it directly

…escribe block

Co-authored-by: stephenhand <1694716+stephenhand@users.noreply.github.com>
Copy link
Contributor Author

Copilot AI commented Feb 26, 2026

maskNotifications is now a private function called by maskChannelStringsWithIdentifiers, update the unit tests to test the maskNotifications functionality as part of the maskChannelStringsWithIdentifi...

Done in 85f01a7. Removed the standalone maskNotifications describe block and its direct import — the notification behavior is now tested exclusively through maskChannelStringsWithIdentifiers.

Copilot AI changed the title Add unit tests for lookupTranslation and maskNotifications Add unit tests for lookupTranslation and maskChannelStringsWithIdentifiers notification logic Feb 26, 2026
@stephenhand stephenhand marked this pull request as ready for review February 26, 2026 16:36
@stephenhand stephenhand merged commit 7c7a0b2 into CHI-3736-mask_notifications Feb 26, 2026
26 checks passed
@stephenhand stephenhand deleted the copilot/sub-pr-3964 branch February 26, 2026 16:37
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