From a2d0a9ece368f1b1e88e5345d5d09870d691a98c Mon Sep 17 00:00:00 2001 From: Greenlamp2 <44787002+Greenlamp2@users.noreply.github.com> Date: Tue, 11 Jun 2024 19:13:02 +0200 Subject: [PATCH] [CI] Add GitHub Action to Run Silent Tests on PRs to Main (#2100) * github action to run tests in PR * fix the CI name * fix comment * fix divergent tests + cut some useless long test + fix versions --- .github/workflows/tests.yml | 31 +++++++++++++++++++++++++++++++ src/test/inputs/inputs.test.ts | 27 ++++++--------------------- 2 files changed, 37 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000000..c1c32a95cd6f --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,31 @@ +name: Tests + +on: + # Trigger the workflow on push or pull request, + # but only for the main branch + push: + branches: + - main # Trigger on push events to the main branch + pull_request: + branches: + - main # Trigger on pull request events targeting the main branch + +jobs: + run-tests: # Define a job named "run-tests" + name: Run tests # Human-readable name for the job + runs-on: ubuntu-latest # Specify the latest Ubuntu runner for the job + + steps: + - name: Check out Git repository # Step to check out the repository + uses: actions/checkout@v4 # Use the checkout action version 4 + + - name: Set up Node.js # Step to set up Node.js environment + uses: actions/setup-node@v4 # Use the setup-node action version 4 + with: + node-version: 20 # Specify Node.js version 20 + + - name: Install Node.js dependencies # Step to install Node.js dependencies + run: npm ci # Use 'npm ci' to install dependencies + + - name: tests # Step to run tests + run: npm run test:silent \ No newline at end of file diff --git a/src/test/inputs/inputs.test.ts b/src/test/inputs/inputs.test.ts index e753e167b6bf..5acee1450111 100644 --- a/src/test/inputs/inputs.test.ts +++ b/src/test/inputs/inputs.test.ts @@ -48,8 +48,8 @@ describe("Inputs", () => { }); it("Mobile - test touch holding for 1000ms - 4 input", async () => { - await game.inputsHandler.pressTouch("dpadUp", 1000); - expect(game.inputsHandler.log.length).toBe(4); + await game.inputsHandler.pressTouch("dpadUp", 1050); + expect(game.inputsHandler.log.length).toBe(5); }); it("keyboard - test input holding for 200ms - 1 input", async() => { @@ -63,13 +63,8 @@ describe("Inputs", () => { }); it("keyboard - test input holding for 1000ms - 4 input", async() => { - await game.inputsHandler.pressKeyboardKey(cfg_keyboard_qwerty.deviceMapping.KEY_ARROW_UP, 1000); - expect(game.inputsHandler.log.length).toBe(4); - }); - - it("keyboard - test input holding for 2000ms - 8 input", async() => { - await game.inputsHandler.pressKeyboardKey(cfg_keyboard_qwerty.deviceMapping.KEY_ARROW_UP, 2000); - expect(game.inputsHandler.log.length).toBe(8); + await game.inputsHandler.pressKeyboardKey(cfg_keyboard_qwerty.deviceMapping.KEY_ARROW_UP, 1050); + expect(game.inputsHandler.log.length).toBe(5); }); it("gamepad - test input holding for 1ms - 1 input", async() => { @@ -82,24 +77,14 @@ describe("Inputs", () => { expect(game.inputsHandler.log.length).toBe(1); }); - it("gamepad - test input holding for 249ms - 1 input", async() => { - await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 249); - expect(game.inputsHandler.log.length).toBe(1); - }); - it("gamepad - test input holding for 300ms - 2 input", async() => { await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 300); expect(game.inputsHandler.log.length).toBe(2); }); it("gamepad - test input holding for 1000ms - 4 input", async() => { - await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 1000); - expect(game.inputsHandler.log.length).toBe(4); - }); - - it("gamepad - test input holding for 2000ms - 8 input", async() => { - await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 2000); - expect(game.inputsHandler.log.length).toBe(8); + await game.inputsHandler.pressGamepadButton(pad_xbox360.deviceMapping.RC_S, 1050); + expect(game.inputsHandler.log.length).toBe(5); }); });