generated from Arquisoft/dede_0
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #103 from Arquisoft/frontEndTest
front end test
- Loading branch information
Showing
42 changed files
with
4,081 additions
and
44 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
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: 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 |
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: 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 |
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,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() | ||
}) | ||
|
||
}); | ||
|
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,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() | ||
}) | ||
|
||
}); | ||
|
Oops, something went wrong.