[WPB-26754] Logout tests#9687
Conversation
| "lodash": "4.18.1", | ||
| "logdown": "3.3.1", | ||
| "minimist": "1.2.8", | ||
| "open": "^11.0.0", |
There was a problem hiding this comment.
I noticed open is added to package.json, but I couldn't find any imports or usages of it in this PR. Is this dependency actually needed, or was it added unintentionally?
There was a problem hiding this comment.
I was meant for testing deep links, it will be needed later, but I could remove it for now or leave it for future
It's added anyway but not explicitly
There was a problem hiding this comment.
Great then lets remove it for now and add it again when needed.
| clearDataCheckbox: app.page.getByTestId('modal-option-checkbox'), | ||
| cancelButton: app.page.getByTestId('do-secondary'), | ||
| logoutButton: app.page.getByTestId('do-action'), | ||
| }); |
There was a problem hiding this comment.
Modal Dismissal Not Tested
The "Cancel" button on the logout popup is created but never tested.
ESC key dismissal not tested.
There was a problem hiding this comment.
This logic is supposed to be tested on web, cancelButton has been added to have full functionality of the pop up available for future need
| }); | ||
|
|
||
| await test.step("User clicks 'Log Out' button on the popup", async () => { | ||
| app.page = app.windows()[2]; |
There was a problem hiding this comment.
Sensing a possible race condition here
app.page = app.windows()[2] relies on window order
If windows are created/destroyed in different order, this breaks. Shall we Use app.waitForEvent('window') or more stable window tracking.
There was a problem hiding this comment.
The idea is that windows are already created and are not destroyed.
We are checking that (while being on the account A) clicking the logout option in the account's B context menu will trigger the focus on the account B. But then we still need to manually assign app.page to account B which has index 2 because it doesn't happen automatically
There was a problem hiding this comment.
Alternatively we could find a not active window, e.g. like this
const userBWindow = app.windows().find(win => win !== app.page && win.url().startsWith('http'));
if (userBWindow) {
app.page = userBWindow;
}
There was a problem hiding this comment.
this is much better i think it finds the window by logic, not position and works regardless of window count or creation order.
Consider extracting this into a helper function since it might be useful in other tests.
export const switchToNonActiveWindow = async (app: App) => {
const inactiveWindow = app.windows().find(
win => win !== app.page && win.url().startsWith('http')
);
if (!inactiveWindow) {
throw new Error('No inactive window found');
}
app.page = inactiveWindow;
};
| export const loginUserAfterDataCleanup = async (page: Page, user: User) => { | ||
| await fillLoginCredentials(page, user); | ||
| const historyConfirmButton = loginPage(page).historyConfirmButton; | ||
| await historyConfirmButton.click(); |
There was a problem hiding this comment.
clicking historyConfirmButton without checking if it's visible assumes the history confirmation modal always appears. Should run expect().toBeVisible() first.
|



Uh oh!
There was an error while loading. Please reload this page.