-
Notifications
You must be signed in to change notification settings - Fork 450
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(structure): uncaught error while swapping images in array in PTE (#…
…6399) * chore(test-studio): add schema for fix * fix(structure): console error for when selection is zero * chore(test-studio): update test schema * chore(core): remove try catch * test(pte): add test for usecase * chore(sanity): remove ? since it will always be defined Co-authored-by: Pedro Bonamin <[email protected]> * chore(test): fix test file to have .spec. --------- Co-authored-by: Pedro Bonamin <[email protected]>
- Loading branch information
1 parent
457bba2
commit 6508065
Showing
3 changed files
with
87 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import {expect} from '@playwright/test' | ||
import {test} from '@sanity/test' | ||
|
||
test('Portable Text Input - Array Input of images dragging an image will not trigger range out of bounds (toast)', async ({ | ||
page, | ||
createDraftDocument, | ||
}) => { | ||
await createDraftDocument('/test/content/input-standard;portable-text;pt_allTheBellsAndWhistles') | ||
|
||
// set up the portable text editor | ||
await page.getByTestId('field-body').focus() | ||
await page.getByTestId('field-body').click() | ||
|
||
await page | ||
.getByTestId('insert-menu-auto-collapse-menu') | ||
.getByRole('button', {name: 'Insert Image slideshow (block)'}) | ||
.click() | ||
|
||
// set up for the PTE block | ||
await page.getByRole('button', {name: 'Add item'}).click() | ||
await page.getByTestId('file-input-multi-browse-button').click() | ||
await page.getByTestId('file-input-browse-button-sanity-default').click() | ||
|
||
// grab an image | ||
await page.getByRole('button', {name: 'capybara.jpg'}).click() | ||
await page.getByLabel('Edit Image With Caption').getByLabel('Close dialog').click() | ||
|
||
// grab drag element in array element | ||
await page.locator("[data-sanity-icon='drag-handle']").hover() | ||
|
||
// drag and drop element | ||
await page.mouse.down() | ||
await page.getByRole('button', {name: 'Add item'}).hover() | ||
await page.mouse.up() | ||
|
||
await page.locator( | ||
`:has-text("Failed to execute 'getRangeAt' on 'Selection': 0 is not a valid index.']`, | ||
) | ||
|
||
// check that the alert is not visible | ||
await expect(await page.getByRole('alert').locator('div').nth(1)).not.toBeVisible() | ||
}) |