import { describe, test } from "@odoo/hoot"; import { press } from "@odoo/hoot-dom"; import { testEditor } from "../_helpers/editor"; import { unformat } from "../_helpers/format"; describe("move selection with tab/shift+tab", () => { describe("tab", () => { test("should move cursor to the end of next cell", async () => { await testEditor({ contentBefore: unformat(`
[]ab cd ef
`), stepFunction: async () => press("Tab"), contentAfter: unformat(`
ab cd[] ef
`), }); }); test.tags("iframe"); test("should move cursor to the end of next cell in an iframe", async () => { await testEditor({ props: { iframe: true }, contentBefore: unformat(`
[]ab cd ef
`), stepFunction: async () => press("Tab"), contentAfter: unformat(`
ab cd[] ef
`), }); }); test("should move cursor to the end of next cell in the row below", async () => { await testEditor({ contentBefore: unformat(`
ab [cd]
ef gh
`), stepFunction: async () => press("Tab"), contentAfter: unformat(`
ab cd
ef[] gh
`), }); }); test("move cursor to end of next cell when selection is inside table", async () => { await testEditor({ contentBefore: unformat(` `), stepFunction: async () => press("Tab"), contentAfter: unformat(` `), }); }); }); describe("shift+tab", () => { test("should move cursor to the end of previous cell", async () => { await testEditor({ contentBefore: unformat(`
ab []cd ef
`), stepFunction: async () => press(["Shift", "Tab"]), contentAfter: unformat(`
ab[] cd ef
`), }); }); test("should move cursor to the end of previous cell in the row above", async () => { await testEditor({ contentBefore: unformat(`
ab cd
[ef] gh
`), stepFunction: async () => press(["Shift", "Tab"]), contentAfter: unformat(`
ab cd[]
ef gh
`), }); }); test("should not cursor if there is no previous cell", async () => { await testEditor({ contentBefore: unformat(`
[ab] cd ef
`), stepFunction: async () => press(["Shift", "Tab"]), contentAfter: unformat(`
[ab] cd ef
`), }); }); test("move cursor to end of previous cell when selection is inside table", async () => { await testEditor({ contentBefore: unformat(` `), stepFunction: async () => press(["Shift", "Tab"]), contentAfter: unformat(` `), }); }); }); });