diff --git a/webapp/e2e/features/instructions.feature b/webapp/e2e/features/instructions.feature new file mode 100644 index 00000000..f59fda00 --- /dev/null +++ b/webapp/e2e/features/instructions.feature @@ -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 + + + diff --git a/webapp/e2e/steps/home.steps.js b/webapp/e2e/steps/home.steps.js index 770b2a0a..d179ebe0 100644 --- a/webapp/e2e/steps/home.steps.js +++ b/webapp/e2e/steps/home.steps.js @@ -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 () => { diff --git a/webapp/e2e/steps/instructions.steps.js b/webapp/e2e/steps/instructions.steps.js new file mode 100644 index 00000000..0770eaf1 --- /dev/null +++ b/webapp/e2e/steps/instructions.steps.js @@ -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(); + }); +}); diff --git a/webapp/e2e/steps/login.steps.js b/webapp/e2e/steps/login.steps.js index 5c3fb3a1..3623f16c 100644 --- a/webapp/e2e/steps/login.steps.js +++ b/webapp/e2e/steps/login.steps.js @@ -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 }) => { @@ -26,8 +26,8 @@ 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"]'); }); @@ -35,7 +35,7 @@ defineFeature(feature, test => { await page.waitForNavigation(); expect(page.url()).toContain('/menu'); }); - }); + }, 60000); test('Failed login', ({ given, when, then }) => { given('I am on the login page', async () => { @@ -53,7 +53,7 @@ defineFeature(feature, test => { await page.waitForNavigation(); expect(page.url()).toContain('/login'); }); - }); + }, 60000); afterAll(async () => { await browser.close();