Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/develop-deploy' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
uo289689 committed Apr 8, 2024
2 parents e6386c3 + 5efb2e1 commit f02539f
Show file tree
Hide file tree
Showing 11 changed files with 42 additions and 44 deletions.
13 changes: 0 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,3 @@ 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 install
- run: npm --prefix questions install
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ jobs:
- run: npm --prefix gatewayservice install
- run: npm --prefix webapp install
- run: npm --prefix webapp run build

- run: npm --prefix webapp run test:e2e
docker-push-users:
name: Push users Docker Image to GitHub Packages
runs-on: ubuntu-latest
Expand Down
2 changes: 2 additions & 0 deletions gatewayservice/gateway-service.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,9 @@ app.get('/user/statistics/:username', async (req, res) => {
app.get('/user/group/list', async (req, res) => {
try {
const username = req.query.username;
console.log("username: ", username);
const userResponse = await axios.get(userServiceUrl + '/user/group/list',{params: {username: username }});
console.log("userResponse: ", userResponse);
res.json(userResponse.data);
} catch (error) {
handleErrors(res, error);
Expand Down
25 changes: 8 additions & 17 deletions users/routes/user-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,30 +103,19 @@ router.post('/add', async (req, res) => {
}
});


// router.post('/logout', async (req, res) => {
// try {

// req.session.username = null;
// } catch (error) {
// return res.status(500).json({ error: 'Internal Server Error' });
// }
// });


// router.get('/session', async (req, res) => {
// res.json({ session: req.session });
// });


// Getting the list of groups in the database
router.get('/group/list', async (req, res) => {
try {

const username = req.query.username;

console.log("usernameUsers: "+username);

// If the user is null or undefined (no one is logged, return all groups)
if (username === null || username === undefined) {

console.log("username is null or undefined");

const allGroups = await Group.findAll({ order: [['name', 'ASC']] });
const groupsJSON = await Promise.all(allGroups.map(async (group) => {
const userCount = await UserGroup.count({
Expand All @@ -152,6 +141,7 @@ router.get('/group/list', async (req, res) => {
const userGroupNames = userGroups.map(userGroup => userGroup.groupName);

const allGroups = await Group.findAll({ order: [['name', 'ASC']] });
console.log("username is not null or undefined");
const groupsJSON = await Promise.all(allGroups.map(async (group) => {
const userCount = await UserGroup.count({
where: {
Expand All @@ -164,10 +154,11 @@ router.get('/group/list', async (req, res) => {
isFull: userCount === 20
};
}));

console.log("groups json"+groupsJSON);
res.json({ groups: groupsJSON });

} catch (error) {
console.log(error);
return res.status(500).json({ error: 'Internal Server Error' });
}
});
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ let browser;

async function registerUser(username, password, name, surname) {
clickLink('//*[@id="root"]/div/header/div/a[2]');

await expect(page).toClick("a", { text: "Don't have an account? Register here." });

await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toFill('input[name="name"]', name);
Expand All @@ -28,7 +28,7 @@ if (link) {
}

defineFeature(feature, test => {

beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
Expand Down
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 Home page should be shown in the screen
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ let page;
let browser;

defineFeature(feature, test => {

beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
Expand All @@ -24,7 +24,7 @@ defineFeature(feature, test => {
});

test('The user is not registered in the site', ({given,when,then}) => {

let username;
let password;
let name;
Expand All @@ -35,7 +35,7 @@ defineFeature(feature, test => {
password = "12345678mM."
name = "Jordi"
surname = "Hurtado"

const [loginLink] = await page.$x('//*[@id="root"]/div/header/div/a[2]');

if (loginLink) {
Expand All @@ -56,12 +56,12 @@ defineFeature(feature, test => {
});

then('A confirmation message should be shown in the screen', async () => {
await expect(page).toMatchElement("button", { text: "PLAY" });
await expect(page).toMatchElement("link", { text: "PLAY" });
});
})

afterAll(async ()=>{
browser.close()
})

});
});
5 changes: 2 additions & 3 deletions webapp/e2e/test-environment-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ async function startServer() {
questionservice = await require("../../questions/services/question-data-service");

await sequelize.authenticate();
await sequelize.sync({ force: true });


await sequelize.sync({force:true});

} catch (error) {
console.error('Error starting server:', error);
}
Expand Down
18 changes: 18 additions & 0 deletions webapp/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.2",
"axios": "^1.6.5",
"cross-env": "^7.0.3",
"babel": "^6.23.0",
"express": "^4.19.2",
"react": "^18.2.0",
Expand All @@ -30,7 +31,7 @@
"build": "react-scripts build",
"prod": "serve -s build",
"test": "react-scripts test --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 3000 \"cd e2e && jest\" ",
"eject": "react-scripts eject"
},
"eslintConfig": {
Expand Down

0 comments on commit f02539f

Please sign in to comment.