Skip to content

Commit a7848aa

Browse files
committed
refactor: login desktop and browser tests common code
1 parent ac496fb commit a7848aa

File tree

3 files changed

+48
-74
lines changed

3 files changed

+48
-74
lines changed

test/spec/login-browser-integ-test.js

Lines changed: 5 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ define(function (require, exports, module) {
4949
verifyProfilePopupContent,
5050
cleanupTrialState,
5151
popupToAppear,
52+
performFullLogoutFlow,
53+
verifyProfileIconBlanked,
5254
VIEW_TRIAL_DAYS_LEFT,
5355
VIEW_PHOENIX_PRO,
5456
VIEW_PHOENIX_FREE,
@@ -86,7 +88,7 @@ define(function (require, exports, module) {
8688
"Profile button to be available",
8789
3000
8890
);
89-
SharedUtils = LoginShared.getSharedUtils(testWindow);
91+
SharedUtils = LoginShared.getSharedUtils(testWindow, LoginServiceExports);
9092
VIEW_TRIAL_DAYS_LEFT = SharedUtils.VIEW_TRIAL_DAYS_LEFT;
9193
VIEW_PHOENIX_PRO = SharedUtils.VIEW_PHOENIX_PRO;
9294
VIEW_PHOENIX_FREE = SharedUtils.VIEW_PHOENIX_FREE;
@@ -98,6 +100,8 @@ define(function (require, exports, module) {
98100
verifyProfilePopupContent = SharedUtils.verifyProfilePopupContent;
99101
cleanupTrialState = SharedUtils.cleanupTrialState;
100102
popupToAppear = SharedUtils.popupToAppear;
103+
performFullLogoutFlow = SharedUtils.performFullLogoutFlow;
104+
verifyProfileIconBlanked = SharedUtils.verifyProfileIconBlanked;
101105
}, 30000);
102106

103107
afterAll(async function () {
@@ -277,42 +281,6 @@ define(function (require, exports, module) {
277281
);
278282
}
279283

280-
function verifyProfileIconBlanked() {
281-
const $profileIcon = testWindow.$("#user-profile-button");
282-
const initialContent = $profileIcon.html();
283-
expect(initialContent).not.toContain('TU');
284-
}
285-
286-
async function performFullLogoutFlow() {
287-
// Click profile button to open popup
288-
const $profileButton = testWindow.$("#user-profile-button");
289-
$profileButton.trigger('click');
290-
291-
// Wait for profile popup
292-
await popupToAppear(PROFILE_POPUP);
293-
294-
// Find and click sign out button
295-
let popupContent = testWindow.$('.profile-popup');
296-
const signOutButton = popupContent.find('#phoenix-signout-btn');
297-
signOutButton.trigger('click');
298-
299-
// Wait for sign out confirmation dialog and dismiss it
300-
await testWindow.__PR.waitForModalDialog(".modal");
301-
testWindow.__PR.clickDialogButtonID(testWindow.__PR.Dialogs.DIALOG_BTN_OK);
302-
await testWindow.__PR.waitForModalDialogClosed(".modal");
303-
304-
// Wait for sign out to complete
305-
await awaitsFor(
306-
function () {
307-
return !LoginServiceExports.LoginService.isLoggedIn();
308-
},
309-
"User to be signed out",
310-
10000
311-
);
312-
313-
verifyProfileIconBlanked();
314-
}
315-
316284
describe("Browser Login Tests", function () {
317285

318286
beforeEach(async function () {

test/spec/login-desktop-integ-test.js

Lines changed: 5 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ define(function (require, exports, module) {
5757
verifyProfilePopupContent,
5858
cleanupTrialState,
5959
popupToAppear,
60+
performFullLogoutFlow,
61+
verifyProfileIconBlanked,
6062
VIEW_TRIAL_DAYS_LEFT,
6163
VIEW_PHOENIX_PRO,
6264
VIEW_PHOENIX_FREE,
@@ -94,7 +96,7 @@ define(function (require, exports, module) {
9496
"Profile button to be available",
9597
3000
9698
);
97-
SharedUtils = LoginShared.getSharedUtils(testWindow);
99+
SharedUtils = LoginShared.getSharedUtils(testWindow, LoginServiceExports);
98100
VIEW_TRIAL_DAYS_LEFT = SharedUtils.VIEW_TRIAL_DAYS_LEFT;
99101
VIEW_PHOENIX_PRO = SharedUtils.VIEW_PHOENIX_PRO;
100102
VIEW_PHOENIX_FREE = SharedUtils.VIEW_PHOENIX_FREE;
@@ -106,6 +108,8 @@ define(function (require, exports, module) {
106108
verifyProfilePopupContent = SharedUtils.verifyProfilePopupContent;
107109
cleanupTrialState = SharedUtils.cleanupTrialState;
108110
popupToAppear = SharedUtils.popupToAppear;
111+
performFullLogoutFlow = SharedUtils.performFullLogoutFlow;
112+
verifyProfileIconBlanked = SharedUtils.verifyProfileIconBlanked;
109113
}, 30000);
110114

111115
afterAll(async function () {
@@ -289,41 +293,6 @@ define(function (require, exports, module) {
289293
);
290294
}
291295

292-
async function performFullLogoutFlow() {
293-
// Click profile button to open popup
294-
const $profileButton = testWindow.$("#user-profile-button");
295-
$profileButton.trigger('click');
296-
297-
// Wait for profile popup
298-
await popupToAppear(PROFILE_POPUP);
299-
300-
// Find and click sign out button
301-
let popupContent = testWindow.$('.profile-popup');
302-
const signOutButton = popupContent.find('#phoenix-signout-btn');
303-
signOutButton.trigger('click');
304-
305-
// Wait for sign out confirmation dialog and dismiss it
306-
await testWindow.__PR.waitForModalDialog(".modal");
307-
testWindow.__PR.clickDialogButtonID(testWindow.__PR.Dialogs.DIALOG_BTN_OK);
308-
await testWindow.__PR.waitForModalDialogClosed(".modal");
309-
310-
// Wait for sign out to complete
311-
await awaitsFor(
312-
function () {
313-
return !LoginServiceExports.LoginService.isLoggedIn();
314-
},
315-
"User to be signed out",
316-
10000
317-
);
318-
verifyProfileIconBlanked();
319-
}
320-
321-
function verifyProfileIconBlanked() {
322-
const $profileIcon = testWindow.$("#user-profile-button");
323-
const initialContent = $profileIcon.html();
324-
expect(initialContent).not.toContain('TU');
325-
}
326-
327296
describe("Desktop Login and Promotion Tests", function () {
328297

329298
beforeEach(async function () {

test/spec/login-shared.js

Lines changed: 38 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
define(function (require, exports, module) {
55

6-
function getSharedUtils(testWindow) {
6+
function getSharedUtils(testWindow, LoginServiceExports) {
77
// Helper functions for promotion testing (browser-specific)
88
async function setupTrialState(daysRemaining) {
99
const PromotionExports = testWindow._test_promo_login_exports;
@@ -135,13 +135,50 @@ define(function (require, exports, module) {
135135
);
136136
}
137137

138+
function verifyProfileIconBlanked() {
139+
const $profileIcon = testWindow.$("#user-profile-button");
140+
const initialContent = $profileIcon.html();
141+
expect(initialContent).not.toContain('TU');
142+
}
143+
144+
async function performFullLogoutFlow() {
145+
// Click profile button to open popup
146+
const $profileButton = testWindow.$("#user-profile-button");
147+
$profileButton.trigger('click');
148+
149+
// Wait for profile popup
150+
await popupToAppear(PROFILE_POPUP);
151+
152+
// Find and click sign out button
153+
let popupContent = testWindow.$('.profile-popup');
154+
const signOutButton = popupContent.find('#phoenix-signout-btn');
155+
signOutButton.trigger('click');
156+
157+
// Wait for sign out confirmation dialog and dismiss it
158+
await testWindow.__PR.waitForModalDialog(".modal");
159+
testWindow.__PR.clickDialogButtonID(testWindow.__PR.Dialogs.DIALOG_BTN_OK);
160+
await testWindow.__PR.waitForModalDialogClosed(".modal");
161+
162+
// Wait for sign out to complete
163+
await awaitsFor(
164+
function () {
165+
return !LoginServiceExports.LoginService.isLoggedIn();
166+
},
167+
"User to be signed out",
168+
10000
169+
);
170+
verifyProfileIconBlanked();
171+
}
172+
138173
return {
139174
setupTrialState,
140175
setupExpiredTrial,
141176
verifyProBranding,
142177
verifyProfilePopupContent,
143178
cleanupTrialState,
144179
popupToAppear,
180+
performFullLogoutFlow,
181+
verifyProfileIconBlanked,
145182
VIEW_TRIAL_DAYS_LEFT,
146183
VIEW_PHOENIX_PRO,
147184
VIEW_PHOENIX_FREE,

0 commit comments

Comments
 (0)