Skip to content

Commit

Permalink
chore(#9123): add scenario that update from build version to 'master' (
Browse files Browse the repository at this point in the history
…#9215)

This commit adds a scenario to the individual test should upgrade to the current branch to verify that it is possible to update from a specific build version, 'master' branch it is being used for this test.
  • Loading branch information
tatilepizs authored Jun 28, 2024
1 parent 977e90a commit 9788148
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 28 deletions.
57 changes: 39 additions & 18 deletions tests/e2e/upgrade/upgrade.wdio-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,24 @@ const deleteUpgradeLogs = async () => {
await utils.logsDb.bulkDocs(logs);
};

const upgradeVersion = async (branchVersion) => {
await upgradePage.goToUpgradePage();
await upgradePage.expandPreReleasesAccordion();

await (await upgradePage.getInstallButton(branchVersion, TAG)).click();
await (await upgradePage.upgradeModalConfirm()).click();

await (await upgradePage.cancelUpgradeButton()).waitForDisplayed();
await (await upgradePage.deploymentInProgress()).waitForDisplayed();
await (await upgradePage.deploymentInProgress()).waitForDisplayed({ reverse: true, timeout: 100000 });

if (testFrontend) {
// https://github.com/medic/cht-core/issues/9186
// this is an unfortunate incompatibility between current API and admin app in the old version
await (await upgradePage.deploymentComplete()).waitForDisplayed();
}
};

describe('Performing an upgrade', () => {
before(async () => {
await utils.saveDocs([...docs.places, ...docs.clinics, ...docs.persons, ...docs.reports]);
Expand Down Expand Up @@ -87,24 +105,7 @@ describe('Performing an upgrade', () => {
});

it('should upgrade to current branch', async () => {
await upgradePage.goToUpgradePage();
await upgradePage.expandPreReleasesAccordion();

const installButton = await upgradePage.getInstallButton(BRANCH, TAG);
await installButton.click();

const confirm = await upgradePage.upgradeModalConfirm();
await confirm.click();

await (await upgradePage.cancelUpgradeButton()).waitForDisplayed();
await (await upgradePage.deploymentInProgress()).waitForDisplayed();
await (await upgradePage.deploymentInProgress()).waitForDisplayed({ reverse: true, timeout: 100000 });

if (testFrontend) {
// https://github.com/medic/cht-core/issues/9186
// this is an unfortunate incompatibility between current API and admin app in the old version
await (await upgradePage.deploymentComplete()).waitForDisplayed();
}
await upgradeVersion(BRANCH);

const currentVersion = await upgradePage.getCurrentVersion();
expect(version.getVersion(true)).to.include(currentVersion);
Expand Down Expand Up @@ -142,9 +143,29 @@ describe('Performing an upgrade', () => {
await browser.refresh();
await commonPage.waitForPageLoaded();
await commonPage.goToAboutPage();
await (await aboutPage.aboutCard()).waitForDisplayed();
const expected = TAG || `${utils.escapeBranchName(BRANCH)} (`;
expect(await aboutPage.getVersion()).to.include(expected);
await commonPage.logout();

// https://github.com/medic/cht-core/issues/9117
// install 'master' branch to make sure a new version can be installed from the build version

await loginPage.cookieLogin({
username: constants.USERNAME,
password: constants.PASSWORD,
createUser: false
});

await upgradeVersion('master');

expect(await upgradePage.getBuild()).to.include('alpha');
await commonPage.goToAboutPage();
await commonPage.waitForPageLoaded();
await (await aboutPage.aboutCard()).waitForDisplayed();
expect(await aboutPage.getVersion()).to.include('master');

await commonPage.logout();
});

it('should display upgrade page even without upgrade logs', async () => {
Expand Down
3 changes: 1 addition & 2 deletions tests/e2e/upgrade/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ const servicesStartTimeout = () => {
const upgradeConfig = Object.assign(wdioBaseConfig.config, {
specs:
[
'upgrade.wdio-spec.js',
'*.wdio-spec.js'
'*.wdio-spec.js',
],
exclude: [],

Expand Down
8 changes: 0 additions & 8 deletions tests/e2e/upgrade/webapp.wdio-spec.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
const common = require('@page-objects/default/common/common.wdio.page');
const reportsPage = require('@page-objects/default/reports/reports.wdio.page');
const peoplePage = require('@page-objects/default/contacts/contacts.wdio.page');
const aboutPage = require('@page-objects/default/about/about.wdio.page');
const utils = require('@utils');

const { BRANCH, TAG } = process.env;

const loginPage = require('@page-objects/default/login/login.wdio.page');
const constants = require('@constants');

Expand Down Expand Up @@ -55,9 +52,4 @@ describe('Webapp after upgrade', () => {
expect(contacts).to.deep.equal(['DC']);
});

it('should display correct version on the about page', async () => {
await common.goToAboutPage();
const expected = TAG || `${utils.escapeBranchName(BRANCH)} (`;
expect(await aboutPage.getVersion()).to.include(expected);
});
});
2 changes: 2 additions & 0 deletions tests/page-objects/default/about/about.wdio.page.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const userName = () => $('label=User name');
const partners = () => $('.partners');
const version = () => $('[test-id="about-version"]');
const aboutCard = () => $('div*=About');
const RELOAD_BUTTON = '.about.page .mat-primary';

const getPartnerImage = async (name) => {
Expand All @@ -21,5 +22,6 @@ module.exports = {
partners,
getPartnerImage,
getVersion,
aboutCard,
RELOAD_BUTTON,
};

0 comments on commit 9788148

Please sign in to comment.