/* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file * distributed with this work for additional information * regarding copyright ownership. The ASF licenses this file * to you under the Apache License, Version 2.0 (the * "License"); you may not use this file except in compliance * with the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, * software distributed under the License is distributed on an * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * KIND, either express or implied. See the License for the * specific language governing permissions and limitations * under the License. */ import { test, expect } from "../../__fixtures__/base"; test.describe("Selection", () => { test.describe("Context menu", () => { test.beforeEach(async ({ stories, page, monaco }) => { await stories.openRelation(); await monaco.fill({ monacoParentLocator: page, content: '"test"' }); }); test.describe(() => { test.beforeEach(async ({ clipboard, context, browserName }) => { test.skip( browserName === "webkit", "Playwright Webkit doesn't support clipboard permissions: https://github.com/microsoft/playwright/issues/13037" ); clipboard.setup(context, browserName); }); test("should use copy from selection context menu", async ({ page, clipboard }) => { await page.getByTestId("monaco-container").click({ button: "right" }); await page.getByRole("menuitem", { name: "Copy" }).click(); await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); await page.getByTestId("monaco-container").click(); await page.keyboard.press("Delete"); await expect(page.getByRole("row", { name: "1" }).nth(1)).not.toContainText("test"); await clipboard.paste(); await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); }); test("should use cut from selection context menu", async ({ page, clipboard }) => { await page.getByTestId("monaco-container").click({ button: "right" }); await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); await page.getByRole("menuitem", { name: "Cut" }).click(); await expect(page.getByRole("row", { name: "1" }).nth(1)).not.toContainText("test"); await page.getByTestId("monaco-container").click(); await clipboard.paste(); await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); }); test("should use copy and paste from selection context menu", async ({ page }) => { await page.getByTestId("monaco-container").click({ button: "right" }); await page.getByRole("menuitem", { name: "Copy" }).click(); await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); await page.getByTestId("monaco-container").click(); await page.keyboard.press("Delete"); await expect(page.getByRole("row", { name: "1" }).nth(1)).not.toContainText("test"); await page.getByTestId("monaco-container").click({ button: "right" }); await page.getByRole("menuitem", { name: "Paste" }).click(); await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); }); test("should use cut and paste from selection context menu", async ({ page, context }) => { await page.getByTestId("monaco-container").click({ button: "right" }); await page.getByRole("menuitem", { name: "Cut" }).click(); await expect(page.getByRole("row", { name: "1" }).nth(1)).not.toContainText("test"); await page.getByTestId("monaco-container").click(); await page.getByTestId("monaco-container").click({ button: "right" }); await page.getByRole("menuitem", { name: "Paste" }).click(); await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); }); }); test("should use reset from selection context menu", async ({ page }) => { await expect(page.getByRole("row", { name: "1" }).nth(1)).toContainText("test"); await page.getByTestId("monaco-container").click({ button: "right" }); await page.getByRole("menuitem", { name: "Reset" }).click(); await expect(page.getByRole("row", { name: "1" }).nth(1)).not.toContainText("test"); }); }); });