Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

e2e tests #112

Merged
merged 32 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
752edc0
Login and navbar e2e
lauratbg Apr 20, 2024
9cee846
Trying to solve some conflicts and also added tests for instructions
lauratbg Apr 21, 2024
8b9c72d
Changed the beforeall and also some things in login
lauratbg Apr 21, 2024
18b1144
Changed the before all
lauratbg Apr 21, 2024
ef42830
Chanegd login tests to wait until domcontentloaded
lauratbg Apr 21, 2024
9ea0ea5
Trying to pass login test
lauratbg Apr 24, 2024
6d6c743
Merge branch 'master' into e2e_laura
lauratbg Apr 24, 2024
c30eb8a
Removed login test
lauratbg Apr 25, 2024
ae6c297
Merge branch 'master' into e2e_laura
lauratbg Apr 25, 2024
9b3e824
Merge and changes
lauratbg Apr 25, 2024
0f7da6b
Removed a test from home and login feature
lauratbg Apr 25, 2024
56958a1
Removed login and updated wait time in competitive test
lauratbg Apr 25, 2024
4e47c6a
Copied from master competitive tests
lauratbg Apr 25, 2024
c8bf83a
Merge branch 'master' into e2e_laura
lauratbg Apr 26, 2024
65d7bc3
First try of login test
lauratbg Apr 26, 2024
7b7d3fd
AddUser added
lauratbg Apr 26, 2024
6b9bd36
Changed things
lauratbg Apr 26, 2024
ca4ff41
Changing the before all of login
lauratbg Apr 26, 2024
c082cfc
Increased times
lauratbg Apr 26, 2024
ef8b784
Improving things
lauratbg Apr 26, 2024
4c5dca5
More
lauratbg Apr 26, 2024
fce7bef
Doing it without using utils
lauratbg Apr 26, 2024
744bd16
Continue trying things
lauratbg Apr 26, 2024
7dec293
Last try
lauratbg Apr 26, 2024
a6f0e80
little fix
lauratbg Apr 26, 2024
a78516d
Fixed tests
Mister-Mario Apr 27, 2024
8f15093
Added test feature
Mister-Mario Apr 27, 2024
86551f5
Added headless mode
Mister-Mario Apr 27, 2024
95e7a17
Added commented scenarios for home
Mister-Mario Apr 27, 2024
4fecee7
Added headless
Mister-Mario Apr 27, 2024
becbd1e
Merge branch 'master' into e2e_laura
Mister-Mario Apr 27, 2024
a65664b
Tests pass on local
Mister-Mario Apr 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions webapp/e2e/features/addUser.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Register page functionality

Scenario: Register
Given I register a user
Then I am in /menu

9 changes: 9 additions & 0 deletions webapp/e2e/features/competitiveGame.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Game Configurator and Competitive Game functionality
Scenario: Create Competitive Game should go to /questions
Given I am on the game configurator
When I click on new competitive game
Then I am in /questions
Scenario: Create Customized Game should go to /questions
Given I am on the game configurator
When I click on new customized game
Then I am in /questions
3 changes: 1 addition & 2 deletions webapp/e2e/features/home.feature
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,4 @@ Feature: Home page functionality
Scenario: Closing the text container
Given I am on the home page
When I click on the toggle button to open and then I click it to close
Then The text container should be visible

Then The text container should be visible
9 changes: 9 additions & 0 deletions webapp/e2e/features/instructions.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Instructions page functionality

Scenario: Instructions view is well rendered
Given I am on the instructions page
Then The instructions title is rendered
Then The instructions content is rendered



10 changes: 10 additions & 0 deletions webapp/e2e/features/login.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Feature: Login page functionality

Scenario: Login
Given I login a user
Then I am in /menu
Scenario: Failed login
Given I am on the login page
When I try to login
Then I am in /login

13 changes: 13 additions & 0 deletions webapp/e2e/features/navBar.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Feature: NavBar functionality

Scenario: Displaying navbar elements correctly
Given I am on the home page
Then The navbar elements are visible

Scenario: Changing language
Given I am on the home page
When I click on the language button
Then The language options menu should be visible
Then I choose Spanish
Then The navbar should be in Spanish

44 changes: 44 additions & 0 deletions webapp/e2e/steps/addUser.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
const puppeteer = require('puppeteer');
const { defineFeature, loadFeature } = require('jest-cucumber');
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions;

const feature = loadFeature('./features/addUser.feature');

const { register, login, logout } = require("../utils");

let page;
let browser;

const email = "[email protected]";
const username = "testUserAddUser"
const password = "testUserPassword"

defineFeature(feature, test => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: "new",
slowMo: 40,
defaultViewport: { width: 1920, height: 1080 },
args: ['--window-size=1920,1080']
});

page = await browser.newPage();
setDefaultOptions({ timeout: 30000 });

}, 60000);


test('Register', ({ given,when, then }) => {
given('I register a user', async () => {
await register(page, email, username, password);
});

then('I am in /menu', async () => {
await expect(page).toMatchElement('.divMenu');
});
}, 60000);



});
63 changes: 63 additions & 0 deletions webapp/e2e/steps/competitiveGame.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const puppeteer = require('puppeteer');
const { defineFeature, loadFeature } = require('jest-cucumber');
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions;

const feature = loadFeature('./features/competitiveGame.feature');

const { register, login, logout } = require("../utils");

let page;
let browser;

const email = "[email protected]";
const username = "testUserCompetitiveGame"
const password = "testUserPassword"

defineFeature(feature, test => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: "new",
slowMo: 40,
defaultViewport: { width: 1920, height: 1080 },
args: ['--window-size=1920,1080']
});

