This repository contains End-to-End tests for the Truck Management API available at http://qa-api-mock-3.eu-central-1.elasticbeanstalk.com/. The tests are written using the Playwright framework.
- Truck:
- Must have a unique alphanumeric code.
- Must have a name.
- Must have a status included in the following set:
Out Of Service,Loading,To Job,At Job,Returning. - The "Out Of Service" status can be set regardless of the current status of the Truck.
- Each status can be set if the current status of the Truck is "Out of service".
- The remaining statuses can only be changed in the following order:
Loading -> To Job -> At Job -> Returning. When the Truck has the "Returning" status, it can start "Loading" again. - May have a description.
This project is integrated with GitHub Actions for Continuous Integration (CI). The workflow is triggered in the following scenarios:
- Pushing commits to the main branch.
- Opening, reopening, or editing a pull request.
- Manual trigger.
After the tests are executed, the workflow uploads a test report as an artifact. This allows for easy access and review of the test results.
If you want to manually trigger the GitHub Actions workflow without making a commit or opening a pull request, you can do so using the following steps:
-
Navigate to the GitHub Repository: Go to the main page of your GitHub repository.
-
Go to the "Actions" Tab: Located at the top of the repository, click on the "Actions" tab.
-
Select the Workflow: On the left sidebar, select the workflow you want to run.
-
Run Workflow: Above the list of past runs, you'll find a "Run workflow" dropdown. Click on it.
-
Select the Branch: Using the dropdown, select the branch where you want to run the workflow.
-
Trigger the Workflow: Click on the "Run workflow" button to start the workflow.
-
Monitor the Workflow: You can click on the workflow run to monitor the progress, view logs, and see results.
-
Accessing the Test Report: After the workflow completes, in the specific run summary, under the "Artifacts" section, you can download the test report.
Remember, manually triggering the GitHub Actions workflow will use the latest commit on the branch you select. Ensure you have pushed all your changes to the desired branch before manually triggering the workflow.
Ensure you have Node.js installed.
-
Clone the repository:
git clone https://github.com/logip87/playwright-api-test.git -
Navigate to the project directory:
cd playwright-api-trucks -
Install the dependencies:
npm install
To run all the tests, execute the following command:
npx playwright test
-
truck-OUT_OF_SERVICE.spec.ts:
- Tests if the status
OUT_OF_SERVICEcan be updated to any other statuses (LOADING,TO_JOB,AT_JOB,RETURNING) and back.
- Tests if the status
-
truck-statuses-rotation.spec.ts:
- Validates the status rotation order:
Loading -> To Job -> At Job -> Returning -> Loading.
- Validates the status rotation order:
-
each-truck.spec.ts:
- Ensures that all trucks have unique codes.
- Checks if all trucks have a name.
- Verifies if all trucks have a valid status.
- Validates that a truck may have a description.
randomCode(): Generates a random alphanumeric code.randomID(): Generates a random ID.randomName(): Generates a random name.updateStatus(): Updates the status of a truck.updateStatusFail(): Asserts that the status update fails.
This project uses Prettier for code formatting.
