Skip to content

Commit

Permalink
e2e tests updated
Browse files Browse the repository at this point in the history
  • Loading branch information
UO287687 committed Apr 26, 2024
1 parent 11c44b9 commit 547b278
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 12 deletions.
2 changes: 1 addition & 1 deletion webapp/e2e/steps/close-session-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 100 });
: await puppeteer.launch({ headless: false, slowMo: 50 });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand Down
2 changes: 1 addition & 1 deletion webapp/e2e/steps/friends.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 10 });
: await puppeteer.launch({ headless: false, slowMo: 50 });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand Down
20 changes: 15 additions & 5 deletions webapp/e2e/steps/i18n-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 10 });
: await puppeteer.launch({ headless: false, slowMo: 50 });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand All @@ -23,7 +23,7 @@ defineFeature(feature, test => {
.catch(() => {});
});

test('The user is going to try different languages', ({given,when,then}) => {
test('The user is going to try different languages', async ({given,when,then}) => {

let username;
let password;
Expand All @@ -38,25 +38,35 @@ defineFeature(feature, test => {
await expect(page).toFill('input[name="username"]', username);
await expect(page).toFill('input[name="password"]', password);
await expect(page).toFill('input[name="confirmPassword"]', password);

await page.waitForSelector('button.btn', { text: '' });
await expect(page).toClick('button.btn', { text: '' });

await page.waitForSelector('span', { text: "Classic Game" });
await expect(page).toMatchElement("span", { text: "Classic Game" });

await page.waitForSelector('button.menuLeft', { text: '' });
await expect(page).toClick('button.menuLeft', { text: '' });

await page.waitForSelector('div.languageButton', { text: '' });
await expect(page).toClick('div.languageButton', { text: '' });

await page.waitForSelector('li', { text: 'Spanish' });
await expect(page).toClick('li', { text: 'Spanish' });
});

then('A Classic Game message should be shown in different languages', async () => {

await expect(page).toMatchElement("span", { text: "Juego Clásico" });

await page.waitForSelector('div.languageButton', { text: '' });
await expect(page).toClick('div.languageButton', { text: '' });
await page.waitForSelector('li', { text: 'Italiano' });
await expect(page).toClick('li', { text: 'Italiano' });
await expect(page).toMatchElement("span", { text: "Gioco Classico" });

await page.waitForSelector('div.languageButton', { text: '' });
await expect(page).toClick('div.languageButton', { text: '' });
await page.waitForSelector('li', { text: 'Francese' });
await expect(page).toClick('li', { text: 'Francese' });
await expect(page).toMatchElement("span", { text: "Jeu classique" });
});
})

Expand Down
6 changes: 4 additions & 2 deletions webapp/e2e/steps/infinite-mode-steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 10 });
: await puppeteer.launch({ headless: false, slowMo: 50 });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand Down Expand Up @@ -41,13 +41,15 @@ defineFeature(feature, test => {

await expect(page).toClick('button.btn', { text: '' });

await page.waitForSelector('button.btn', { text: 'Infinite Mode' });
await expect(page).toClick('button.btn', { text: 'Infinite Mode' });

await page.waitForSelector('div.endGameButton', { text: '' });
await expect(page).toClick('div.endGameButton', { text: '' });
});

then('A Game Over message should be shown in the screen', async () => {
await expect(page).toMatchElement("p", { text: "Game Over" });
await page.waitForSelector('p', { text: 'Game Over' });
});
})

Expand Down
2 changes: 1 addition & 1 deletion webapp/e2e/steps/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 10 });
: await puppeteer.launch({ headless: false, slowMo: 50 });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand Down
4 changes: 3 additions & 1 deletion webapp/e2e/steps/play-classic.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,16 @@ defineFeature(feature, test => {

await expect(page).toClick('button.btn', { text: 'Classic Game' });
for(let i = 0; i <10; i++) {
await page.waitForSelector('ul li span');
await expect(page).toClick('ul li span');
await page.waitForSelector('.botoneraPreguntas div', { visible: true, enabled: true });
await expect(page).toClick('.botoneraPreguntas div');
}

});

then('A Game Over message should be shown in the screen', async () => {
await expect(page).toMatchElement("p", { text: "Game Over" });
await page.waitForSelector('p', { text: 'Game Over' });
});
})

Expand Down
2 changes: 1 addition & 1 deletion webapp/e2e/steps/register-form.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defineFeature(feature, test => {
beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: false, slowMo: 10 });
: await puppeteer.launch({ headless: false, slowMo: 50 });
page = await browser.newPage();
//Way of setting up the timeout
setDefaultOptions({ timeout: 10000 })
Expand Down

0 comments on commit 547b278

Please sign in to comment.