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

99 e2e testing #135

Merged
merged 2 commits into from
Apr 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 0 additions & 9 deletions webapp/e2e/features/competitiveGame.feature

This file was deleted.

12 changes: 10 additions & 2 deletions webapp/e2e/features/gameMenu.feature
Original file line number Diff line number Diff line change
@@ -1,8 +1,16 @@
Feature: Game Menu page functionality
Scenario: There should be visible three links
Given I am on the game menu
Then three buttons should be visible
Given I am on the game menu
Then three buttons should be visible
Scenario: New Game should go to game configurator
Given I am on the game menu
When I click on New Game
Then I should be in the game configurator
Scenario: Ranking should go to ranking view
Given I am on the game menu
When I click on Ranking
Then I should be in the ranking
Scenario: View Historical Data should go to historical data
Given I am on the game menu
When I click on View Historical Data
Then I should be in the historical data
29 changes: 29 additions & 0 deletions webapp/e2e/features/questionGame.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
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
Scenario: Create Customized Game of Capital questions
Given I am on the game configurator
When I click select Capital and I create a new customized game
Then I get Capital questions
Scenario: Create Customized Game of Language questions
Given I am on the game configurator
When I click select Language and I create a new customized game
Then I get Language questions
Scenario: Create Customized Game of Population questions
Given I am on the game configurator
When I click select Population and I create a new customized game
Then I get Population questions
Scenario: Create Customized Game of Size questions
Given I am on the game configurator
When I click select Size and I create a new customized game
Then I get Size questions
Scenario: Create Customized Game of Head of Goverment questions
Given I am on the game configurator
When I click select Head of Goverment and I create a new customized game
Then I get Head of Goverment questions
9 changes: 9 additions & 0 deletions webapp/e2e/features/revealAnswers.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
Feature: Question View answers
Scenario: Create Competitive Game and reveal correct answer color
Given I am on the game configurator and create a competitive game
When I let the counter end
Then Correct Color appears
Scenario: Create Competitive Game and reveal wrong answer colors
Given I am on the game configurator and create a competitive game
When I let the counter end
Then Incorrect Color appears
63 changes: 0 additions & 63 deletions webapp/e2e/steps/competitiveGame.steps.js

This file was deleted.

24 changes: 24 additions & 0 deletions webapp/e2e/steps/gameMenu.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,29 @@ defineFeature(feature, test => {
await expect(page).toMatchElement('.GameConfiguratorDiv');
});
});
test('Ranking should go to ranking view', ({ given, when, then }) => {
given('I am on the game menu', async () => {
await page.goto('http://localhost:3000/menu');
await page.waitForSelector('.divMenu');
});
when('I click on Ranking', async () => {
await page.click('#ranking');
});
then('I should be in the ranking', async () => {
await expect(page).toMatchElement('.table');
});
});
test('View Historical Data should go to historical data', ({ given, when, then }) => {
given('I am on the game menu', async () => {
await page.goto('http://localhost:3000/menu');
await page.waitForSelector('.divMenu');
});
when('I click on View Historical Data', async () => {
await page.click('#historical');
});
then('I should be in the historical data', async () => {
await expect(page).toMatchElement('.globalHistoricalView');
});
});

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

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

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

let page;
let browser;

const email = "[email protected]";
const username = "testUser1"
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: 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');
});
});

test('Create Customized Game of Capital 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 select Capital and I create a new customized game', async () => {
await page.select('#select', 'CAPITAL');
await page.click('.linkButton');//click on capital
});
then('I get Capital questions', async () => {
//await expect(page).toMatchElement('.topPanel');
const questionContainer = await page.$('.topPanel');
const questionText = await page.evaluate(questionContainer => questionContainer.textContent, questionContainer);
const containsCapital = /Capital/i.test(questionText);
expect(containsCapital).toBe(true);
});
});

test('Create Customized Game of Language 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 select Language and I create a new customized game', async () => {
await page.select('#select', 'LANGUAGE');
await page.click('.linkButton');
});
then('I get Language questions', async () => {
//await expect(page).toMatchElement('.topPanel');
const questionContainer = await page.$('.topPanel');
const questionText = await page.evaluate(questionContainer => questionContainer.textContent, questionContainer);
const containsCapital = /Language/i.test(questionText);
expect(containsCapital).toBe(true);
});
});
test('Create Customized Game of Population 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 select Population and I create a new customized game', async () => {
await page.select('#select', 'POPULATION');
await page.click('.linkButton');
});
then('I get Population questions', async () => {
//await expect(page).toMatchElement('.topPanel');
const questionContainer = await page.$('.topPanel');
const questionText = await page.evaluate(questionContainer => questionContainer.textContent, questionContainer);
const containsCapital = /Population/i.test(questionText);
expect(containsCapital).toBe(true);
});
});
test('Create Customized Game of Size 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 select Size and I create a new customized game', async () => {
await page.select('#select', 'SIZE');
await page.click('.linkButton');
});
then('I get Size questions', async () => {
//await expect(page).toMatchElement('.topPanel');
const questionContainer = await page.$('.topPanel');
const questionText = await page.evaluate(questionContainer => questionContainer.textContent, questionContainer);
const containsCapital = /Size/i.test(questionText);
expect(containsCapital).toBe(true);
});
});
test('Create Customized Game of Head of Goverment 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 select Head of Goverment and I create a new customized game', async () => {
await page.select('#select', 'HEAD_OF_GOVERMENT');
await page.click('.linkButton');
});
then('I get Head of Goverment questions', async () => {
//await expect(page).toMatchElement('.topPanel');
const questionContainer = await page.$('.topPanel');
const questionText = await page.evaluate(questionContainer => questionContainer.textContent, questionContainer);
const containsCapital = /Head of Goverment/i.test(questionText);
expect(containsCapital).toBe(true);
});
});

});
Loading