Fixes #14032. When duplicating arrays that contains nested arrays, the newly duplicated row will include twice as many fields within the nested array as the original. This is because duplicated row ids don't match 1:1 with their parent's `rows` property. For example: `array.0.nestedArray.0.id` should match `array.0.nestedArray.rows[0].id`. The problem is that when we duplicate the row, we regenerate all nested id fields, but we fail to sync them its corresponding row in its parent field. When we go to build form state on the server, we build new fields for this stale row. Then when we merge server form state back into local state, those new fields are simply _merged_ with the local state without replacing them. This is how we determine whether local changes to a row took place while a form state request was pending. It is important to prevent the merge strategy from overriding your active changes. --- - To see the specific tasks where the Asana app for GitHub is being used, see below: - https://app.asana.com/0/0/1211543194775558
34 lines
1005 B
TypeScript
34 lines
1005 B
TypeScript
import type { Locator, Page } from 'playwright'
|
|
|
|
import { expect } from 'playwright/test'
|
|
|
|
import { openArrayRowActions } from './openArrayRowActions.js'
|
|
|
|
/**
|
|
* Duplicates the array row at the specified index.
|
|
*/
|
|
export const duplicateArrayRow = async (
|
|
page: Page,
|
|
{ fieldName, rowIndex = 0 }: Parameters<typeof openArrayRowActions>[1],
|
|
): Promise<{
|
|
popupContentLocator: Locator
|
|
rowActionsButtonLocator: Locator
|
|
}> => {
|
|
const rowLocator = page.locator(`#field-${fieldName} > .array-field__draggable-rows > *`)
|
|
|
|
const numberOfPrevRows = await rowLocator.count()
|
|
|
|
const { popupContentLocator, rowActionsButtonLocator } = await openArrayRowActions(page, {
|
|
fieldName,
|
|
rowIndex,
|
|
})
|
|
|
|
await popupContentLocator.locator('.array-actions__action.array-actions__duplicate').click()
|
|
|
|
expect(await rowLocator.count()).toBe(numberOfPrevRows + 1)
|
|
|
|
// TODO: test the array row's field input values have been duplicated as well
|
|
|
|
return { popupContentLocator, rowActionsButtonLocator }
|
|
}
|