Files
Ferdinand Thiessen 49dec7388e test(playwright): answer password confirmation via a locator handler
The dialog only appears once a session's confirmation window has expired, so
the old helper probed for it for 500 ms and silently skipped it on a slow
shard, leaving the guarded request unsent; its wait for the dialog to close
was unbounded.

Install a locator handler per logged-in page instead, and use
awaitPasswordGuardedRequest() where a response promise is awaited, since
handlers never run during a bare waitForResponse.

Assisted-by: ClaudeCode:claude-opus-5
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
2026-09-16 00:57:55 +02:00

47 lines
1.5 KiB
TypeScript

/*
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { Page, Response } from '@playwright/test'
import { awaitPasswordGuardedRequest } from './password-confirmation.ts'
/**
* Wait for the request that persists an account property or its scope.
*
* Register the listener before triggering the change - account properties are
* saved with a debounce - and await it after the change.
*
* @param page - The Playwright page object
*/
export function waitForPropertySave(page: Page): Promise<Response> {
return page.waitForResponse((r) => r.request().method() === 'PUT' && r.url().includes('/ocs/v2.php/cloud/users/'))
}
/**
* Wait for the request that persists the profile visibility of a property.
*
* @param page - The Playwright page object
*/
export function waitForVisibilitySave(page: Page): Promise<Response> {
return page.waitForResponse((r) => r.request().method() === 'PUT' && r.url().includes('/ocs/v2.php/profile/'))
}
/**
* Perform an account-property change and wait for its save request.
*
* @param page - The Playwright page object
* @param change - Action that triggers the save request
* @param waitForSave - Request matcher for the property being changed
*/
export async function saveAccountProperty(
page: Page,
change: () => Promise<void>,
waitForSave: (page: Page) => Promise<Response> = waitForPropertySave,
): Promise<void> {
const saved = waitForSave(page)
await change()
await awaitPasswordGuardedRequest(page, saved)
}