@@ -24,9 +24,11 @@ import { resetTimeoutDuration } from "../../src/components/helpers/touch_scroll_
2424import { PaintFormatStore } from "../../src/components/paint_format_button/paint_format_store" ;
2525import { CellPopoverStore } from "../../src/components/popover" ;
2626import { buildSheetLink , toCartesian , toZone , zoneToXc } from "../../src/helpers" ;
27+ import { handleCopyPasteResult } from "../../src/helpers/ui/paste_interactive" ;
2728import { Store } from "../../src/store_engine" ;
2829import { ClientFocusStore } from "../../src/stores/client_focus_store" ;
2930import { HighlightStore } from "../../src/stores/highlight_store" ;
31+ import { NotificationStore } from "../../src/stores/notification_store" ;
3032import { Align , ClipboardMIMEType } from "../../src/types" ;
3133import { FileStore } from "../__mocks__/mock_file_store" ;
3234import { MockTransportService } from "../__mocks__/transport_service" ;
@@ -127,6 +129,14 @@ let composerFocusStore: Store<ComposerFocusStore>;
127129
128130jest . useFakeTimers ( ) ;
129131mockChart ( ) ;
132+ jest . mock ( "../../src/actions/menu_items_actions.ts" , ( ) => {
133+ const originalModule = jest . requireActual ( "../../src/actions/menu_items_actions.ts" ) ;
134+ return {
135+ __esModule : true ,
136+ ...originalModule ,
137+ INSERT_TABLE : jest . fn ( originalModule . INSERT_TABLE ) ,
138+ } ;
139+ } ) ;
130140
131141describe ( "Grid component" , ( ) => {
132142 beforeEach ( async ( ) => {
@@ -942,8 +952,13 @@ describe("Grid component", () => {
942952 expect ( model . getters . getActiveSheetId ( ) ) . toBe ( "third" ) ;
943953 } ) ;
944954
945- // test("Pressing Shift+F11 insert a new sheet", () => {
946- // });
955+ test ( "Pressing Shift+F11 insert a new sheet" , ( ) => {
956+ expect ( model . getters . getSheetIds ( ) ) . toHaveLength ( 1 ) ;
957+ keyDown ( { key : "F11" , shiftKey : true } ) ;
958+ const sheetIds = model . getters . getSheetIds ( ) ;
959+ expect ( sheetIds ) . toHaveLength ( 2 ) ;
960+ expect ( model . getters . getActiveSheetId ( ) ) . toBe ( sheetIds [ 1 ] ) ;
961+ } ) ;
947962
948963 test ( "pressing Ctrl+K opens the link editor" , async ( ) => {
949964 await keyDown ( { key : "k" , ctrlKey : true } ) ;
@@ -1794,7 +1809,7 @@ describe("Copy paste keyboard shortcut", () => {
17941809 const fileStore = new FileStore ( ) ;
17951810 beforeEach ( async ( ) => {
17961811 clipboardData = new MockClipboardData ( ) ;
1797- ( { parent, model, fixture } = await mountSpreadsheet ( {
1812+ ( { parent, model, fixture, env } = await mountSpreadsheet ( {
17981813 model : new Model ( { } , { external : { fileStore } } ) ,
17991814 } ) ) ;
18001815 sheetId = model . getters . getActiveSheetId ( ) ;
@@ -1967,6 +1982,16 @@ describe("Copy paste keyboard shortcut", () => {
19671982 expect ( getCell ( model , "D2" ) ?. content ) . toBe ( "d1" ) ;
19681983 } ) ;
19691984
1985+ test ( "banane" , ( ) => {
1986+ setCellContent ( model , "A1" , "a1" ) ;
1987+ merge ( model , "A2:A3" ) ;
1988+ setSelection ( model , [ "A1:A3" ] ) ;
1989+ handleCopyPasteResult ( env , { type : "COPY_PASTE_CELLS_ON_ZONE" } ) ;
1990+ // @ts -ignore
1991+ const notificationStore = env . __spreadsheet_stores__ . get ( NotificationStore ) ;
1992+ expect ( notificationStore . raiseError ) . toHaveBeenCalled ( ) ;
1993+ } ) ;
1994+
19701995 test ( "can copy and paste cell(s) on left using CTRL+R" , async ( ) => {
19711996 setCellContent ( model , "A2" , "a2" ) ;
19721997 setCellContent ( model , "B2" , "b2" ) ;
@@ -1983,6 +2008,26 @@ describe("Copy paste keyboard shortcut", () => {
19832008 expect ( getCell ( model , "B4" ) ?. content ) . toBe ( "a4" ) ;
19842009 } ) ;
19852010
2011+ test ( "can copy and paste cell(s) on zone using CTRL+ENTER" , async ( ) => {
2012+ setCellContent ( model , "A1" , "a1" ) ;
2013+ setSelection ( model , [ "A1:B2" ] ) ;
2014+ keyDown ( { key : "Enter" , ctrlKey : true } ) ;
2015+ expect ( getCell ( model , "A1" ) ?. content ) . toBe ( "a1" ) ;
2016+ expect ( getCell ( model , "A2" ) ?. content ) . toBe ( "a1" ) ;
2017+ expect ( getCell ( model , "B1" ) ?. content ) . toBe ( "a1" ) ;
2018+ expect ( getCell ( model , "B2" ) ?. content ) . toBe ( "a1" ) ;
2019+ } ) ;
2020+
2021+ test ( "Alt+T -> Table" , async ( ) => {
2022+ setSelection ( model , [ "A1:A5" ] ) ;
2023+ await keyDown ( { key : "T" , altKey : true } ) ;
2024+ expect ( model . getters . getTable ( { sheetId, row : 0 , col : 0 } ) ) . toMatchObject ( {
2025+ range : { zone : toZone ( "A1:A5" ) } ,
2026+ } ) ;
2027+ const { INSERT_TABLE } = require ( "../../src/actions/menu_items_actions" ) ;
2028+ expect ( INSERT_TABLE as jest . Mock ) . toHaveBeenCalled ( ) ;
2029+ } ) ;
2030+
19862031 test ( "Clipboard visible zones (copy) will be cleaned after hitting esc" , async ( ) => {
19872032 setCellContent ( model , "A1" , "things" ) ;
19882033 selectCell ( model , "A1" ) ;
0 commit comments