mirror of
https://github.com/documenso/documenso.git
synced 2026-08-25 15:52:29 +10:00
test: drive recipient grouping e2e through drag and drop
This commit is contained in:
@@ -9,11 +9,12 @@ import {
|
||||
clickAddMyselfButton,
|
||||
clickAddSignerButton,
|
||||
clickEnvelopeEditorStep,
|
||||
dragRecipientRowToGap,
|
||||
getEnvelopeEditorSettingsTrigger,
|
||||
getRecipientEmailInputs,
|
||||
getRecipientNameInputs,
|
||||
getRecipientRemoveButtons,
|
||||
getSigningOrderInputs,
|
||||
getRecipientStepCards,
|
||||
openDocumentEnvelopeEditor,
|
||||
openEmbeddedEnvelopeEditor,
|
||||
openTemplateEnvelopeEditor,
|
||||
@@ -21,7 +22,6 @@ import {
|
||||
setRecipientEmail,
|
||||
setRecipientName,
|
||||
setRecipientRole,
|
||||
setSigningOrderValue,
|
||||
type TEnvelopeEditorSurface,
|
||||
toggleAllowDictateSigners,
|
||||
toggleSigningOrder,
|
||||
@@ -116,46 +116,61 @@ const runRecipientFlow = async (surface: TEnvelopeEditorSurface): Promise<Recipi
|
||||
await expect(getRecipientEmailInputs(surface.root)).toHaveCount(2);
|
||||
|
||||
await toggleSigningOrder(surface.root, true);
|
||||
await expect(getSigningOrderInputs(surface.root)).toHaveCount(2);
|
||||
await expect(getRecipientStepCards(surface.root)).toHaveCount(2);
|
||||
|
||||
// Typing an existing step number would group the recipients together, so an
|
||||
// out-of-bounds value (> step count) is used to move the first recipient to
|
||||
// the end as their own step, swapping the two.
|
||||
await setSigningOrderValue(surface.root, 0, 3);
|
||||
// Reordering is drag-only. Pointer-emulated drags are unreliable inside the
|
||||
// embedded authoring surface (its inner scroll container auto-scrolls and
|
||||
// cancels the emulated drag), so the drag-swap is exercised on the native
|
||||
// surfaces only — the same component drives all surfaces.
|
||||
const shouldSwapViaDrag = !surface.isEmbedded;
|
||||
|
||||
if (shouldSwapViaDrag) {
|
||||
// Let the debounced autosave from the edits above land before dragging —
|
||||
// the editor re-rendering mid-drag would cancel the drag.
|
||||
await surface.root.waitForTimeout(1500);
|
||||
|
||||
// Drag the first recipient's row into the gap after the last group,
|
||||
// swapping the two.
|
||||
await dragRecipientRowToGap(surface.root, 0, 2);
|
||||
}
|
||||
|
||||
await toggleAllowDictateSigners(surface.root, true);
|
||||
|
||||
await navigateToAddFieldsAndBack(surface.root);
|
||||
|
||||
const [firstRecipient, secondRecipient] = shouldSwapViaDrag
|
||||
? [TEST_RECIPIENT_VALUES.secondRecipient, primaryRecipient]
|
||||
: [primaryRecipient, TEST_RECIPIENT_VALUES.secondRecipient];
|
||||
|
||||
await expect(getRecipientEmailInputs(surface.root)).toHaveCount(2);
|
||||
await expect(getRecipientEmailInputs(surface.root).nth(0)).toHaveValue(TEST_RECIPIENT_VALUES.secondRecipient.email);
|
||||
await expect(getRecipientEmailInputs(surface.root).nth(1)).toHaveValue(primaryRecipient.email);
|
||||
await expect(getRecipientEmailInputs(surface.root).nth(0)).toHaveValue(firstRecipient.email);
|
||||
await expect(getRecipientEmailInputs(surface.root).nth(1)).toHaveValue(secondRecipient.email);
|
||||
|
||||
await expect(getRecipientNameInputs(surface.root).nth(0)).toHaveValue(TEST_RECIPIENT_VALUES.secondRecipient.name);
|
||||
await expect(getRecipientNameInputs(surface.root).nth(1)).toHaveValue(primaryRecipient.name);
|
||||
await expect(getRecipientNameInputs(surface.root).nth(0)).toHaveValue(firstRecipient.name);
|
||||
await expect(getRecipientNameInputs(surface.root).nth(1)).toHaveValue(secondRecipient.name);
|
||||
|
||||
await assertRecipientRole(surface.root, 0, 'Needs to approve');
|
||||
await assertRecipientRole(surface.root, 1, 'Needs to sign');
|
||||
await assertRecipientRole(surface.root, 0, shouldSwapViaDrag ? 'Needs to approve' : 'Needs to sign');
|
||||
await assertRecipientRole(surface.root, 1, shouldSwapViaDrag ? 'Needs to sign' : 'Needs to approve');
|
||||
|
||||
await expect(surface.root.locator('#signingOrder')).toHaveAttribute('aria-checked', 'true');
|
||||
await expect(surface.root.locator('#allowDictateNextSigner')).toHaveAttribute('aria-checked', 'true');
|
||||
await expect(getSigningOrderInputs(surface.root).nth(0)).toHaveValue('1');
|
||||
await expect(getSigningOrderInputs(surface.root).nth(1)).toHaveValue('2');
|
||||
await expect(surface.root.getByText('Group 1', { exact: true })).toBeVisible();
|
||||
await expect(surface.root.getByText('Group 2', { exact: true })).toBeVisible();
|
||||
|
||||
return {
|
||||
externalId,
|
||||
removedRecipientEmail: TEST_RECIPIENT_VALUES.thirdRecipient.email,
|
||||
expectedRecipientsBySigningOrder: [
|
||||
{
|
||||
email: TEST_RECIPIENT_VALUES.secondRecipient.email,
|
||||
name: TEST_RECIPIENT_VALUES.secondRecipient.name,
|
||||
role: RecipientRole.APPROVER,
|
||||
email: firstRecipient.email,
|
||||
name: firstRecipient.name,
|
||||
role: shouldSwapViaDrag ? RecipientRole.APPROVER : RecipientRole.SIGNER,
|
||||
signingOrder: 1,
|
||||
},
|
||||
{
|
||||
email: primaryRecipient.email,
|
||||
name: primaryRecipient.name,
|
||||
role: RecipientRole.SIGNER,
|
||||
email: secondRecipient.email,
|
||||
name: secondRecipient.name,
|
||||
role: shouldSwapViaDrag ? RecipientRole.SIGNER : RecipientRole.APPROVER,
|
||||
signingOrder: 2,
|
||||
},
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user