Skip to content

Commit

Permalink
CI: Kiosk mode (#319)
Browse files Browse the repository at this point in the history
* CI: Checkout the correct commit, allow manually running the workflow and use Firefox kiosk mode

- When the workflows were separated, the workflows that were started from other workflows all checked out the code of the main branch. The behavior was changed so that they checkout the same commit
- There was also a check to see if the workflow that initiated the integration tests was successful. If you start that workflow manually, this check failed so the workflow was skipped. This was fixed so now all workflows can get started manually
- Firefox has a kiosk mode to start Firefox maximized and don't allow closing it as easily. This is used in the tests to simplify the code and make them more robust
  • Loading branch information
pentamassiv authored Sep 7, 2024
1 parent 26f871d commit 8ddf90d
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/failing_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ jobs:
if: runner.os == 'Linux' # This step is only needed on Linux. The other OSs don't need to be set up
uses: ./.github/actions/headless_display

- name: Install Firefox on macOS
if: runner.os == 'macOS'
run: brew install --cask firefox

- name: Run the ignored unit tests
run: cargo test unit --no-default-features --features ${{ matrix.features }} -- --ignored --test-threads=1 --nocapture

Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ jobs:
if: runner.os == 'Linux' # This step is only needed on Linux. The other OSs don't need to be set up
uses: ./.github/actions/headless_display

- name: Install Firefox on macOS
if: runner.os == 'macOS'
run: brew install --cask firefox

- name: Run integration tests in release mode
if: matrix.features != 'wayland' && matrix.features != 'libei' && matrix.features != 'libei,wayland,xdo,x11rb' # On Linux, the integration tests only work with X11 for now
run: cargo test integration --release --no-default-features --features ${{ matrix.features }} -- --test-threads=1 --nocapture --include-ignored
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,10 @@ jobs:
if: runner.os == 'Linux' # This step is only needed on Linux. The other OSs don't need to be set up
uses: ./.github/actions/headless_display

- name: Install Firefox on macOS
if: runner.os == 'macOS'
run: brew install --cask firefox

- name: Run the unit tests
run: cargo test unit --no-default-features --features ${{ matrix.features }} -- --test-threads=1 --nocapture

Expand Down
10 changes: 5 additions & 5 deletions tests/common/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ pub static BROWSER_INSTANCE: std::sync::LazyLock<Option<std::process::Child>> =
let child = if cfg!(target_os = "windows") {
// On Windows, use cmd.exe to run the "start" command
std::process::Command::new("cmd")
.args(["/C", "start", "firefox", &url])
.args(["/C", "start", "firefox", "--kiosk", &url])
.spawn()
.expect("Failed to start Firefox on Windows")
} else if cfg!(target_os = "macos") {
// On macOS, use the "open" command to run Safari (Firefox is not preinstalled)
// On macOS, use the "open" command to run Firefox
std::process::Command::new("open")
.args(["-a", "Safari", &url])
.args(["-a", "Firefox", "--args", "--kiosk", &url])
.spawn()
.expect("Failed to start Safari on macOS")
.expect("Failed to start Firefox on macOS")
} else {
// On Linux, use the "firefox" command
std::process::Command::new("firefox")
.arg(&url)
.args(["--kiosk", &url])
.spawn()
.expect("Failed to start Firefox on Linux")
};
Expand Down
2 changes: 1 addition & 1 deletion tests/integration_browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use common::enigo_test::EnigoTest as Enigo;
fn integration_browser_events() {
let mut enigo = Enigo::new(&Settings::default());

enigo.maximize_browser();
// enigo.maximize_browser();

enigo.text("TestText❤️").unwrap(); // Fails on Windows (Message is empty???)
enigo.key(Key::F1, Click).unwrap();
Expand Down

0 comments on commit 8ddf90d

Please sign in to comment.