Skip to content

Commit

Permalink
AddUser added
Browse files Browse the repository at this point in the history
  • Loading branch information
lauratbg committed Apr 26, 2024
1 parent 65d7bc3 commit 7b7d3fd
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 2 deletions.
7 changes: 7 additions & 0 deletions webapp/e2e/features/addUser.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Feature: Login page functionality

Scenario: Register
Given I am on the add user page
When I register a user
Then I am in /menu

8 changes: 6 additions & 2 deletions webapp/e2e/features/login.feature
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,9 @@ Feature: Login page functionality

Scenario: Login
Given I am on the login page
I login as user
I am in /menu
When I login as 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
51 changes: 51 additions & 0 deletions webapp/e2e/steps/addUser.steps.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
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 = "testUser1"
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 });

});

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

test('Register', ({ given,when, then }) => {
given('I am on the add user page', async () => {
await page.goto('http://localhost:3000/addUser');
await page.waitForSelector('.general');
});
when('I register a user', async () => {
await register(page, email, username, password);
});
then('I am in /menu', async () => {
await expect(page).toMatchElement('.divMenu');
});
});



});
13 changes: 13 additions & 0 deletions webapp/e2e/steps/login.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,19 @@ defineFeature(feature, test => {
await expect(page).toMatchElement('.divMenu');
});
});

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



Expand Down

0 comments on commit 7b7d3fd

Please sign in to comment.