Skip to content

Commit

Permalink
Trying to solve some conflicts and also added tests for instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
lauratbg committed Apr 21, 2024
1 parent 752edc0 commit 9cee846
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 15 deletions.
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



18 changes: 9 additions & 9 deletions webapp/e2e/steps/home.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,16 @@ defineFeature(feature, test => {
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 Down
40 changes: 40 additions & 0 deletions webapp/e2e/steps/instructions.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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({
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();
});
});
12 changes: 6 additions & 6 deletions webapp/e2e/steps/login.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ 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('Successful login', ({ given, when, then }) => {
Expand All @@ -26,16 +26,16 @@ defineFeature(feature, test => {
});

when('I enter valid credentials', async () => {
await page.type('input[type="text"]', 'validUsername');
await page.type('input[type="password"]', 'validPassword');
await page.type('input[type="text"]', 'ltbg');
await page.type('input[type="password"]', 'ltbg');
await page.click('button[type="submit"]');
});

then('I should be redirected to the menu', async () => {
await page.waitForNavigation();
expect(page.url()).toContain('/menu');
});
});
}, 60000);

test('Failed login', ({ given, when, then }) => {
given('I am on the login page', async () => {
Expand All @@ -53,7 +53,7 @@ defineFeature(feature, test => {
await page.waitForNavigation();
expect(page.url()).toContain('/login');
});
});
}, 60000);

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

0 comments on commit 9cee846

Please sign in to comment.