guidepup / setup

Setup your environment for screen reader test automation.
https://guidepup.dev
MIT License
5 stars 2 forks source link

feat: enable Do Not Disturb mode in CI env #2

Closed msereniti closed 1 year ago

msereniti commented 1 year ago

Problem

Sometimes tests are falling due to the the "Updates available" notifications that appear on macOS devices and catch focus of screen reader.

Solution

When --ci flag is provided, enable Do Not Disturb mode.

Enabling Do Not Disturb mode programmatically is not trivial – for macOS 11 it updates system defaults and restarts notification processes but for macOS 12 it opens System Preferences and toggles Focus Mode switch via applescript. That UI interactions are not ideal and might be unstable, but I have not found a better approach to deal with Focus mode.

Testing

I have added testing matrix to run setup on macos-11, macos-12 and macos-11 (right now it is macos-11) on every push and every month – it will notice maintainers if new macOS update break backward compatibility

cmorten commented 1 year ago

For Monterey have you looked into https://github.com/arodik/macos-focus-mode (the last comment on one of your linked threads) - it seems promising for MacOS 12 without needing to delve into UI scripting?

msereniti commented 1 year ago

For Monterey have you looked into https://github.com/arodik/macos-focus-mode (the last comment on one of your linked threads) - it seems promising for MacOS 12 without needing to delve into UI scripting?

Surely. This package uses macOS shortcuts mechanism that allows you to visually build scripts in Shorutcts app and than, when shortcut is installed, run any shortcut from the shell. The problem is that installing shortcut is only possible via UI interaction (calling installFocusModeShortcut() from mentioned package opens UI were "Install shortcut" button is present). So, as far as UI interactions seem to be inevitable I decided to use in to set focus mode directly instead of installing shortcut and then calling it.

I have macbooks both with Big Sur and Monterey, so if you have any other ideas I can test them locally.