Skip to content

Commit

Permalink
Merge pull request PrestaShop#35302 from nesrineabdmouleh/TEST-4984
Browse files Browse the repository at this point in the history
Functional tests - Add new test in 'FO > Hummingbird > logout from user account page'
  • Loading branch information
nesrineabdmouleh authored Feb 12, 2024
2 parents 040d786 + 0d721d7 commit 7a2ee26
Showing 1 changed file with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// Import utils
import helper from '@utils/helpers';
import testContext from '@utils/testContext';
import files from '@utils/files';

// Import common tests
import {installHummingbird, uninstallHummingbird} from '@commonTests/FO/hummingbird';

// 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 data
import Customers from '@data/demo/customers';

import {expect} from 'chai';
import type {BrowserContext, Page} from 'playwright';

const baseContext: string = 'functional_FO_hummingbird_userAccount_logOut';

describe('FO - User Account : LogOut', async () => {
let browserContext: BrowserContext;
let page: Page;

// 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('Logout in FO', async () => {
it('should open the shop page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToShopFO', baseContext);

await homePage.goTo(page, global.FO.URL);

const result = await homePage.isHomePage(page);
expect(result).to.eq(true);
});

it('should logIn', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'enterValidCredentials', baseContext);

await homePage.goToLoginPage(page);
await loginPage.customerLogin(page, Customers.johnDoe);

const isCustomerConnected = await loginPage.isCustomerConnected(page);
expect(isCustomerConnected, 'Customer is not connected!').to.eq(true);

const result = await homePage.isHomePage(page);
expect(result).to.eq(true);
});

it('should go to my account page', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'goToAccountPage', baseContext);

await homePage.goToMyAccountPage(page);

const pageTitle = await myAccountPage.getPageTitle(page);
expect(pageTitle).to.equal(myAccountPage.pageTitle);
});

it('should logOut with link in the footer', async function () {
await testContext.addContextItem(this, 'testIdentifier', 'signOutWithLinkAtAccountPage', baseContext);

await myAccountPage.logout(page);

const isCustomerConnected = await myAccountPage.isCustomerConnected(page);
expect(isCustomerConnected, 'Customer is connected!').to.eq(false);
});
});

// Post-condition : Uninstall Hummingbird
uninstallHummingbird(`${baseContext}_postTest`);
});

0 comments on commit 7a2ee26

Please sign in to comment.