Skip to content

Commit f276b7c

Browse files
committed
test: carry the copypaste touch-emulation skips with the instance widening
These skips guard tests that drive selection/resizing with positional mouse drags, which have no touch-emulation equivalent. They used to ship with the test infrastructure; review pointed out they belong here, where the android instance actually starts running the copypaste suite.
1 parent 15fbaf9 commit f276b7c

1 file changed

Lines changed: 82 additions & 73 deletions

File tree

tests/src/end-to-end/copypaste/copypaste.test.tsx

Lines changed: 82 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ import {
2525
import { getRect, mouseSequence } from "../../utils/mouse.js";
2626
import { executeSlashCommand } from "../../utils/slashmenu.js";
2727

28+
// The android browser instance runs this suite too (see
29+
// vite.config.browser.ts); tests that drive selection or resizing with
30+
// positional mouse drags don't translate to the touch-emulated context:
31+
const onAndroid = /android/i.test(navigator.userAgent);
32+
2833
describe("Check Copy/Paste Functionality", () => {
2934
beforeEach(async () => {
3035
await render(<TestingApp />);
@@ -128,51 +133,53 @@ describe("Check Copy/Paste Functionality", () => {
128133
},
129134
);
130135

131-
test.skipIf(browserName === "firefox" || browserName === "webkit")(
132-
"Images should keep props",
133-
async () => {
134-
await focusOnEditor();
135-
await userEvent.keyboard("paragraph");
136-
137-
const IMAGE_EMBED_URL = "https://placehold.co/800x540.png";
138-
await executeSlashCommand("image");
139-
140-
await userEvent.click(await waitForSelector(`[data-test="embed-tab"]`));
141-
await userEvent.click(await waitForSelector(`[data-test="embed-input"]`));
142-
await userEvent.keyboard(IMAGE_EMBED_URL);
143-
await userEvent.click(
144-
await waitForSelector(`[data-test="embed-input-button"]`),
145-
);
146-
await waitForSelector(`img[src="${IMAGE_EMBED_URL}"]`);
147-
148-
await userEvent.click(await waitForSelector(`img`));
149-
150-
await waitForSelector(`[class*="bn-resize-handle"][style*="right"]`);
151-
const resizeHandleBoundingBox = getRect(
152-
`[class*="bn-resize-handle"][style*="right"]`,
153-
);
154-
await mouseSequence([
155-
{
156-
type: "move",
157-
x: resizeHandleBoundingBox.x + resizeHandleBoundingBox.width / 2,
158-
y: resizeHandleBoundingBox.y + resizeHandleBoundingBox.height / 2,
159-
steps: 5,
160-
},
161-
{ type: "down" },
162-
{
163-
type: "move",
164-
x: resizeHandleBoundingBox.x + resizeHandleBoundingBox.width / 2 - 50,
165-
y: resizeHandleBoundingBox.y + resizeHandleBoundingBox.height / 2,
166-
steps: 5,
167-
},
168-
{ type: "up" },
169-
]);
170-
171-
await copyPaste();
172-
173-
await compareDocToSnapshot("images");
174-
},
175-
);
136+
// Skipped on android: sets previewWidth by mouse-dragging the resize
137+
// handle, which doesn't operate under touch emulation, so the prop is
138+
// legitimately absent from the pasted result.
139+
test.skipIf(
140+
browserName === "firefox" || browserName === "webkit" || onAndroid,
141+
)("Images should keep props", async () => {
142+
await focusOnEditor();
143+
await userEvent.keyboard("paragraph");
144+
145+
const IMAGE_EMBED_URL = "https://placehold.co/800x540.png";
146+
await executeSlashCommand("image");
147+
148+
await userEvent.click(await waitForSelector(`[data-test="embed-tab"]`));
149+
await userEvent.click(await waitForSelector(`[data-test="embed-input"]`));
150+
await userEvent.keyboard(IMAGE_EMBED_URL);
151+
await userEvent.click(
152+
await waitForSelector(`[data-test="embed-input-button"]`),
153+
);
154+
await waitForSelector(`img[src="${IMAGE_EMBED_URL}"]`);
155+
156+
await userEvent.click(await waitForSelector(`img`));
157+
158+
await waitForSelector(`[class*="bn-resize-handle"][style*="right"]`);
159+
const resizeHandleBoundingBox = getRect(
160+
`[class*="bn-resize-handle"][style*="right"]`,
161+
);
162+
await mouseSequence([
163+
{
164+
type: "move",
165+
x: resizeHandleBoundingBox.x + resizeHandleBoundingBox.width / 2,
166+
y: resizeHandleBoundingBox.y + resizeHandleBoundingBox.height / 2,
167+
steps: 5,
168+
},
169+
{ type: "down" },
170+
{
171+
type: "move",
172+
x: resizeHandleBoundingBox.x + resizeHandleBoundingBox.width / 2 - 50,
173+
y: resizeHandleBoundingBox.y + resizeHandleBoundingBox.height / 2,
174+
steps: 5,
175+
},
176+
{ type: "up" },
177+
]);
178+
179+
await copyPaste();
180+
181+
await compareDocToSnapshot("images");
182+
});
176183
});
177184

178185
describe("Check Copy/Paste From Non-Editable Block", () => {
@@ -183,32 +190,34 @@ describe("Check Copy/Paste From Non-Editable Block", () => {
183190

184191
// Firefox doesn't yet support the async clipboard API. Webkit copy/paste
185192
// stopped working after updating to Playwright 1.33.
186-
test.skipIf(browserName === "firefox" || browserName === "webkit")(
187-
"Should be able to copy/paste text from a non-editable block",
188-
async () => {
189-
// Click and drag across the non-editable block's text to select part of it.
190-
const box = getRect('[data-content-type="nonEditable"] p');
191-
await mouseSequence([
192-
{ type: "move", x: box.x + 2, y: box.y + box.height / 2 },
193-
{ type: "down" },
194-
{
195-
type: "move",
196-
x: box.x + box.width * 0.25,
197-
y: box.y + box.height / 2,
198-
steps: 5,
199-
},
200-
{ type: "up" },
201-
]);
202-
203-
await userEvent.keyboard(`{${MOD}>}c{/${MOD}}`);
204-
205-
// Click the trailing block to create a new empty paragraph and focus
206-
// the editor there.
207-
await userEvent.click(await waitForSelector(DOC_TRAILING_BLOCK_SELECTOR));
208-
209-
await userEvent.keyboard(`{${MOD}>}v{/${MOD}}`);
210-
211-
await compareDocToSnapshot("nonEditableBlock");
212-
},
213-
);
193+
// Skipped on android: selects text with a positional mouse drag, which
194+
// doesn't operate under touch emulation — Mod+C then copies nothing and the
195+
// paste emits whatever the previous test left on the shared clipboard.
196+
test.skipIf(
197+
browserName === "firefox" || browserName === "webkit" || onAndroid,
198+
)("Should be able to copy/paste text from a non-editable block", async () => {
199+
// Click and drag across the non-editable block's text to select part of it.
200+
const box = getRect('[data-content-type="nonEditable"] p');
201+
await mouseSequence([
202+
{ type: "move", x: box.x + 2, y: box.y + box.height / 2 },
203+
{ type: "down" },
204+
{
205+
type: "move",
206+
x: box.x + box.width * 0.25,
207+
y: box.y + box.height / 2,
208+
steps: 5,
209+
},
210+
{ type: "up" },
211+
]);
212+
213+
await userEvent.keyboard(`{${MOD}>}c{/${MOD}}`);
214+
215+
// Click the trailing block to create a new empty paragraph and focus
216+
// the editor there.
217+
await userEvent.click(await waitForSelector(DOC_TRAILING_BLOCK_SELECTOR));
218+
219+
await userEvent.keyboard(`{${MOD}>}v{/${MOD}}`);
220+
221+
await compareDocToSnapshot("nonEditableBlock");
222+
});
214223
});

0 commit comments

Comments
 (0)