Skip to content

Commit

Permalink
Better code quality
Browse files Browse the repository at this point in the history
  • Loading branch information
jesQM committed Apr 28, 2020
1 parent 53cd4a8 commit 60838bf
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 123 deletions.
9 changes: 5 additions & 4 deletions e2e/step-definitions/basicFunctionality.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@ const expect = require('expect-puppeteer');
const puppeteer = require('puppeteer');

jest.setTimeout(400000);
let page = null;

function delay(time) {
return new Promise(function (resolve) {
setTimeout(resolve, time)
setTimeout(resolve, time);
});
}
defineFeature(feature, test => {
defineFeature(feature, (test) => {

beforeEach(async () => {
await delay(10000);
console.log("Before each");
//Open browser
const browser = await puppeteer.launch({
//headless let watch the chrome window interacting with the application
Expand All @@ -22,7 +23,7 @@ defineFeature(feature, test => {
});
page = await browser.newPage();
await page.goto('http://localhost:3000');
})
});

test('Access the main view of the App', ({ given, when, then }) => {

Expand Down
9 changes: 4 additions & 5 deletions e2e/step-definitions/groups.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ let page = null;

function a(){
//return "viadeen3atest123";
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8')
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8');
}

function delay(time) {
return new Promise(function (resolve) {
setTimeout(resolve, time)
setTimeout(resolve, time);
});
}

defineFeature(feature, test => {
defineFeature(feature, (test) => {

beforeEach(async () => {
await delay(10000);
Expand All @@ -34,12 +34,11 @@ defineFeature(feature, test => {
await page.goto('http://localhost:3000');

// Login
console.log("Logging in...");
await page.waitForSelector('button.btn-outline-light');
await page.click('button.btn-outline-light');

const [popup] = await Promise.all([
new Promise(resolve => page.once('popup', resolve)),
new Promise((resolve) => {page.once('popup', resolve);}),
]);

await popup.waitForSelector('input[type="url"]');
Expand Down
11 changes: 6 additions & 5 deletions e2e/step-definitions/login.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,19 @@ const puppeteer = require('puppeteer');
jest.setTimeout(400000);
let idp = "https://uo263624.solid.community";
let account = "uo263624";
let page = null;

function a(){
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8')
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8');
}

function delay(time) {
return new Promise(function (resolve) {
setTimeout(resolve, time)
setTimeout(resolve, time);
});
}

defineFeature(feature, test => {
defineFeature(feature, (test) => {

beforeEach(async () => {
await delay(10000);
Expand All @@ -30,7 +31,7 @@ defineFeature(feature, test => {
});
page = await browser.newPage();
await page.goto('http://localhost:3000');
})
});

test('Login to an account', ({ given, when, then }) => {

Expand All @@ -44,7 +45,7 @@ defineFeature(feature, test => {
await page.click('button.btn-outline-light');

const [popup] = await Promise.all([
new Promise(resolve => page.once('popup', resolve)),
new Promise((resolve) => {page.once('popup', resolve);}),
]);

await popup.waitForSelector('input[type="url"]');
Expand Down
24 changes: 7 additions & 17 deletions e2e/step-definitions/navigation.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,16 @@ let account = "uo263624";
let page = null

function a(){
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8')
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8');
}

function delay(time) {
return new Promise(function (resolve) {
setTimeout(resolve, time)
setTimeout(resolve, time);
});
}

defineFeature(feature, test => {
defineFeature(feature, (test) => {

beforeEach(async () => {
delay(10000);
Expand All @@ -33,18 +33,11 @@ defineFeature(feature, test => {
await page.goto('http://localhost:3000');

// Login
await page.evaluate(async () => {
//let btns = [...document.querySelectorAll("button")];
//if (btns.length != 0 && btns.map(btn => btn.innerText).find(s => s.includes("Identifícate"))){

//}
});
console.log("Logging in...");
await page.waitForSelector('button.btn-outline-light');
await page.click('button.btn-outline-light');

const [popup] = await Promise.all([
new Promise(resolve => page.once('popup', resolve)),
new Promise((resolve) => {page.once('popup', resolve);}),
]);

await popup.waitForSelector('input[type="url"]');
Expand Down Expand Up @@ -75,8 +68,7 @@ defineFeature(feature, test => {
await page.evaluate(() => {
let btns = [...document.querySelectorAll("a")];
btns.forEach(async function (btn) {
if (btn.firstChild.innerText == "Gestión de rutas"){
console.log("Clicked Gestión")
if (btn.firstChild.innerText === "Gestión de rutas"){
btn.click();
}
});
Expand All @@ -103,8 +95,7 @@ defineFeature(feature, test => {
await page.evaluate(() => {
let btns = [...document.querySelectorAll("a")];
btns.forEach(async function (btn) {
if (btn.firstChild.innerText == "Gestión de rutas"){
console.log("Clicked Gestión")
if (btn.firstChild.innerText === "Gestión de rutas"){
btn.click();
}
});
Expand All @@ -129,8 +120,7 @@ defineFeature(feature, test => {
await page.evaluate(() => {
let btns = [...document.querySelectorAll("a")];
btns.forEach(async function (btn) {
if (btn.firstChild.innerText == "Gestión de rutas"){
console.log("Clicked Gestión")
if (btn.firstChild.innerText === "Gestión de rutas"){
btn.click();
}
});
Expand Down
9 changes: 4 additions & 5 deletions e2e/step-definitions/routes.steps.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ let page = null;

function a(){
//return "viadeen3atest123";
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8')
return Buffer.from("SXo5X1NlVjRfJA==", "base64").toString('utf-8');
}

function delay(time) {
return new Promise(function (resolve) {
setTimeout(resolve, time)
setTimeout(resolve, time);
});
}

defineFeature(feature, test => {
defineFeature(feature, (test) => {

beforeEach(async () => {
await delay(10000);
Expand All @@ -34,12 +34,11 @@ defineFeature(feature, test => {
await page.goto('http://localhost:3000');

// Login
console.log("Logging in...");
await page.waitForSelector('button.btn-outline-light');
await page.click('button.btn-outline-light');

const [popup] = await Promise.all([
new Promise(resolve => page.once('popup', resolve)),
new Promise((resolve) => {page.once('popup', resolve);}),
]);

await popup.waitForSelector('input[type="url"]');
Expand Down
57 changes: 0 additions & 57 deletions e2e/support/actions.js

This file was deleted.

5 changes: 0 additions & 5 deletions e2e/support/field.js

This file was deleted.

11 changes: 0 additions & 11 deletions e2e/support/pages.js

This file was deleted.

1 change: 0 additions & 1 deletion e2e/support/scope.js

This file was deleted.

13 changes: 0 additions & 13 deletions e2e/support/selectors.js

This file was deleted.

0 comments on commit 60838bf

Please sign in to comment.