generated from Arquisoft/wiq_0
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/develop'
- Loading branch information
Showing
36 changed files
with
444 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: End 2 End Tests | ||
|
||
on: | ||
push: | ||
branches: | ||
- test/e2e | ||
|
||
jobs: | ||
e2e-tests: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20 | ||
- run: sudo apt install -y openssl | ||
- run: openssl req -newkey rsa:2048 -nodes -keyout server.key -out server.csr -subj "/CN=localhost" | ||
- run: openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt | ||
- run: openssl pkcs12 -export -out server.p12 -inkey server.key -in server.crt -passout pass:${{ secrets.E2E_SSL_PASSWORD }} -name tomcat | ||
- run: sudo mkdir /certs | ||
- run: sudo mv server.p12 /certs/keystore.p12 | ||
- name: Set up environment variables | ||
run: | | ||
echo "DATABASE_USER=${{ secrets.DATABASE_USER }}" >> .env | ||
echo "DATABASE_PASSWORD=${{ secrets.DATABASE_PASSWORD }}" >> .env | ||
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> .env | ||
echo "REACT_APP_API_ENDPOINT=https://localhost:8443" >> ./webapp/.env | ||
echo "SSL_PASSWORD=${{ secrets.E2E_SSL_PASSWORD }}" >> .env | ||
- run: mv .env ./webapp/e2e/.env | ||
- run: ls ./webapp -la | ||
- run: cat ./webapp/.env | ||
- run: docker compose -f ./webapp/e2e/docker-compose.yml up -d | ||
- run: npm --prefix webapp install | ||
- run: docker ps -a | ||
- run: docker logs api-defaultASW | ||
- run: npm --prefix webapp run build | ||
- run: npm --prefix webapp run test:e2eci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
version: '3' | ||
services: | ||
WIQ_DB: | ||
container_name: postgresql-${teamname:-defaultASW} | ||
environment: | ||
POSTGRES_USER: ${DATABASE_USER} | ||
POSTGRES_PASSWORD: ${DATABASE_PASSWORD} | ||
volumes: | ||
- postgres_data:/var/lib/postgresql/data | ||
image: postgres:latest | ||
networks: | ||
mynetwork: | ||
|
||
api: | ||
container_name: api-${teamname:-defaultASW} | ||
build: | ||
context: ../../api | ||
args: | ||
DATABASE_USER: ${DATABASE_USER} | ||
DATABASE_PASSWORD: ${DATABASE_PASSWORD} | ||
JWT_SECRET: ${JWT_SECRET} | ||
SSL_PASSWORD: ${SSL_PASSWORD} | ||
dockerfile: Dockerfile | ||
environment: | ||
- DATABASE_URL=jdbc:postgresql://WIQ_DB:5432/wiq | ||
- DATABASE_USER=${DATABASE_USER} | ||
- DATABASE_PASSWORD=${DATABASE_PASSWORD} | ||
- JWT_SECRET=${JWT_SECRET} | ||
- SSL_PASSWORD=${SSL_PASSWORD} | ||
ports: | ||
- 8443:8443 | ||
networks: | ||
mynetwork: | ||
volumes: | ||
- /certs:/etc/letsencrypt/live/kiwiq.run.place:ro | ||
depends_on: | ||
- WIQ_DB | ||
|
||
question-generator: | ||
container_name: question-generator-${teamname:-defaultASW} | ||
build: | ||
context: ../../questiongenerator | ||
args: | ||
DATABASE_USER: ${DATABASE_USER} | ||
DATABASE_PASSWORD: ${DATABASE_PASSWORD} | ||
dockerfile: Dockerfile | ||
environment: | ||
- DATABASE_URL=jdbc:postgresql://WIQ_DB:5432/wiq | ||
- DATABASE_USER=${DATABASE_USER} | ||
- DATABASE_PASSWORD=${DATABASE_PASSWORD} | ||
networks: | ||
mynetwork: | ||
depends_on: | ||
- WIQ_DB | ||
|
||
volumes: | ||
postgres_data: | ||
certs: | ||
|
||
networks: | ||
mynetwork: | ||
driver: bridge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/** | ||
* Note: e2e Testing purposes only! | ||
* Auxiliar function for login an user using its credentials from the root directory of the website. | ||
* It also ensures the task has been performed successfully. | ||
* | ||
* @param username The username for the user. Currently we are using codes for each test case. | ||
* @param email The email for the user. If none is defined, the username (a code) + '@gmail.com' is used | ||
* @param password The password for the user. If none is defined, the username (a code) + '.ps' is used | ||
* Beware of constraits for the user password. | ||
* @param page The website | ||
*/ | ||
async function loginUserFromRootDirectory(username, email = username + "@gmail.com", password = username + ".ps", page) { | ||
|
||
// login process | ||
await expect(page).toClick("button[data-testid='Login'"); | ||
await expect(page).toFill("#user", email); | ||
await expect(page).toFill("#password", password); | ||
await expect(page).toClick("button[data-testid='Login'"); | ||
|
||
// Checking for the process to be correct | ||
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load | ||
let header = await page.$eval("h2", (element) => { | ||
return element.innerHTML | ||
}) | ||
let value = header === "Bienvenid@ " + username || header === "Welcome " + username; | ||
expect(value).toBeTruthy(); | ||
|
||
} | ||
modules.export ={loginUserFromRootDirectory}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
const {waitForPageToLoad} = require('../e2e_utils/e2e_utils_timeout.js'); | ||
|
||
/** | ||
* Note: e2e Testing purposes only! | ||
* Auxiliar function for logging out an user from any directory of the user. | ||
* Beware if the user is playing a game when logging out | ||
* It also ensures the task has been performed successfully. | ||
* | ||
* @param {*} page The website | ||
*/ | ||
async function logOutUser(page) { | ||
// Logging out | ||
await expect(page).toClick("#lateralMenuButton"); | ||
await expect(page).toClick("button[data-testid='LogOut']"); | ||
|
||
// Checking for the log out to be sucessful | ||
waitForPageToLoad(); | ||
let header = await page.$eval("button[data-testid='Login']", (element) => { | ||
return element.innerHTML | ||
}) | ||
let value = header === "Login" || "Iniciar sesión"; | ||
|
||
expect(value).toBeTruthy(); | ||
} | ||
modules.export = {logOutUser} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/** | ||
* Note: e2e Testing purposes only! | ||
* Auxiliar function for registering a new user from the root directory of the website. | ||
* It also ensures the task has been performed successfully. | ||
* | ||
* @param {*} username The username for the new user. Currently we are using codes for each test case. | ||
* @param {*} page The website | ||
* @returns An array with the credentials of the user created [email, username] | ||
*/ | ||
async function registerUserFromRootDirectory(username, page) { | ||
// Credentials for the new user | ||
let email = username + "@email.com" | ||
let password = username + "ps" | ||
|
||
// Registeing process | ||
await expect(page).toClick("span[class='chakra-link css-1bicqx'"); | ||
await expect(page).toFill("input[id='user'", email); | ||
await expect(page).toFill("input[id='username'", username); | ||
await expect(page).toFill("#password", password); | ||
await expect(page).toFill("input[id='field-:r5:']", password); | ||
await expect(page).toClick("button[data-testid='Sign up'"); | ||
|
||
// Checking for the process to be correct | ||
await new Promise(resolve => setTimeout(resolve, 6000)); // Waiting for page to fully load | ||
let header = await page.$eval("h2", (element) => { | ||
return element.innerHTML | ||
}) | ||
let value = header === "Bienvenid@ " + username || header === "Welcome " + username; | ||
expect(value).toBeTruthy(); | ||
|
||
return [email, password]; | ||
} | ||
|
||
modules.export ={registerUserFromRootDirectory}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/** | ||
* Note: e2e Testing purposes only! | ||
* Auxiliar function that times out the tests for some time, so the page can be fully loaded. | ||
* @param {*} timeout_ms Amount of ms to wait. | ||
*/ | ||
async function waitForPageToLoad(timeout_ms = 6000) { | ||
await new Promise(resolve => setTimeout(resolve, timeout_ms)); | ||
|
||
} | ||
|
||
modules.export = {waitForPageToLoad} |
4 changes: 2 additions & 2 deletions
4
webapp/e2e/features/playing_game_features/positive_playing_full_game.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module.exports = { | ||
testMatch: ["**/steps/*.js"], | ||
testMatch: ["**/playing_full_game_pos*.steps.js","**/about.steps.js", "**/login_positive.steps.js"], | ||
moduleFileExtensions: ["ts", "tsx", "js", "jsx", "json", "node"], | ||
testTimeout: 30000 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,5 +58,6 @@ defineFeature(feature, test => { | |
|
||
afterAll((done) => { | ||
done(); | ||
browser.close(); | ||
}); | ||
}); |
Oops, something went wrong.