fix(orchestrator): keep search term chips when backspacing empty input (#215)
This commit is contained in:
parent
1e0767a4ed
commit
483e5f49e0
@ -1,5 +1,5 @@
|
||||
import { createAppSettings } from "@shared/testing/factories.js";
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import type React from "react";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { AutomaticRunTab } from "./AutomaticRunTab";
|
||||
@ -155,4 +155,33 @@ describe("AutomaticRunTab", () => {
|
||||
"Set a Glassdoor city in Advanced settings to enable Glassdoor.",
|
||||
);
|
||||
});
|
||||
|
||||
it("does not remove existing search terms when Backspace is pressed on an empty input", () => {
|
||||
render(
|
||||
<AutomaticRunTab
|
||||
open
|
||||
settings={createAppSettings({
|
||||
searchTerms: ["backend engineer", "frontend engineer"],
|
||||
jobspyCountryIndeed: "united kingdom",
|
||||
jobspyLocation: "",
|
||||
})}
|
||||
enabledSources={["linkedin"]}
|
||||
pipelineSources={["linkedin"]}
|
||||
onToggleSource={vi.fn()}
|
||||
onSetPipelineSources={vi.fn()}
|
||||
isPipelineRunning={false}
|
||||
onSaveAndRun={vi.fn().mockResolvedValue(undefined)}
|
||||
/>,
|
||||
);
|
||||
|
||||
const input = screen.getByPlaceholderText("Type and press Enter");
|
||||
fireEvent.keyDown(input, { key: "Backspace" });
|
||||
|
||||
expect(
|
||||
screen.getByRole("button", { name: "Remove backend engineer" }),
|
||||
).toBeInTheDocument();
|
||||
expect(
|
||||
screen.getByRole("button", { name: "Remove frontend engineer" }),
|
||||
).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
@ -479,15 +479,6 @@ export const AutomaticRunTab: React.FC<AutomaticRunTabProps> = ({
|
||||
setValue("searchTermDraft", "");
|
||||
return;
|
||||
}
|
||||
if (
|
||||
event.key === "Backspace" &&
|
||||
searchTermDraft.length === 0 &&
|
||||
searchTerms.length > 0
|
||||
) {
|
||||
setValue("searchTerms", searchTerms.slice(0, -1), {
|
||||
shouldDirty: true,
|
||||
});
|
||||
}
|
||||
}}
|
||||
onBlur={() => {
|
||||
addSearchTerms(searchTermDraft);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user