Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

front end test #103

Merged
merged 9 commits into from
Apr 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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