Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
t-on-click="onClick"
t-on-contextmenu.prevent="(ev) => this.onContextMenu(ev)"
t-ref="sheetDiv"
t-key="sheetName"
t-att-style="props.style"
t-att-title="sheetName"
t-att-data-id="props.sheetId"
Expand Down
24 changes: 21 additions & 3 deletions tests/bottom_bar/bottom_bar_component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ async function mountBottomBar(
return { parent, model, env };
}

function getSheetNameSpan(): HTMLSpanElement | null {
return fixture.querySelector<HTMLSpanElement>(".o-sheet-name");
}

describe("BottomBar component", () => {
test("simple rendering", async () => {
await mountBottomBar();
Expand Down Expand Up @@ -338,14 +342,13 @@ describe("BottomBar component", () => {
test("Pasting styled content in sheet name and renaming sheet does not throw a trackback", async () => {
const HTML = `<span style="color: rgb(242, 44, 61); background-color: rgb(0, 0, 0);">HELLO</span>`;

const sheetName = fixture.querySelector<HTMLElement>(".o-sheet-name")!;
const sheetName = getSheetNameSpan()!;
triggerMouseEvent(sheetName, "dblclick");
await nextTick();

sheetName.innerHTML = HTML;
await keyDown({ key: "Enter" });

expect(sheetName.getAttribute("contenteditable")).toEqual("false");
expect(getSheetNameSpan()!.getAttribute("contenteditable")).toEqual("false");
await nextTick();

expect(sheetName.innerText).toEqual("HELLO");
Expand All @@ -367,6 +370,21 @@ describe("BottomBar component", () => {
expect(focusableElementStore.focus).toHaveBeenCalled();
}
);

test("Displayed sheet name is udpated on undo/redo", async () => {
const sheetName = getSheetNameSpan()!;
expect(sheetName.textContent).toEqual("Sheet1");
await doubleClick(sheetName);
sheetName.textContent = "ThisIsASheet";
await keyDown({ key: "Enter" });
expect(getSheetNameSpan()!.textContent).toEqual("ThisIsASheet");
undo(model);
await nextTick();
expect(getSheetNameSpan()!.textContent).toEqual("Sheet1");
redo(model);
await nextTick();
expect(getSheetNameSpan()!.textContent).toEqual("ThisIsASheet");
});
});

test("Can't rename a sheet in readonly mode", async () => {
Expand Down