Skip to content

Commit

Permalink
Merge pull request #103 from Arquisoft/frontEndTest
Browse files Browse the repository at this point in the history
front end test
  • Loading branch information
jnt0rrente authored Apr 3, 2022
2 parents eed40e5 + 9305749 commit e132d61
Show file tree
Hide file tree
Showing 42 changed files with 4,081 additions and 44 deletions.
3 changes: 3 additions & 0 deletions docs/05_building_block_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ The restAPI defines DeDe's API in accordance with REST architecture, which allow
****

////
****
.Level 3
Expand Down Expand Up @@ -167,6 +168,8 @@ The controllers interlink the frontend and the backend
****
////

////
Important Interfaces::
_<Description of important interfaces>_
Expand Down
7 changes: 0 additions & 7 deletions docs/07_deployment_view.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,3 @@ Utilizing the user's POD following SOLID design principles allows the applicatio
|===
****

=== Level 2
****
.Motivation
The figure above shows the infrastructure and interlinking of each environment involved in DeDe.
****
6 changes: 6 additions & 0 deletions webapp/e2e/features/add-to-cart.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Adding item to cart

Scenario: Adding an item to cart
Given An empty cart
When I add an item to the cart
Then The item appears in the cart
6 changes: 6 additions & 0 deletions webapp/e2e/features/product-details.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Feature: Displaying product details

Scenario: No product details are displayed
Given No product details
When I click on the product details button of a product
Then I am taken to a new page where product details are displayed
56 changes: 56 additions & 0 deletions webapp/e2e/steps/add-to-cart.steps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import { defineFeature, loadFeature } from 'jest-cucumber';
import puppeteer from "puppeteer";

const feature = loadFeature('./features/add-to-cart.feature');

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

defineFeature(feature, test => {

const testProduct = {
_id: "622fc1418aedec1b7f536775",
name: "Screwdriver",
price: 2,
description: "Multi-purpose screwdriver.",
}

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

await page
.goto("http://localhost:3000", {
waitUntil: "networkidle0",
})
.catch(() => {});
});



test('Adding an item to cart', ({given,when,then}) => {

given('An empty cart', () => {
});

when('I add an item to the cart', async () => {
await expect(page).toMatch('DEDE')

await expect(page).toClick(testProduct._id + '_cart')
});

then('The item appears in the cart', async () => {
await expect(page).toClick('shoppingCart')

await expect(page).toMatch('Total')
});
})

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

});

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

const feature = loadFeature('./features/product-details.feature');

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

defineFeature(feature, test => {

const testProduct = {
_id: "622fc1418aedec1b7f536775",
name: "Screwdriver",
price: 2,
description: "Multi-purpose screwdriver.",
}

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

await page
.goto("http://localhost:3000", {
waitUntil: "networkidle0",
})
.catch(() => {});
});

test('No product details are displayed', ({given,when,then}) => {

given('No product details', () => {
});

when('I click on the product details button of a product', async () => {
await expect(page).toMatch('DEDE')
await expect(page).toClick(testProduct._id + '_details')
});

then('I am taken to a new page where product details are displayed', async () => {
await expect(page).toMatch('Price:')
});
})

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

});

Loading

0 comments on commit e132d61

Please sign in to comment.