Skip to content

Commit

Permalink
Merge pull request #196 from Arquisoft/e2e_gaspar
Browse files Browse the repository at this point in the history
e2e gaspar
  • Loading branch information
UO250825 authored May 3, 2022
2 parents 372e0d9 + e24219e commit 2abdb6b
Show file tree
Hide file tree
Showing 5 changed files with 111 additions and 1 deletion.
6 changes: 6 additions & 0 deletions webapp/e2e/features/documentation.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Consulting documentation

Scenario: User consults project documentation
Given A user who founds the site
When selects the documentation button on the footer
Then is redirected to the documentation web page
6 changes: 6 additions & 0 deletions webapp/e2e/features/source-code.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Consulting source code

Scenario: User consults project source code
Given A user who founds the site
When selects the source code button on the footer
Then is redirected to GitHub
2 changes: 1 addition & 1 deletion webapp/e2e/steps/add-to-cart.steps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ defineFeature(feature, test => {
page = await browser.newPage();

await page
.goto("http://localhost:3000", {
.goto("https://dede-es5a.herokuapp.com/", {
waitUntil: "networkidle0",
})
.catch(() => {console.log("Error while testing")});
Expand Down
49 changes: 49 additions & 0 deletions webapp/e2e/steps/documentation.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { defineFeature, loadFeature } from 'jest-cucumber';
import puppeteer from "puppeteer";

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

let page: puppeteer.Page;
let browser: puppeteer.Browser;

defineFeature(feature, test => {

beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: true });
page = await browser.newPage();

await page
.goto("https://dede-es5a.herokuapp.com/", {
waitUntil: "networkidle0",
})
.catch(() => {
// This is intentional
});
});

test('User consults project documentation', ({given,when,then}) => {
jest.setTimeout(40000);

given('A user who founds the site', () => {
// This is intentional
});

when('selects the documentation button on the footer', async () => {
await Promise.all([
(await page.$x("/html/body/div[1]/div/div[2]/div[3]/div[2]/a")).at(0)?.click(),
page.waitForNavigation(),
]);
});

then('is redirected to the documentation web page', async () => {
await expect(page).toMatch('DeDe_es5a')
});
})

afterAll(async ()=>{
browser.close()
})
});

49 changes: 49 additions & 0 deletions webapp/e2e/steps/source-code.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { defineFeature, loadFeature } from 'jest-cucumber';
import puppeteer from "puppeteer";

const feature = loadFeature('./features/source-code.feature');

let page: puppeteer.Page;
let browser: puppeteer.Browser;

defineFeature(feature, test => {

beforeAll(async () => {
browser = process.env.GITHUB_ACTIONS
? await puppeteer.launch()
: await puppeteer.launch({ headless: true });
page = await browser.newPage();

await page
.goto("https://dede-es5a.herokuapp.com/", {
waitUntil: "networkidle0",
})
.catch(() => {
// This is intentional
});
});

test('User consults project source code', ({given,when,then}) => {
jest.setTimeout(40000);

given('A user who founds the site', () => {
// This is intentional
});

when('selects the source code button on the footer', async () => {
await Promise.all([
(await page.$x("/html/body/div[1]/div/div[2]/div[3]/div[3]/a")).at(0)?.click(),
page.waitForNavigation(),
]);
});

then('is redirected to GitHub', async () => {
await expect(page).toMatch('master')
});
})

afterAll(async ()=>{
browser.close()
})
});

0 comments on commit 2abdb6b

Please sign in to comment.