Reduce flake on edit mock test
This commit is contained in:
parent
d6db3f7943
commit
ecf5019cd6
2 changed files with 22 additions and 1 deletions
|
@ -1,6 +1,8 @@
|
|||
// Copyright 2023 Signal Messenger, LLC
|
||||
// SPDX-License-Identifier: AGPL-3.0-only
|
||||
|
||||
import type { Locator } from 'playwright';
|
||||
|
||||
export function bufferToUuid(buffer: Buffer): string {
|
||||
const hex = buffer.toString('hex');
|
||||
|
||||
|
@ -12,3 +14,21 @@ export function bufferToUuid(buffer: Buffer): string {
|
|||
hex.substring(20),
|
||||
].join('-');
|
||||
}
|
||||
|
||||
export async function type(input: Locator, text: string): Promise<void> {
|
||||
let currentValue = '';
|
||||
|
||||
try {
|
||||
currentValue = await input.inputValue();
|
||||
} catch (e) {
|
||||
// if input is actually not an input (e.g. contenteditable)
|
||||
currentValue = (await input.textContent()) ?? '';
|
||||
}
|
||||
|
||||
// Type with a reasonably human delay
|
||||
await input.type(text, { delay: 100 });
|
||||
|
||||
// Wait to ensure that the input (and react state controlling it) has actually
|
||||
// updated with the right value
|
||||
await input.locator(`:text("${currentValue}${text}")`).waitFor();
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@ import { drop } from '../../util/drop';
|
|||
import { strictAssert } from '../../util/assert';
|
||||
import { generateAci } from '../../types/ServiceId';
|
||||
import { IMAGE_GIF } from '../../types/MIME';
|
||||
import { type } from '../helpers';
|
||||
|
||||
export const debug = createDebug('mock:test:edit');
|
||||
|
||||
|
@ -505,7 +506,7 @@ describe('editing', function (this: Mocha.Suite) {
|
|||
.click();
|
||||
await page.getByRole('menuitem', { name: 'Edit' }).click();
|
||||
const input = await app.waitForEnabledComposer();
|
||||
await input.type(additionalText);
|
||||
await type(input, additionalText);
|
||||
await input.press('Enter');
|
||||
}
|
||||
const { contacts, desktop } = bootstrap;
|
||||
|
|
Loading…
Add table
Reference in a new issue