forked from PrestaShop/PrestaShop
-
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 PrestaShop#35308 from nesrineabdmouleh/TEST-4986
Functional tests - Add new test 'FO > Hummingbird > Subscribe to newsletter'
- Loading branch information
Showing
3 changed files
with
241 additions
and
3 deletions.
There are no files selected for viewing
233 changes: 233 additions & 0 deletions
233
tests/UI/campaigns/functional/FO/hummingbird/04_newsletter/01_subscribeNewsletter.ts
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,233 @@ | ||
// Import utils | ||
import helper from '@utils/helpers'; | ||
import testContext from '@utils/testContext'; | ||
import files from '@utils/files'; | ||
|
||
// Import commonTests | ||
import loginCommon from '@commonTests/BO/loginBO'; | ||
import {installHummingbird, uninstallHummingbird} from '@commonTests/FO/hummingbird'; | ||
|
||
// Import pages | ||
// Import BO pages | ||
import dashboardPage from '@pages/BO/dashboard'; | ||
import {moduleManager as moduleManagerPage} from '@pages/BO/modules/moduleManager'; | ||
import {moduleConfigurationPage} from '@pages/BO/modules/moduleConfiguration'; | ||
import psEmailSubscriptionPage from '@pages/BO/modules/psEmailSubscription'; | ||
// Import FO pages | ||
import homePage from '@pages/FO/hummingbird/home'; | ||
import loginPage from '@pages/FO/hummingbird/login'; | ||
import myAccountPage from '@pages/FO/hummingbird/myAccount'; | ||
import accountIdentityPage from '@pages/FO/hummingbird/myAccount/identity'; | ||
|
||
// Import data | ||
import Customers from '@data/demo/customers'; | ||
import ModuleData from '@data/faker/module'; | ||
|
||
import {expect} from 'chai'; | ||
import type {BrowserContext, Page} from 'playwright'; | ||
|
||
// context | ||
const baseContext: string = 'functional_FO_hummingbird_newsletter_subscribeNewsletter'; | ||
|
||
/* | ||
Pre-condition: | ||
- Install hummingbird | ||
Scenario: | ||
- Go to the FO homepage | ||
- Fill the subscribe newsletter field and subscribe | ||
- Go to BO in newsletter module | ||
- Check if correctly subscribed | ||
- Go back to the FO homepage | ||
- Try to subscribe again with the same email | ||
- Go to back to BO and delete subscription | ||
Post-condition: | ||
- Uninstall hummingbird | ||
*/ | ||
describe('FO - Newsletter : Subscribe to Newsletter', async () => { | ||
let browserContext: BrowserContext; | ||
let page: Page; | ||
|
||
const moduleInformation: ModuleData = new ModuleData({ | ||
tag: 'ps_emailsubscription', | ||
name: 'Newsletter subscription', | ||
}); | ||
|
||
// Pre-condition : Install Hummingbird | ||
installHummingbird(`${baseContext}_preTest`); | ||
|
||
// before and after functions | ||
before(async function () { | ||
browserContext = await helper.createBrowserContext(this.browser); | ||
page = await helper.newTab(browserContext); | ||
}); | ||
|
||
after(async () => { | ||
await helper.closeBrowserContext(browserContext); | ||
await files.deleteFile('../../admin-dev/hummingbird.zip'); | ||
}); | ||
|
||
describe('Go to FO and try to subscribe with already used email', async () => { | ||
it('should open the shop page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'openFoShop', baseContext); | ||
|
||
await homePage.goTo(page, global.FO.URL); | ||
|
||
const result = await homePage.isHomePage(page); | ||
expect(result).to.eq(true); | ||
}); | ||
|
||
it('should subscribe to newsletter with already used email', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'subscribeWithAlreadyUsedEmail', baseContext); | ||
|
||
const newsletterSubscribeAlertMessage = await homePage.subscribeToNewsletter(page, Customers.johnDoe.email); | ||
expect(newsletterSubscribeAlertMessage).to.contains(homePage.alreadyUsedEmailMessage); | ||
}); | ||
}); | ||
|
||
describe('Go to FO customer account to unsubscribe newsletter', async () => { | ||
it('should go to login page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToFOLoginPage', baseContext); | ||
|
||
await homePage.goToLoginPage(page); | ||
|
||
const pageHeaderTitle = await loginPage.getPageTitle(page); | ||
expect(pageHeaderTitle).to.equal(loginPage.pageTitle); | ||
}); | ||
|
||
it('Should sign in FO', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'signInFo', baseContext); | ||
|
||
await loginPage.customerLogin(page, Customers.johnDoe); | ||
|
||
const isCustomerConnected = await myAccountPage.isCustomerConnected(page); | ||
expect(isCustomerConnected, 'Customer is not connected').to.eq(true); | ||
}); | ||
|
||
it('should go to account information page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToAccountInformationPage', baseContext); | ||
|
||
await homePage.goToMyAccountPage(page); | ||
await myAccountPage.goToInformationPage(page); | ||
|
||
const pageTitle = await accountIdentityPage.getPageTitle(page); | ||
expect(pageTitle).to.equal(accountIdentityPage.pageTitle); | ||
}); | ||
|
||
it('should unsubscribe from newsletter', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'unsubscribeFromNewsLetter', baseContext); | ||
|
||
const unsubscribeAlertText = await accountIdentityPage.unsubscribeNewsletter(page, Customers.johnDoe.password); | ||
expect(unsubscribeAlertText).to.contains(accountIdentityPage.successfulUpdateMessage); | ||
}); | ||
}); | ||
|
||
describe('Go to BO to check if correctly unsubscribed', async () => { | ||
it('should login in BO', async function () { | ||
await loginCommon.loginBO(this, page); | ||
}); | ||
|
||
it('should go to module manager page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToModuleManagerPage', baseContext); | ||
|
||
await dashboardPage.goToSubMenu( | ||
page, | ||
dashboardPage.modulesParentLink, | ||
dashboardPage.moduleManagerLink, | ||
); | ||
await moduleManagerPage.closeSfToolBar(page); | ||
|
||
const pageTitle = await moduleManagerPage.getPageTitle(page); | ||
expect(pageTitle).to.contains(moduleManagerPage.pageTitle); | ||
}); | ||
|
||
it(`should search for module ${moduleInformation.name}`, async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'searchForModule', baseContext); | ||
|
||
const isModuleVisible = await moduleManagerPage.searchModule(page, moduleInformation); | ||
expect(isModuleVisible).to.eq(true); | ||
}); | ||
|
||
it('should go to newsletter subscription module configuration page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToNewsletterModuleConfigPage', baseContext); | ||
|
||
await moduleManagerPage.searchModule(page, moduleInformation); | ||
await moduleManagerPage.goToConfigurationPage(page, moduleInformation.tag); | ||
|
||
const moduleConfigurationPageSubtitle = await moduleConfigurationPage.getPageSubtitle(page); | ||
expect(moduleConfigurationPageSubtitle).to.contains(moduleInformation.name); | ||
}); | ||
|
||
it('should check if user is unsubscribed from newsletter', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'checkThatEmailIsNotInTable', baseContext); | ||
|
||
const subscribedUserList = await psEmailSubscriptionPage.getListOfNewsletterRegistrationEmails(page); | ||
expect(subscribedUserList).to.not.contains(Customers.johnDoe.email); | ||
}); | ||
|
||
it('should logout from BO', async function () { | ||
await loginCommon.logoutBO(this, page); | ||
}); | ||
}); | ||
|
||
describe('Go to FO to subscribe to the newsletter', async () => { | ||
it('should open the shop page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToFOToSubscribeToNewsletter', baseContext); | ||
|
||
await homePage.goTo(page, global.FO.URL); | ||
|
||
const result = await homePage.isHomePage(page); | ||
expect(result).to.eq(true); | ||
}); | ||
|
||
it('should subscribe to newsletter', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'subscribeToNewsletter', baseContext); | ||
|
||
const newsletterSubscribeAlertMessage = await homePage.subscribeToNewsletter(page, Customers.johnDoe.email); | ||
expect(newsletterSubscribeAlertMessage).to.contains(homePage.successSubscriptionMessage); | ||
}); | ||
}); | ||
|
||
describe('Go to BO to check if correctly subscribed', async () => { | ||
it('should login in BO', async function () { | ||
await loginCommon.loginBO(this, page); | ||
}); | ||
|
||
it('should go to module manager page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goToBOToCheckIfSubscribed', baseContext); | ||
|
||
await dashboardPage.goToSubMenu( | ||
page, | ||
dashboardPage.modulesParentLink, | ||
dashboardPage.moduleManagerLink, | ||
); | ||
await moduleManagerPage.closeSfToolBar(page); | ||
|
||
const pageTitle = await moduleManagerPage.getPageTitle(page); | ||
expect(pageTitle).to.contains(moduleManagerPage.pageTitle); | ||
}); | ||
|
||
it('should go to newsletter subscription module configuration page', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'goBackToNewsletterModuleConfig', baseContext); | ||
|
||
await moduleManagerPage.searchModule(page, moduleInformation); | ||
await moduleManagerPage.goToConfigurationPage(page, moduleInformation.tag); | ||
|
||
const moduleConfigurationPageSubtitle = await moduleConfigurationPage.getPageSubtitle(page); | ||
expect(moduleConfigurationPageSubtitle).to.contains(moduleInformation.name); | ||
}); | ||
|
||
it('should check if previous customer subscription is visible in table', async function () { | ||
await testContext.addContextItem(this, 'testIdentifier', 'checkIfSubscriptionIsInTable', baseContext); | ||
|
||
const subscribedUserList = await psEmailSubscriptionPage.getListOfNewsletterRegistrationEmails(page); | ||
expect(subscribedUserList).to.contains(Customers.johnDoe.email); | ||
}); | ||
|
||
it('should logout from BO', async function () { | ||
await loginCommon.logoutBO(this, page); | ||
}); | ||
}); | ||
|
||
// Post-condition : Uninstall Hummingbird | ||
uninstallHummingbird(`${baseContext}_postTest`); | ||
}); |
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