generated from Arquisoft/dede_0
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #269 from Arquisoft/develop
Test e2e
- Loading branch information
Showing
11 changed files
with
190 additions
and
77 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Feature: Registering a new user | ||
|
||
Scenario: The user is already registered on the website | ||
Given Data from an existing user | ||
When I fill the data in the form | ||
Then Error | ||
|
||
Scenario: Dont fill all the data in the form | ||
Given Nothing information | ||
When I dont fill the data in the form | ||
Then Error | ||
|
||
Scenario: The user is not registered in the site | ||
Given An unregistered user | ||
When I fill the data in the form and press submit | ||
Then A confirmation message should be shown in the screen |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Feature: Get a product | ||
|
||
Scenario: User enters the webpage | ||
Given Homepage | ||
When Click a product | ||
Then Details from product |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { defineFeature, loadFeature } from "jest-cucumber"; | ||
import puppeteer from "puppeteer"; | ||
|
||
const feature = loadFeature("./features/get-products.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: false }); | ||
page = await browser.newPage(); | ||
|
||
await page | ||
.goto("http://localhost:3000", { | ||
waitUntil: "networkidle0", | ||
}) | ||
.catch(() => {}); | ||
|
||
/*page.on("request", (interceptedRequest) => { | ||
console.log(interceptedRequest.url()); | ||
});*/ | ||
}); | ||
|
||
test("User enters the webpage", ({ given, when, then }) => { | ||
given("Homepage", async () => { | ||
}); | ||
|
||
when("Click a product", async () => { | ||
await page.goto("http://localhost:3000/Details?id=9z"); | ||
expect(page.url()).toContain("/Details?id=9z"); | ||
await delay(1000); | ||
}); | ||
|
||
then("Details from product", async () => { | ||
const text = await page.evaluate(() => document.body.textContent); | ||
expect(text).toContain("Adidas Equipment Support 93"); | ||
expect(text).toContain("Zapatilla"); | ||
expect(text).toContain("35.99"); | ||
}); | ||
}); | ||
}); | ||
|
||
afterAll(async () => { | ||
browser.close(); | ||
}); | ||
|
||
function delay(time: number) { | ||
return new Promise(function (resolve) { | ||
setTimeout(resolve, time); | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
import { defineFeature, loadFeature } from 'jest-cucumber'; | ||
import puppeteer from "puppeteer"; | ||
|
||
const feature = loadFeature('./features/Register.feature'); | ||
|
||
let page: puppeteer.Page; | ||
let browser: puppeteer.Browser; | ||
|
||
defineFeature(feature, test => { | ||
|
||
beforeEach(async () => { | ||
browser = process.env.GITHUB_ACTIONS | ||
? await puppeteer.launch() | ||
: await puppeteer.launch({ headless: true }); | ||
page = await browser.newPage(); | ||
|
||
await page | ||
.goto("http://localhost:3000/Register", { | ||
waitUntil: "networkidle0", | ||
}) | ||
.catch(() => {}); | ||
}); | ||
|
||
test('The user is already registered on the website', ({given,when,then}) => { | ||
|
||
let username:string; | ||
let password:string; | ||
|
||
given('Data from an existing user', () => { | ||
username = "user1" | ||
password = process.env.TESTPW1 as string | ||
}); | ||
|
||
when('I fill the data in the form', async () => { | ||
await expect(page).toMatch('Registro') | ||
await expect(page).toFillForm('form[name="registro"]', { | ||
username: username, | ||
password: password, | ||
confirmpassword: password | ||
}) | ||
|
||
await expect(page).toClick('button', { text: 'Registrarse' }) | ||
}); | ||
|
||
then('Error', async () => { | ||
await expect(page).toMatch('') | ||
}); | ||
}) | ||
|
||
|
||
test('Dont fill all the data in the form', ({given,when,then}) => { | ||
|
||
given('Nothing information', () => { | ||
}); | ||
|
||
when('I dont fill the data in the form', async () => { | ||
await expect(page).toMatch('Registro') | ||
await expect(page).toClick('button', { text: 'Registrarse' }) | ||
}); | ||
|
||
then('Error', async () => { | ||
await expect(page).toMatch('') | ||
}); | ||
}) | ||
|
||
test('The user is not registered in the site', ({given,when,then}) => { | ||
let username:string; | ||
let password:string; | ||
|
||
given('An unregistered user', () => { | ||
username = "newuser" | ||
password = process.env.TESTPW2 as string | ||
}); | ||
|
||
when('I fill the data in the form and press submit', async () => { | ||
await expect(page).toMatch('Registro') | ||
await expect(page).toFillForm('form[name="registro"]', { | ||
username: username, | ||
password: password, | ||
confirmpassword: password | ||
}) | ||
await expect(page).toClick('button', { text: 'Registrarse' }) | ||
}); | ||
|
||
then('A confirmation message should be shown in the screen', async () => { | ||
await expect(page).toMatch('') | ||
}); | ||
}) | ||
|
||
afterEach(async ()=>{ | ||
browser.close() | ||
}); | ||
|
||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters