Skip to content

Commit

Permalink
Merge pull request #148 from Arquisoft/fix-e2e-test
Browse files Browse the repository at this point in the history
fix e2e test + release
  • Loading branch information
pelazas authored May 6, 2024
2 parents 1deb7b8 + 21d3224 commit 50c3abb
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 110 deletions.
49 changes: 27 additions & 22 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,32 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
# e2e-tests:
# needs: [unit-tests]
# runs-on: ubuntu-latest
# steps:
# - uses: actions/checkout@v4
# - uses: actions/setup-node@v4
# with:
# node-version: 20
# - run: npm --prefix users/authservice install
# - run: npm --prefix users/userservice install
# - run: npm --prefix gatewayservice install
# - run: npm --prefix webapp install
# - run: npm --prefix webapp run build
# - run: npm --prefix webapp run test:e2e
e2e-tests:
needs: [unit-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 20
- run: npm --prefix users/authservice install
- run: npm --prefix users/userservice install
- run: npm --prefix gatewayservice install
- run: npm --prefix game/gameservice install
- run: npm --prefix game/groupservice install
- run: npm --prefix game/qgservice install
- run: npm --prefix multiplayerservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
- run: npm --prefix webapp run test:e2e

docker-push-webapp:
name: Push webapp Docker Image to GitHub Packages
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -69,7 +74,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -87,7 +92,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -105,7 +110,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -123,7 +128,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -141,7 +146,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -162,7 +167,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand All @@ -180,7 +185,7 @@ jobs:
permissions:
contents: read
packages: write
needs: [unit-tests]
needs: [e2e-tests]
steps:
- uses: actions/checkout@v4
- name: Publish to Registry
Expand Down
2 changes: 1 addition & 1 deletion webapp/e2e/features/register-form.feature
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ Feature: Registering a new user
Scenario: The user is not registered in the site
Given An unregistered user
When I fill the data in the form and press submit
Then A confirmation message should be shown in the screen
Then Should be inside the game route
71 changes: 0 additions & 71 deletions webapp/e2e/singlePlayer.js

This file was deleted.

12 changes: 5 additions & 7 deletions webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ defineFeature(feature, test => {
let password;

given('An unregistered user', async () => {
username = "pablo"
password = "pabloasw"
username = "conoceryvenceruser"
password = "conoceryvencerpass"
await page.waitFor('button')
await page.click("button", {id: "registerButton"});
});
Expand All @@ -41,11 +41,9 @@ defineFeature(feature, test => {
await page.click('button', { text: 'Add User' })
});

then('A confirmation message should be shown in the screen', async () => {
const confirmationMessage = await page.waitForSelector('div',"#successUserAdd");

const messageText = await page.evaluate(confirmationMessage => confirmationMessage.innerText, confirmationMessage);
expect(messageText).toContain('User added successfully');
then('Should be inside the game route', async () => {
await page.waitForSelector('div', '.game-container');
expect(page.url()).toContain('/game');
});
})

Expand Down
16 changes: 8 additions & 8 deletions webapp/e2e/test-environment-setup.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
const { MongoMemoryServer } = require('mongodb-memory-server');


let mongoserver;
let userservice;
let authservice;
let gatewayservice;

async function startServer() {
console.log('Starting MongoDB memory server...');
mongoserver = await MongoMemoryServer.create();
const mongoserver = await MongoMemoryServer.create();
const mongoUri = mongoserver.getUri();
process.env.MONGODB_URI = mongoUri;
userservice = await require("../../users/userservice/user-service");
authservice = await require("../../users/authservice/auth-service");
gatewayservice = await require("../../gatewayservice/gateway-service");
require("../../users/userservice/user-service");
require("../../users/authservice/auth-service");
require("../../gatewayservice/gateway-service");
require("../../game/gameservice/gameservice");
require("../../game/groupservice/group-service");
require("../../game/qgservice/qg-service");
require("../../multiplayerservice/server")
}

startServer();
2 changes: 1 addition & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"build": "react-scripts build",
"prod": "cross-env REACT_APP_API_ENDPOINT=http://localhost:8000 REACT_APP_MULTIPLAYER_ENDPOINT=http://localhost:8006 serve -s build -l 80",
"test": "react-scripts test --silent --transformIgnorePatterns 'node_modules/(?!axios)/'",
"test:e2e": "start-server-and-test 'node e2e/test-environment-setup.js' http://localhost:8000/health prod 3000 \"cd e2e && jest\"",
"test:e2e": "start-server-and-test 'node e2e/test-environment-setup.js' http://localhost:8000/health prod 80 \"cd e2e && jest\"",
"eject": "react-scripts eject",
"test-only:e2e": "cd e2e && jest"
},
Expand Down

0 comments on commit 50c3abb

Please sign in to comment.