Skip to content

feat: add testing.ping_ipm_server message handler [#1488]

Marwan Zibaoui requested to merge 1488-ping-ipm-server-cmd into next

This MR adds a new message handler for a message containing the payload {type: "testing.ping_ipm_server"}.

This is a direct request from QA, where they need to be able to reset the IPM data during tests. I consider other ways to do this (e.g. enviornment variables) but decided to instead stick to existing patterns in the codebase and just execute what was asked of us.

Other solutions would have needed to introduce new patterns and i'd rather just stick to what we have now instead of kicking off an entire discussion on how we want to do this kind of things. I took inspiration from the existing "testing.getReadyState" message.

The way it works is:

  • We create a new message listener, i re-used existing message listener (Port)
  • When we receive the instruction to send a ping, we must make sure prefs have been loaded, as the sendPing function makes use of them
  • We have multiple example of sending a message to the background app in e2e tests: the basic idea is that we execute a script in an app page such as the option page where the web extension messaging API is available.

I tested the change manually and it works fine in both FF and Chrome. I did not write any unit test for this because:

  • We need to setup jest better for working with web extension API. It's something I actually successfully experimented with but I consider it out of scope for this MR
  • This will be used in test anyways, so there will be tests written making use of this codepath, and asserting that things are working correctly. In that sense I don't feel that unit tests are super necessary here.

Related to #1488 (closed)

Edited by Marwan Zibaoui

Merge request reports