/
autoUpgrade.js
65 lines (59 loc) · 2.36 KB
/
autoUpgrade.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
const BOBasePage = require('../../BO/BObasePage');
module.exports = class autoUpgrade extends BOBasePage {
constructor(page) {
super(page);
this.pageTitle = '1-Click Upgrade > 1-Click Upgrade •';
this.expectedStepsDoneForUpgradeTable = [
'backupFiles',
'backupDb',
'upgradeFiles',
'upgradeDb',
'upgradeModules',
'upgradeComplete',
];
this.actualStepsDoneForUpgradeTable = [];
// Selectors
this.showExpertModeButton = 'input[type=\'button\'][value=\'More options (Expert mode)\']';
this.channelSelect = '#channel';
this.updateChannelSaveButton = '#advanced input[type=\'button\'][value=\'Save\']';
this.upgradePrestashopNowButton = '#upgradeNow';
this.upgradeResultMessageBloc = '#upgradeResultCheck>p';
}
/*
Methods
*/
/**
* Select the channel from where to do the upgrade
* @param upgradeChannelValue, value to select
* @return {Promise<void>}
*/
async chooseUpgradeChannel(upgradeChannelValue) {
if (await this.elementVisible(this.showExpertModeButton)) {
await this.page.click(this.showExpertModeButton);
}
await this.page.waitForSelector(this.channelSelect, {visible: true});
await this.page.select(this.channelSelect, upgradeChannelValue);
await this.page.click(this.updateChannelSaveButton);
await this.page.waitForNavigation({waitUntil: 'networkidle0'});
}
/**
* Select the channel from where to do the upgrade,
* Upgrade Prestashop
* And check successful message and that all steps are passed
* @param upgradeChannelValue, value to select
* @return {Promise<void>}
*/
async upgradePrestashop(upgradeChannelValue) {
await this.chooseUpgradeChannel(upgradeChannelValue);
await this.page.waitForSelector(this.upgradePrestashopNowButton, {visible: true});
this.page.on('response', async (response) => {
if (await response.url().endsWith('ajax-upgradetab.php') && await response.status() === 200) {
const jsonResponse = await response.json();
await this.actualStepsDoneForUpgradeTable.push(jsonResponse.next);
}
});
await this.page.click(this.upgradePrestashopNowButton);
await this.page.waitForSelector(this.upgradeResultMessageBloc, {visible: true, timeout: 300000});
await global.expect(this.actualStepsDoneForUpgradeTable).to.include.members(this.expectedStepsDoneForUpgradeTable);
}
};