|
| 1 | +/** |
| 2 | + * Copyright since 2007 PrestaShop SA and Contributors |
| 3 | + * PrestaShop is an International Registered Trademark & Property of PrestaShop SA |
| 4 | + * |
| 5 | + * NOTICE OF LICENSE |
| 6 | + * |
| 7 | + * This source file is subject to the Academic Free License version 3.0 |
| 8 | + * that is bundled with this package in the file LICENSE.md. |
| 9 | + * It is also available through the world-wide-web at this URL: |
| 10 | + * https://opensource.org/licenses/AFL-3.0 |
| 11 | + * If you did not receive a copy of the license and are unable to |
| 12 | + * obtain it through the world-wide-web, please send an email |
| 13 | + * to license@prestashop.com so we can send you a copy immediately. |
| 14 | + * |
| 15 | + * @author PrestaShop SA and Contributors <contact@prestashop.com> |
| 16 | + * @copyright Since 2007 PrestaShop SA and Contributors |
| 17 | + * @license https://opensource.org/licenses/AFL-3.0 Academic Free License version 3.0 |
| 18 | + */ |
| 19 | + |
| 20 | +import { |
| 21 | + // Import utils |
| 22 | + utilsTest, |
| 23 | + // Import BO pages |
| 24 | + boDashboardPage, |
| 25 | + boLoginPage, |
| 26 | + boModuleManagerPage, |
| 27 | + boInstalledModulesPage, |
| 28 | + boModuleSelectionPage, |
| 29 | + boModuleManagerAlertsPage, |
| 30 | + modAutoupgradeBoModal, |
| 31 | + dataModules, |
| 32 | +} from '@prestashop-core/ui-testing'; |
| 33 | + |
| 34 | +import { |
| 35 | + test, expect, Page, BrowserContext, |
| 36 | +} from '@playwright/test'; |
| 37 | +import semver from 'semver'; |
| 38 | + |
| 39 | +const psVersion = utilsTest.getPSVersion(); |
| 40 | + |
| 41 | +/* |
| 42 | + Uninstall welcome module |
| 43 | + */ |
| 44 | +if (semver.lt(psVersion, '8.0.1')) { |
| 45 | + test.describe('Uninstall welcome module', () => { |
| 46 | + let browserContext: BrowserContext; |
| 47 | + let page: Page; |
| 48 | + |
| 49 | + test.beforeAll(async ({browser}) => { |
| 50 | + browserContext = await browser.newContext(); |
| 51 | + page = await browserContext.newPage(); |
| 52 | + }); |
| 53 | + test.afterAll(async () => { |
| 54 | + await page.close(); |
| 55 | + }); |
| 56 | + |
| 57 | + // Steps |
| 58 | + test('should login in BO', async () => { |
| 59 | + await boLoginPage.goTo(page, global.BO.URL); |
| 60 | + await boLoginPage.successLogin(page, global.BO.EMAIL, global.BO.PASSWD); |
| 61 | + |
| 62 | + const pageTitle = await boDashboardPage.getPageTitle(page); |
| 63 | + expect(pageTitle).toContain(boDashboardPage.pageTitle); |
| 64 | + }); |
| 65 | + |
| 66 | + test('should close update notification dialog', async () => { |
| 67 | + const isDialogNotVisible = await modAutoupgradeBoModal.closeDialogUpdateNotification(page); |
| 68 | + expect(isDialogNotVisible).toEqual(true); |
| 69 | + }); |
| 70 | + |
| 71 | + // Steps to go to module configuration page |
| 72 | + if (semver.lt(psVersion, '7.4.0')) { |
| 73 | + test('should go to \'Modules > Modules & Services\' page', async () => { |
| 74 | + await boDashboardPage.goToSubMenu( |
| 75 | + page, |
| 76 | + boDashboardPage.modulesParentLink, |
| 77 | + boDashboardPage.moduleManagerLink, |
| 78 | + ); |
| 79 | + await boModuleManagerPage.closeSfToolBar(page); |
| 80 | + |
| 81 | + const pageTitle = await boModuleSelectionPage.getPageTitle(page); |
| 82 | + expect(pageTitle).toContain(boModuleSelectionPage.pageTitle); |
| 83 | + }); |
| 84 | + |
| 85 | + test('should go to Installed modules page', async () => { |
| 86 | + await boModuleSelectionPage.goToInstalledModulesPage(page); |
| 87 | + |
| 88 | + const pageTitle = await boInstalledModulesPage.getPageTitle(page); |
| 89 | + expect(pageTitle).toContain(boInstalledModulesPage.pageTitle); |
| 90 | + }); |
| 91 | + |
| 92 | + test(`should search the module '${dataModules.welcome.name}'`, async () => { |
| 93 | + const isModuleVisible = await boInstalledModulesPage.searchModule(page, dataModules.welcome); |
| 94 | + expect(isModuleVisible).toEqual(true); |
| 95 | + }); |
| 96 | + |
| 97 | + test(`should uninstall the module '${dataModules.autoupgrade.name}'`, async () => { |
| 98 | + const successMessage = await boInstalledModulesPage.uninstallModule(page, dataModules.welcome.tag); |
| 99 | + expect(successMessage).toEqual(boModuleManagerAlertsPage.uninstallModuleSuccessMessage(dataModules.welcome.tag)); |
| 100 | + }); |
| 101 | + } else if (semver.lt(psVersion, '7.5.0')) { |
| 102 | + test('should go to \'Modules > Modules & Services\' page', async () => { |
| 103 | + await boDashboardPage.goToSubMenu( |
| 104 | + page, |
| 105 | + boDashboardPage.modulesParentLink, |
| 106 | + boDashboardPage.moduleManagerLink, |
| 107 | + ); |
| 108 | + await boModuleManagerPage.closeSfToolBar(page); |
| 109 | + |
| 110 | + const pageTitle = await boInstalledModulesPage.getPageTitle(page); |
| 111 | + expect(pageTitle).toContain(boInstalledModulesPage.pageTitle); |
| 112 | + }); |
| 113 | + |
| 114 | + test(`should search the module '${dataModules.welcome.name}'`, async () => { |
| 115 | + const isModuleVisible = await boInstalledModulesPage.searchModule(page, dataModules.welcome); |
| 116 | + expect(isModuleVisible).toEqual(true); |
| 117 | + }); |
| 118 | + |
| 119 | + test(`should uninstall the module '${dataModules.welcome.name}'`, async () => { |
| 120 | + const successMessage = await boInstalledModulesPage.uninstallModule(page, dataModules.welcome.tag); |
| 121 | + expect(successMessage).toEqual(boModuleManagerAlertsPage.uninstallModuleSuccessMessage(dataModules.welcome.tag)); |
| 122 | + }); |
| 123 | + } else { |
| 124 | + test('should go to Module Manager page', async () => { |
| 125 | + await boDashboardPage.goToSubMenu( |
| 126 | + page, |
| 127 | + boDashboardPage.modulesParentLink, |
| 128 | + boDashboardPage.moduleManagerLink, |
| 129 | + ); |
| 130 | + |
| 131 | + const pageTitle = await boModuleManagerPage.getPageTitle(page); |
| 132 | + expect(pageTitle).toContain(boModuleManagerPage.pageTitle); |
| 133 | + }); |
| 134 | + |
| 135 | + test(`should search the module '${dataModules.welcome.name}'`, async () => { |
| 136 | + const isModuleVisible = await boModuleManagerPage.searchModule(page, dataModules.welcome); |
| 137 | + expect(isModuleVisible).toEqual(true); |
| 138 | + }); |
| 139 | + |
| 140 | + test(`should uninstall the module '${dataModules.autoupgrade.name}'`, async () => { |
| 141 | + const successMessage = await boModuleManagerPage.setActionInModule(page, dataModules.welcome, 'uninstall'); |
| 142 | + expect(successMessage).toEqual(boModuleManagerAlertsPage.uninstallModuleSuccessMessage(dataModules.welcome.tag)); |
| 143 | + }); |
| 144 | + } |
| 145 | + }); |
| 146 | +} |
0 commit comments