feat(editor): add ignore action to sql parameter dialog
This commit is contained in:
10 files changed
+58
No files matched your search
@@ -86,6 +86,10 @@ function clearActionButton(): HTMLButtonElement | null {
|
||||
return document.body.querySelector('[data-testid="sql-parameters-clear-values"]');
|
||||
}
|
||||
|
||||
function ignoreActionButton(): HTMLButtonElement | null {
|
||||
return document.body.querySelector('[data-testid="sql-parameters-ignore"]');
|
||||
}
|
||||
|
||||
function clickRawAction() {
|
||||
const button = actionButton();
|
||||
expect(button).not.toBeNull();
|
||||
@@ -98,6 +102,12 @@ function clickClearAction() {
|
||||
button!.click();
|
||||
}
|
||||
|
||||
function clickIgnoreAction() {
|
||||
const button = ignoreActionButton();
|
||||
expect(button).not.toBeNull();
|
||||
button!.click();
|
||||
}
|
||||
|
||||
function buttonWithText(text: string): HTMLButtonElement | undefined {
|
||||
return Array.from(document.body.querySelectorAll("button")).find((button) => button.textContent?.trim() === text);
|
||||
}
|
||||
@@ -183,6 +193,38 @@ describe("SqlParameterDialog raw parameter action", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("SqlParameterDialog ignore parameter action", () => {
|
||||
it("closes the dialog and emits the original SQL without remembering or mutating values", async () => {
|
||||
const { state, onExecute } = await mountDialog();
|
||||
|
||||
clickIgnoreAction();
|
||||
await nextTick();
|
||||
|
||||
expect(state.open).toBe(false);
|
||||
expect(onExecute).toHaveBeenCalledOnce();
|
||||
expect(onExecute).toHaveBeenCalledWith(SQL);
|
||||
expect(historyMocks.remember).not.toHaveBeenCalled();
|
||||
expect(parameterInputs().map((input) => input.value)).toEqual(PARAMETERS.map((parameter) => MIXED_VALUES[parameter.key]?.value ?? ""));
|
||||
});
|
||||
|
||||
it("does not apply current parameter edits when ignoring", async () => {
|
||||
const { state, onExecute } = await mountDialog();
|
||||
|
||||
const firstInput = parameterInputs()[0];
|
||||
expect(firstInput).not.toBeUndefined();
|
||||
firstInput!.value = "changed";
|
||||
firstInput!.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
await nextTick();
|
||||
|
||||
clickIgnoreAction();
|
||||
await nextTick();
|
||||
|
||||
expect(state.open).toBe(false);
|
||||
expect(onExecute).toHaveBeenCalledWith(SQL);
|
||||
expect(historyMocks.remember).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
|
||||
describe("SqlParameterDialog clear parameter values action", () => {
|
||||
it("clears every displayed value while preserving kinds and updating the preview", async () => {
|
||||
const { state, onExecute } = await mountDialog();
|
||||
|
||||
Reference in new issue
Block a user