Skip to content

Commit

Permalink
Merge pull request #142 from Arquisoft/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
adriiglz authored Apr 28, 2024
2 parents 1530142 + d6673e6 commit d3a7d33
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 63 deletions.
13 changes: 2 additions & 11 deletions webapp/e2e/features/userprofile-form.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,7 @@ Feature: View and Change User Quiz Rankings

Scenario: Viewing Global Rankings
Given the user navigates to their profile
When they select the "Global" category
Then they see their performance statistics for global quizzes
When see user general info
Then they see their performance statistics for all quizzes

Scenario: Switching Category to Flags
Given the user is on their profile page
When they click on the "Flags" category
Then they view their performance metrics for flag-related quizzes

Scenario: Switching Category to Food
Given the user is on their profile page
When they click on the "Food" category
Then they view their performance metrics for food-related quizzes

67 changes: 15 additions & 52 deletions webapp/e2e/steps/userprofile-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,76 +29,39 @@ defineFeature(feature, test => {

let username;
let password;
let email;

given('the user navigates to their profile', async () => {
username = "testUser"
username = "testUser";
password = "testpass";
email = "test@email";
await expect(page).toClick("a", { text: "Log In" });
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toClick("button", { text: "Log In" });
await expect(page).toClick("button", { text: "My stats" });
});

when('they select the "Global" category', async () => {
when('see user general info', async () => {

await expect(page).toMatchElement("h2", { text: "Username: " + username });
await expect(page).toClick("button", { text: "Flags" });
await expect(page).toClick("button", { text: "Global" });
await expect(page).toMatchElement("h2", { text: username });
await expect(page).toMatchElement("p", { text: "Email: " + email });
});

then('they see their performance statistics for global quizzes', async () => {
await expect(page).toMatchElement('.ranking h3', { text: "global Ranking" });
await expect(page).toMatchElement(".ranking p:nth-child(1)", { text: "Total Answered Questions: " + 1 });
});

});

test('Switching Category to Flags', ({given,when,then}) => {

let username;
let password;

given('the user is on their profile page', async () => {
username = "testUser"
password = "testpass";
await expect(page).toMatchElement("h2", { text: "Username: " + username });
});

when('they click on the "Flags" category', async () => {

await expect(page).toClick("button", { text: "Flags" });
});
then('they see their performance statistics for all quizzes', async () => {
await expect(page).toMatchElement('h3.font-bold', { text: "Global" });
await expect(page).toMatchElement('h3.font-bold', { text: "Flags" });
await expect(page).toMatchElement('h3.font-bold', { text: "Cities" });
await expect(page).toMatchElement('h3.font-bold', { text: "Food" });
await expect(page).toMatchElement('h3.font-bold', { text: "Attractions" });
await expect(page).toMatchElement('h3.font-bold', { text: "Monuments" });

then('they view their performance metrics for flag-related quizzes', async () => {
await expect(page).toMatchElement('.ranking h3', { text: "flags Ranking" });
await expect(page).toMatchElement(".ranking p:nth-child(1)", { text: "Total Answered Questions: " + 1 });
await expect(page).toMatchElement("div.mx-auto h3.font-bold + p", { text: "Total questions: 1" });
await expect(page).toMatchElement("div.mx-auto h3.font-bold + p", { text: "Total questions: 0" });
});

});

test('Switching Category to Food', ({given,when,then}) => {

let username;
let password;

given('the user is on their profile page', async () => {
username = "testUser"
password = "testpass";
await expect(page).toMatchElement("h2", { text: "Username: " + username });
});

when('they click on the "Food" category', async () => {

await expect(page).toClick("button", { text: "Food" });
});

then('they view their performance metrics for food-related quizzes', async () => {
await expect(page).toMatchElement('.ranking h3', { text: "foods Ranking" });
await expect(page).toMatchElement(".ranking p:nth-child(1)", { text: "Total Answered Questions: " + 0 });
});

});

afterAll(async ()=>{
browser.close()
Expand Down

0 comments on commit d3a7d33

Please sign in to comment.