Skip to content

Commit 4e8b0c1

Browse files
committed
signout test
1 parent cfd1f7d commit 4e8b0c1

4 files changed

Lines changed: 39 additions & 2 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
export enum AccountHeaderOptions {
2+
MY_ACCOUNT = 'My Account',
3+
MY_WISH_LIST = 'My Wish List',
4+
SIGN_OUT = 'Sign Out',
5+
}

pages/LumaMainPage.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { CartActionsOptionalParamsInterface, ClientSideValiationErrorOptionalPar
55
import { MenuBarCategories } from "../common/navigationEnums/menuBarCategories/MenuBarCategories";
66
import { MenuBarSubCategories } from "../common/navigationEnums/menuBarSubCategories/MenuBarSubCategories";
77
import { ItemShoppingComponentPage } from "./pageComponents/productShoppingComponent/ItemShoppingPage";
8+
import { AccountHeaderOptions } from "../common/accountHeader/AccountHeaderOptions";
89

910
export class LumaMainPage extends BasePage {
1011
private searchBoxLocator = '#search';
@@ -28,6 +29,8 @@ export class LumaMainPage extends BasePage {
2829
protected pageMessageCaptionLocator = '[class="page messages"]'
2930
private navigationMenuBar = '.navigation a';
3031
private dialogFooterLocator = '[class="modal-footer"]';
32+
private loggedInAttributeLocator = '.logged-in';
33+
private accountDownArrowButtonLocator = '[class="panel header"] .customer-welcome'
3134

3235
public async chooseMenuBarOption(menuBarItem: MenuBar) {
3336
let menuBarValue = this.page.locator(this.navigationMenuBar, { hasText: new RegExp(`^\\${menuBarItem.valueOf()}\\b$`, 'i') });
@@ -340,4 +343,17 @@ export class LumaMainPage extends BasePage {
340343
}
341344
expect(tableRowCellValues).toEqual(expectedCellValues);
342345
}
346+
347+
/**
348+
* @description clicks on the logged in user account header down arrow button and chooses one of the options - my account, my wish list and sign out
349+
*/
350+
public async clickAndChooseAccountOption(accountHeaderOption: AccountHeaderOptions) {
351+
const userGreet = this.page.locator(this.userWelcomeCaptionLocator);
352+
if (await userGreet.isVisible()) {
353+
await this.clickElement(this.accountDownArrowButtonLocator);
354+
await this.clickOnLink(accountHeaderOption.valueOf());
355+
} else {
356+
throw new Error(`user may be signed out and therefore the account options are not available`)
357+
}
358+
}
343359
}

pages/pageComponents/productShoppingComponent/ItemShoppingPage.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class ItemShoppingComponentPage extends BasePage {
2424
* in the test
2525
*/
2626
public async chooseProductItem(productName: string, options?: ProductItemOptionalParamsInterface) {
27-
const productItem = await this.deterimeItemScope(productName);
27+
const productItem = await this.getProductItemScopeLocator(productName);
2828
await this.hover(productItem);
2929
try {
3030
if (options?.chooseSize && options.size !== undefined) {
@@ -81,7 +81,7 @@ export class ItemShoppingComponentPage extends BasePage {
8181
* @param itemText
8282
* @returns
8383
*/
84-
private async deterimeItemScope(itemText: string) {
84+
private async getProductItemScopeLocator(itemText: string) {
8585
let itemLocator: Locator | undefined;
8686
let currentPageUrl = await this.getPageUrl();
8787
if (currentPageUrl.includes('cart')) {
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
import { expect } from '@playwright/test'
2+
import { AccountHeaderOptions } from '../../common/accountHeader/AccountHeaderOptions'
3+
import { test } from '../../helpers/fixtures/customFixtures/CustomFixtures'
4+
5+
test('logout basic test', { tag: ['@LOGIN'] }, async ({ loadAppAndLogin, loginPage }) => {
6+
let user: string = 'John Doe'
7+
let notLoggedInState: string = 'not-logged-in'
8+
await test.step('use the login fixture and validate user is logged in', async () => {
9+
await loginPage.validateLoggedInUser(user)
10+
})
11+
await test.step('sign out and validate user is signed out', async () => {
12+
await loginPage.clickAndChooseAccountOption(AccountHeaderOptions.SIGN_OUT);
13+
const loggedInState = await loginPage.getLoggedInState()
14+
expect(loggedInState).toBe(notLoggedInState);
15+
})
16+
})

0 commit comments

Comments
 (0)