forked from PrestaShop/PrestaShop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
02_editOrder.js
71 lines (68 loc) · 2.49 KB
/
02_editOrder.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
require('module-alias/register');
// Using chai
const {expect} = require('chai');
const helper = require('@utils/helpers');
const loginCommon = require('@commonTests/loginBO');
// importing pages
const LoginPage = require('@pages/BO/login');
const DashboardPage = require('@pages/BO/dashboard');
const BOBasePage = require('@pages/BO/BObasePage');
const OrderPage = require('@pages/BO/order');
const OrdersPage = require('@pages/BO/orders');
const {Statuses} = require('@data/demo/orders');
let browser;
let page;
// creating pages objects in a function
const init = async function () {
return {
loginPage: new LoginPage(page),
dashboardPage: new DashboardPage(page),
boBasePage: new BOBasePage(page),
orderPage: new OrderPage(page),
ordersPage: new OrdersPage(page),
};
};
/*
Connect to the BO
Edit the first order
Logout from the BO
*/
describe('Edit Order BO', async () => {
// before and after functions
before(async function () {
browser = await helper.createBrowser();
page = await helper.newTab(browser);
this.pageObjects = await init();
});
after(async () => {
await browser.close();
});
// Steps
loginCommon.loginBO();
it('should go to the Orders page', async function () {
await this.pageObjects.boBasePage.goToSubMenu(
this.pageObjects.boBasePage.ordersParentLink,
this.pageObjects.boBasePage.ordersLink,
);
const pageTitle = await this.pageObjects.ordersPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.ordersPage.pageTitle);
});
it('should go to the first order page', async function () {
await this.pageObjects.ordersPage.goToOrder('1');
const pageTitle = await this.pageObjects.orderPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.orderPage.pageTitle);
});
it('should modify the product quantity and check the validation', async function () {
const result = await this.pageObjects.orderPage.modifyProductQuantity('1', '5');
await expect(result).to.be.true;
});
it('should modify the order status and check the validation', async function () {
const result = await this.pageObjects.orderPage.modifyOrderStatus(Statuses.paymentAccepted.status);
await expect(result).to.be.true;
});
it('should logout from the BO', async function () {
await this.pageObjects.boBasePage.logoutBO();
const pageTitle = await this.pageObjects.loginPage.getPageTitle();
await expect(pageTitle).to.contains(this.pageObjects.loginPage.pageTitle);
});
});