Skip to content

Commit

Permalink
updates for PR
Browse files Browse the repository at this point in the history
  • Loading branch information
EmmaLRussell committed Aug 8, 2024
1 parent acb89fe commit fcbdd63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 15 deletions.
4 changes: 2 additions & 2 deletions app/static/src/app/components/mixins/selectVariables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ export default (
): SelectVariablesMixin => {
const thisSrcGraphConfig = hasHiddenVariables ? "hidden" : graphIndex!.toString();

const startDrag = (evt: DragEvent, variable: string) => {
const { dataTransfer, ctrlKey, metaKey } = evt;
const startDrag = (event: DragEvent, variable: string) => {
const { dataTransfer, ctrlKey, metaKey } = event;
const copy = !hasHiddenVariables && (ctrlKey || metaKey);
dataTransfer!.dropEffect = "move";
dataTransfer!.effectAllowed = "move";
Expand Down
20 changes: 7 additions & 13 deletions app/static/tests/unit/components/graphConfig/graphConfig.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,31 +94,25 @@ describe("GraphConfig", () => {
const s = wrapper.findAll(".graph-config-panel .badge").at(0)!;
const setData = jest.fn();
await s.trigger("dragstart", { dataTransfer: { setData }, ctrlKey: false, metaKey: false });
expect(setData.mock.calls[0][0]).toBe("variable");
expect(setData.mock.calls[0][1]).toStrictEqual("S");
expect(setData.mock.calls[1][0]).toStrictEqual("srcGraphConfig");
expect(setData.mock.calls[1][1]).toStrictEqual("0");
expect(setData.mock.calls[2][0]).toBe("copyVar");
expect(setData.mock.calls[2][1]).toBe("false");
expect(wrapper.emitted("setDragging")![0]).toStrictEqual([true]);
expect(setData).toHaveBeenNthCalledWith(1, "variable", "S");
expect(setData).toHaveBeenNthCalledWith(2, "srcGraphConfig", "0");
expect(setData).toHaveBeenNthCalledWith(3, "copyVar", "false");
});

it("start drag sets values copyVar to true in event when Ctrl key pressed", async () => {
const wrapper = getWrapper();
const s = wrapper.findAll(".graph-config-panel .badge").at(0)!;
const setData = jest.fn();
await s.trigger("dragstart", { dataTransfer: { setData }, ctrlKey: true, metaKey: false });
expect(setData.mock.calls[2][0]).toBe("copyVar");
expect(setData.mock.calls[2][1]).toBe("true");
expect(setData).toHaveBeenNthCalledWith(3, "copyVar", "true");
});

it("start drag sets values copyVar to true in event when meta key pressed", async () => {
const wrapper = getWrapper();
const s = wrapper.findAll(".graph-config-panel .badge").at(0)!;
const setData = jest.fn();
await s.trigger("dragstart", { dataTransfer: { setData }, ctrlKey: false, metaKey: true });
expect(setData.mock.calls[2][0]).toBe("copyVar");
expect(setData.mock.calls[2][1]).toBe("true");
expect(setData).toHaveBeenNthCalledWith(3, "copyVar", "true");
});

it("ending drag emits setDragging", async () => {
Expand Down Expand Up @@ -148,13 +142,13 @@ describe("GraphConfig", () => {
expect(mockUpdateSelectedVariables.mock.calls[1][1]).toStrictEqual({ graphIndex: 1, selectedVariables: ["J"] });
});

it("onDrop does not attempt to remove variable if source was hidden variables", async () => {
it("onDrop does not attempt to remove variable if source is hidden, even with Ctrl key", async () => {
const wrapper = getWrapper();
const dataTransfer = {
getData: (s: string) => {
if (s === "variable") return "I";
if (s === "srcGraphConfig") return "hidden";
if (s === "copyVar") return "false";
if (s === "copyVar") return "true";
return null;
}
};
Expand Down

0 comments on commit fcbdd63

Please sign in to comment.