From 066b3718ac2fd4bf2f2a9aca9865c9b5f1ce70be Mon Sep 17 00:00:00 2001 From: Tami Takamiya Date: Thu, 22 Aug 2024 13:52:27 -0400 Subject: [PATCH] Make playbook generation work even with an empty outline --- src/webview/apps/common/editableList.ts | 5 +---- src/webview/apps/lightspeed/playbookGeneration/main.ts | 2 +- test/units/lightspeed/editableList.test.ts | 2 ++ 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/webview/apps/common/editableList.ts b/src/webview/apps/common/editableList.ts index b95bd9442..455e42a4a 100644 --- a/src/webview/apps/common/editableList.ts +++ b/src/webview/apps/common/editableList.ts @@ -39,7 +39,7 @@ export class EditableList { values.push(node.textContent.trim()); } }); - return values; + return values.length === 0 ? [""] : values; } setToUI(values: string[]) { @@ -71,9 +71,6 @@ export class EditableList { } isChanged() { - if (!this.savedValues) { - return true; - } const values = this.getFromUI(); if (this.savedValues.length !== values.length) { return true; diff --git a/src/webview/apps/lightspeed/playbookGeneration/main.ts b/src/webview/apps/lightspeed/playbookGeneration/main.ts index 2023467dd..a8043e2e5 100644 --- a/src/webview/apps/lightspeed/playbookGeneration/main.ts +++ b/src/webview/apps/lightspeed/playbookGeneration/main.ts @@ -47,7 +47,7 @@ window.addEventListener("load", () => { outline = new EditableList("outline-list"); outline.element.addEventListener("input", () => { setButtonEnabled("reset-button", outline.isChanged()); - setButtonEnabled("generate-button", !outline.isEmpty()); + // setButtonEnabled("generate-button", !outline.isEmpty()); }); // Detect whether a dark or a light color theme is used. diff --git a/test/units/lightspeed/editableList.test.ts b/test/units/lightspeed/editableList.test.ts index 2955f28ab..8034cdac6 100644 --- a/test/units/lightspeed/editableList.test.ts +++ b/test/units/lightspeed/editableList.test.ts @@ -66,6 +66,8 @@ describe("Test EditableList", () => { domWithEmptyList.window, ); assert.equal(emptyEditableList.isEmpty(), true); + assert.equal(emptyEditableList.getFromUI().length, 1); + assert.equal(emptyEditableList.getFromUI()[0], ""); }); it("Test constructor", async () => {