page = await browser.newPage();
setDefaultOptions({ timeout: 30000 });

await register(page, email, username, password);
});

beforeEach(async () => {
await logout(page);
await login(page, username, password);
})

test('Create Competitive Game should go to /questions', ({ given,when, then }) => {
given('I am on the game configurator', async () => {
await page.goto('http://localhost:3000/configurator');
await page.waitForSelector('.GameConfiguratorDiv');
});
when('I click on new competitive game', async () => {
await page.click('#competitive');
});
then('I am in /questions', async () => {
await expect(page).toMatchElement('.questionContainer');
});
});

test('Create Customized Game should go to /questions', ({ given,when, then }) => {
given('I am on the game configurator', async () => {
await page.goto('http://localhost:3000/configurator');
await page.waitForSelector('.GameConfiguratorDiv');
});
when('I click on new customized game', async () => {
await page.click('.linkButton');
});
then('I am in /questions', async () => {
await expect(page).toMatchElement('.questionContainer');
});
});

});
49 changes: 24 additions & 25 deletions webapp/e2e/steps/home.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ defineFeature(feature, test => {
page = await browser.newPage();
setDefaultOptions({ timeout: 10000 });
});

test('The text container is initially visible', ({ given, then }) => {
given('I am on the home page', async () => {
await page.goto('http://localhost:3000/home');
await page.waitForSelector('.general');
});

test('The text container is initially visible', ({ given, then }) => {
given('I am on the home page', async () => {
await page.goto('http://localhost:3000/home');
await page.waitForSelector('.general');
});

then('The text container should be visible', async () => {
await expect(page).toMatchElement('.text-container.visible');
});
});
then('The text container should be visible', async () => {
await expect(page).toMatchElement('.text-container.visible');
});
});

test('Opening the text container', ({ given, when, then }) => {
given('I am on the home page', async () => {
Expand All @@ -47,26 +47,25 @@ defineFeature(feature, test => {
});
});

test('Closing the text container', ({ given, when, then }) => {
given('I am on the home page', async () => {
await page.goto('http://localhost:3000/home');
await page.waitForSelector('.general');
});

when('I click on the toggle button to open and then I click it to close', async () => {
test('Closing the text container', ({ given, when, then }) => {
given('I am on the home page', async () => {
await page.goto('http://localhost:3000/home');
await page.waitForSelector('.general');
});
when('I click on the toggle button to open and then I click it to close', async () => {

await page.click('label[for="toggleOpen"]');
await page.click('label[for="toggleOpen"]');

// Wait for label to be render, visible : true
await page.waitForSelector(`label[for="toggleClose"]`, {visible: true});
await page.click('label[for="toggleClose"]');
await page.waitForSelector(`label[for="toggleClose"]`, {visible: true});
await page.click('label[for="toggleClose"]');

});
});

then('The text container should be visible', async () => {
await expect(page).toMatchElement('.text-container.visible');
});
});
then('The text container should be visible', async () => {
await expect(page).toMatchElement('.text-container.visible');
});
});

afterAll(async () => {
await browser.close();
Expand Down
42 changes: 42 additions & 0 deletions webapp/e2e/steps/instructions.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const puppeteer = require('puppeteer');
const { defineFeature, loadFeature } = require('jest-cucumber');
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions;

const feature = loadFeature('./features/instructions.feature');

let page;
let browser;

defineFeature(feature, test => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: "new",
slowMo: 20,
defaultViewport: { width: 1920, height: 1080 },
args: ['--window-size=1920,1080']
});

page = await browser.newPage();
setDefaultOptions({ timeout: 10000 });
});

test('Instructions view is well rendered', ({ given, then }) => {
given('I am on the instructions page', async () => {
await page.goto('http://localhost:3000/instructions');
await page.waitForSelector('.instructions_title');
});

then('The instructions title is rendered', async () => {
await expect(page).toMatchElement('.instructions_title');
});

then('The instructions content is rendered', async () => {
await expect(page).toMatchElement('.ins_ul');
});
});

afterAll(async () => {
await browser.close();
});
});
63 changes: 63 additions & 0 deletions webapp/e2e/steps/login.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
const puppeteer = require('puppeteer');
const { defineFeature, loadFeature } = require('jest-cucumber');
const setDefaultOptions = require('expect-puppeteer').setDefaultOptions;

const feature = loadFeature('./features/login.feature');

const { register, login, logout } = require("../utils");

let page;
let browser;

const email = "[email protected]";
const username = "testUserLogin"
const password = "testUserPassword"

defineFeature(feature, test => {

beforeAll(async () => {
browser = await puppeteer.launch({
headless: "new",
slowMo: 20,
defaultViewport: { width: 1920, height: 1080 },
args: ['--window-size=1920,1080']
});

page = await browser.newPage();
setDefaultOptions({ timeout: 10000 });
await register(page, email, username, password);
await logout(page);
},60000);


test('Login', ({ given, then }) => {
given('I login a user', async () => {
await login(page, username, password);

});
then('I am in /menu', async () => {
await expect(page).toMatchElement('.divMenu');
await logout(page);
});
}, 60000);

test('Failed login', ({ given,when, then }) => {
given('I am on the login page', async () => {
await page.goto('http://localhost:3000/login');
});
when('I try to login', async () => {
await page.goto('http://localhost:3000/login');
await page.waitForSelector('.general');

await page.type('input[type="text"]', 'lau');
await page.type('input[type="password"]', '123');
await page.click('button[type="submit"]');
});
then('I am in /login', async () => {
await expect(page).toMatchElement('.title-login');
}, 60000);
});



});
Loading