[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
This commit is contained in:
Greenlamp2 2024-06-11 19:13:02 +02:00 committed by GitHub
parent 2aa6ec5031
commit a2d0a9ece3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 37 additions and 21 deletions

31
.github/workflows/tests.yml vendored Normal file
View File

@ -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

View File

@ -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);
});
});