lhcb-ntuple-wizard-test 2.1.0 → 2.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/AddTupleToolButton.d.ts +1 -0
- package/dist/components/AddTupleToolButton.js +16 -0
- package/dist/components/BookkeepingPathDropdown.d.ts +1 -1
- package/dist/components/BookkeepingPathDropdown.js +1 -4
- package/dist/components/DatasetEventTypeBadge.js +1 -1
- package/dist/components/DatasetInfo.js +3 -3
- package/dist/components/DecayCard.d.ts +1 -1
- package/dist/components/DecayCard.js +12 -40
- package/dist/components/DecayLatex.d.ts +1 -1
- package/dist/components/DecayLatex.js +4 -87
- package/dist/components/DecayListItem.js +2 -2
- package/dist/components/DecayTagBadge.d.ts +1 -1
- package/dist/components/DecayTagBadge.js +0 -3
- package/dist/components/DecayTreeCard.d.ts +1 -7
- package/dist/components/DecayTreeCard.js +13 -18
- package/dist/components/DecayTreeCardHeader.d.ts +2 -3
- package/dist/components/DecayTreeCardHeader.js +2 -2
- package/dist/components/DecayTreeGraph.d.ts +1 -4
- package/dist/components/DecayTreeGraph.js +66 -41
- package/dist/components/DeleteButton.d.ts +2 -1
- package/dist/components/DeleteButton.js +2 -2
- package/dist/components/DttNameInput.d.ts +9 -0
- package/dist/components/DttNameInput.js +43 -0
- package/dist/components/GuideLinkButton.d.ts +15 -0
- package/dist/components/GuideLinkButton.js +16 -0
- package/dist/components/NtupleWizard.js +1 -7
- package/dist/components/ParticleDropdown.d.ts +11 -1
- package/dist/components/ParticleDropdown.js +3 -6
- package/dist/components/ParticleLatex.d.ts +6 -0
- package/dist/components/ParticleLatex.js +13 -0
- package/dist/components/ParticleTagBadge.d.ts +2 -1
- package/dist/components/ParticleTagBadge.js +5 -7
- package/dist/components/ParticleTagFilters.d.ts +1 -6
- package/dist/components/ParticleTagFilters.js +16 -17
- package/dist/components/RequestButtonGroup.d.ts +1 -1
- package/dist/components/RequestButtonGroup.js +0 -3
- package/dist/components/RequestRow.d.ts +1 -1
- package/dist/components/RequestRow.js +4 -9
- package/dist/components/StrippingLineDropdown.js +14 -16
- package/dist/components/StrippingLineInfo.d.ts +5 -5
- package/dist/components/StrippingLineInfo.js +14 -4
- package/dist/components/StrippingLineInfoButton.d.ts +6 -0
- package/dist/components/StrippingLineInfoButton.js +7 -0
- package/dist/components/StrippingLineVersionBadge.d.ts +7 -0
- package/dist/components/{StrippingLineBadge.js → StrippingLineVersionBadge.js} +5 -5
- package/dist/components/StrippingLinesCountBadge.d.ts +8 -0
- package/dist/components/StrippingLinesCountBadge.js +11 -0
- package/dist/components/TagDropdown.d.ts +3 -3
- package/dist/components/TagDropdown.js +2 -2
- package/dist/components/TupleToolClassDropdown.js +11 -14
- package/dist/components/TupleToolDocsAccordion.d.ts +1 -1
- package/dist/components/TupleToolDocsAccordion.js +4 -8
- package/dist/components/TupleToolGroupsAccordion.d.ts +5 -0
- package/dist/components/TupleToolGroupsAccordion.js +31 -0
- package/dist/components/TupleToolLabel.d.ts +1 -1
- package/dist/components/TupleToolLabel.js +2 -5
- package/dist/components/TupleToolsAccordion.d.ts +1 -0
- package/dist/components/TupleToolsAccordion.js +22 -0
- package/dist/components/modals/AddTupleToolModal.js +3 -2
- package/dist/components/modals/ConfigureTupleToolModal.js +1 -1
- package/dist/components/modals/UploadDttConfigModal.d.ts +1 -1
- package/dist/components/modals/UploadDttConfigModal.js +1 -4
- package/dist/config.d.ts +1 -0
- package/dist/config.js +3 -2
- package/dist/models/bkPath.js +1 -1
- package/dist/models/dtt.d.ts +5 -2
- package/dist/models/dtt.js +37 -18
- package/dist/models/rowData.d.ts +1 -1
- package/dist/models/yamlFile.js +1 -1
- package/dist/pages/DecaySearchPage.js +4 -9
- package/dist/pages/DecayTreeConfigPage.js +4 -38
- package/dist/pages/RequestPage.js +2 -4
- package/dist/providers/DttProvider.d.ts +3 -3
- package/dist/providers/DttProvider.js +30 -55
- package/dist/providers/MetadataProvider.d.ts +1 -1
- package/dist/providers/MetadataProvider.js +11 -5
- package/dist/providers/RequestProvider.js +2 -2
- package/dist/providers/RowProvider.d.ts +2 -2
- package/dist/providers/RowProvider.js +10 -9
- package/dist/providers/RowsProvider.js +0 -3
- package/dist/tests/components/BookkeepingPathDropdown.test.d.ts +1 -0
- package/dist/tests/components/BookkeepingPathDropdown.test.js +118 -0
- package/dist/tests/components/DatasetInfo.test.d.ts +1 -0
- package/dist/tests/components/DatasetInfo.test.js +38 -0
- package/dist/tests/components/DecayCard.test.d.ts +1 -0
- package/dist/tests/components/DecayCard.test.js +115 -0
- package/dist/tests/components/DecayLatex.test.d.ts +1 -0
- package/dist/tests/components/DecayLatex.test.js +31 -0
- package/dist/tests/components/DecayList.test.d.ts +1 -0
- package/dist/tests/components/DecayList.test.js +76 -0
- package/dist/tests/components/DecayListItem.test.d.ts +1 -0
- package/dist/tests/components/DecayListItem.test.js +51 -0
- package/dist/tests/components/DecayTreeCard.test.d.ts +1 -0
- package/dist/tests/components/DecayTreeCard.test.js +119 -0
- package/dist/tests/components/DecayTreeGraph.test.d.ts +1 -0
- package/dist/tests/components/DecayTreeGraph.test.js +125 -0
- package/dist/tests/components/DeleteButton.test.d.ts +1 -0
- package/dist/tests/components/DeleteButton.test.js +45 -0
- package/dist/tests/components/DttNameInput.test.d.ts +1 -0
- package/dist/tests/components/DttNameInput.test.js +75 -0
- package/dist/tests/components/NtupleWizard.test.d.ts +1 -0
- package/dist/tests/components/NtupleWizard.test.js +57 -0
- package/dist/tests/components/ParticleDropdown.test.d.ts +1 -0
- package/dist/tests/components/ParticleDropdown.test.js +23 -0
- package/dist/tests/components/ParticleTagFilters.test.d.ts +1 -0
- package/dist/tests/components/ParticleTagFilters.test.js +87 -0
- package/dist/tests/components/RequestButtonGroup.test.d.ts +1 -0
- package/dist/tests/components/RequestButtonGroup.test.js +132 -0
- package/dist/tests/components/RequestRow.test.d.ts +1 -0
- package/dist/tests/components/RequestRow.test.js +58 -0
- package/dist/tests/components/StrippingLineDropdown.test.d.ts +1 -0
- package/dist/tests/components/StrippingLineDropdown.test.js +88 -0
- package/dist/tests/components/badges.test.d.ts +1 -0
- package/dist/tests/components/badges.test.js +120 -0
- package/dist/tests/components/dropdowns.test.d.ts +1 -0
- package/dist/tests/components/dropdowns.test.js +110 -0
- package/dist/tests/components/dttComponents.test.d.ts +1 -0
- package/dist/tests/components/dttComponents.test.js +287 -0
- package/dist/tests/components/formInputs.test.d.ts +1 -0
- package/dist/tests/components/formInputs.test.js +96 -0
- package/dist/tests/components/metadataComponents.test.d.ts +1 -0
- package/dist/tests/components/metadataComponents.test.js +137 -0
- package/dist/tests/components/miscComponents.test.d.ts +1 -0
- package/dist/tests/components/miscComponents.test.js +134 -0
- package/dist/tests/components/modals.test.d.ts +1 -0
- package/dist/tests/components/modals.test.js +554 -0
- package/dist/tests/components/tupleToolParams.test.d.ts +1 -0
- package/dist/tests/components/tupleToolParams.test.js +213 -0
- package/dist/tests/config.test.d.ts +1 -0
- package/dist/tests/config.test.js +31 -0
- package/dist/tests/mockSetup.d.ts +1 -0
- package/dist/tests/mockSetup.js +30 -0
- package/dist/tests/models/BkPath.test.d.ts +1 -0
- package/dist/tests/models/BkPath.test.js +87 -0
- package/dist/tests/models/Dtt.test.d.ts +1 -0
- package/dist/tests/models/Dtt.test.js +376 -0
- package/dist/tests/models/TupleTool.test.d.ts +1 -0
- package/dist/tests/models/TupleTool.test.js +80 -0
- package/dist/tests/models/YamlFile.test.d.ts +1 -0
- package/dist/tests/models/YamlFile.test.js +123 -0
- package/dist/tests/pages/DecaySearchPage.test.d.ts +1 -0
- package/dist/tests/pages/DecaySearchPage.test.js +228 -0
- package/dist/tests/pages/DecayTreeConfigPage.test.d.ts +1 -0
- package/dist/tests/pages/DecayTreeConfigPage.test.js +105 -0
- package/dist/tests/pages/RequestPage.test.d.ts +1 -0
- package/dist/tests/pages/RequestPage.test.js +439 -0
- package/dist/tests/providers/DttProvider.test.d.ts +1 -0
- package/dist/tests/providers/DttProvider.test.js +105 -0
- package/dist/tests/providers/MetadataProvider.test.d.ts +1 -0
- package/dist/tests/providers/MetadataProvider.test.js +129 -0
- package/dist/tests/providers/RequestProvider.test.d.ts +1 -0
- package/dist/tests/providers/RequestProvider.test.js +306 -0
- package/dist/tests/providers/RowProvider.test.d.ts +1 -0
- package/dist/tests/providers/RowProvider.test.js +110 -0
- package/dist/tests/providers/RowsProvider.test.d.ts +1 -0
- package/dist/tests/providers/RowsProvider.test.js +84 -0
- package/dist/tests/providers/WizardConfigProvider.test.d.ts +1 -0
- package/dist/tests/providers/WizardConfigProvider.test.js +36 -0
- package/dist/tests/setupTests.d.ts +1 -0
- package/dist/tests/setupTests.js +15 -0
- package/dist/tests/testUtils.d.ts +33 -0
- package/dist/tests/testUtils.js +196 -0
- package/dist/tests/utils/latexUtils.test.d.ts +1 -0
- package/dist/tests/utils/latexUtils.test.js +62 -0
- package/dist/tests/utils/utils.test.d.ts +1 -0
- package/dist/tests/utils/utils.test.js +394 -0
- package/dist/utils/latexUtils.d.ts +13 -0
- package/dist/utils/latexUtils.js +86 -0
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +4 -1
- package/package.json +19 -9
- package/dist/components/NumStrippingLinesBadge.d.ts +0 -8
- package/dist/components/NumStrippingLinesBadge.js +0 -10
- package/dist/components/StrippingLineBadge.d.ts +0 -7
- package/dist/components/TupleToolGroup.d.ts +0 -5
- package/dist/components/TupleToolGroup.js +0 -22
- package/dist/components/TupleToolList.d.ts +0 -6
- package/dist/components/TupleToolList.js +0 -42
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { describe, expect, it } from "vitest";
|
|
3
|
+
import { renderHook } from "@testing-library/react";
|
|
4
|
+
import { WizardConfigProvider, useWizardConfig } from "../../providers/WizardConfigProvider";
|
|
5
|
+
function makeWrapper(config) {
|
|
6
|
+
return function Wrapper({ children }) {
|
|
7
|
+
return (_jsx(WizardConfigProvider, { basePath: config.basePath ?? "", submitLocation: config.submitLocation, children: children }));
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
describe("WizardConfigProvider", () => {
|
|
11
|
+
it("sets variant to 'standalone' when no submitLocation is provided", () => {
|
|
12
|
+
const { result } = renderHook(() => useWizardConfig(), { wrapper: makeWrapper({}) });
|
|
13
|
+
expect(result.current.variant).toBe("standalone");
|
|
14
|
+
});
|
|
15
|
+
it("sets variant to 'embedded' when submitLocation is provided", () => {
|
|
16
|
+
const { result } = renderHook(() => useWizardConfig(), {
|
|
17
|
+
wrapper: makeWrapper({ submitLocation: "https://example.com/submit" }),
|
|
18
|
+
});
|
|
19
|
+
expect(result.current.variant).toBe("embedded");
|
|
20
|
+
});
|
|
21
|
+
it("exposes the basePath", () => {
|
|
22
|
+
const { result } = renderHook(() => useWizardConfig(), {
|
|
23
|
+
wrapper: makeWrapper({ basePath: "/wizard" }),
|
|
24
|
+
});
|
|
25
|
+
expect(result.current.basePath).toBe("/wizard");
|
|
26
|
+
});
|
|
27
|
+
it("exposes the submitLocation", () => {
|
|
28
|
+
const { result } = renderHook(() => useWizardConfig(), {
|
|
29
|
+
wrapper: makeWrapper({ submitLocation: "https://example.com/submit" }),
|
|
30
|
+
});
|
|
31
|
+
expect(result.current.submitLocation).toBe("https://example.com/submit");
|
|
32
|
+
});
|
|
33
|
+
it("throws when useWizardConfig is called outside the provider", () => {
|
|
34
|
+
expect(() => renderHook(() => useWizardConfig())).toThrow("useWizardConfig must be used within a WizardConfigProvider");
|
|
35
|
+
});
|
|
36
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest";
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import "@testing-library/jest-dom/vitest";
|
|
2
|
+
import { afterAll, afterEach, beforeEach, vi } from "vitest";
|
|
3
|
+
import { cleanup } from "@testing-library/react";
|
|
4
|
+
afterAll(() => {
|
|
5
|
+
vi.restoreAllMocks();
|
|
6
|
+
});
|
|
7
|
+
beforeEach(() => {
|
|
8
|
+
vi.resetAllMocks();
|
|
9
|
+
localStorage.clear();
|
|
10
|
+
vi.spyOn(console, "error").mockImplementation(() => { });
|
|
11
|
+
vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
12
|
+
});
|
|
13
|
+
afterEach(() => {
|
|
14
|
+
cleanup();
|
|
15
|
+
});
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ReactNode } from "react";
|
|
2
|
+
import { BranchMapItem, ToolMetadata } from "../models/dtt";
|
|
3
|
+
import Dtt from "../models/dtt";
|
|
4
|
+
import { DecayData } from "../models/decayData";
|
|
5
|
+
import { RowData } from "../models/rowData";
|
|
6
|
+
import { StrippingLine } from "../models/strippingLine";
|
|
7
|
+
import { MetadataContext } from "../providers/MetadataProvider";
|
|
8
|
+
import { Particle } from "../models/particle";
|
|
9
|
+
export declare const mockToolMetadata: ToolMetadata;
|
|
10
|
+
export declare const mockBranchItems: BranchMapItem[];
|
|
11
|
+
export declare const mockDecay: DecayData;
|
|
12
|
+
export declare const mockStrippingLine: StrippingLine;
|
|
13
|
+
export declare const mockStrippingLinePrescaled: StrippingLine;
|
|
14
|
+
export declare function createMockDtt(name?: string): Dtt;
|
|
15
|
+
export declare function createMockRow(overrides?: Partial<RowData>): RowData;
|
|
16
|
+
export declare const mockParticleProperties: {
|
|
17
|
+
[key: string]: Particle;
|
|
18
|
+
};
|
|
19
|
+
export declare const mockMetadata: MetadataContext;
|
|
20
|
+
export declare const mockInlineMath: ({ math }: {
|
|
21
|
+
math: string;
|
|
22
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
23
|
+
export declare const mockGuideLinkButton: () => import("react/jsx-runtime").JSX.Element;
|
|
24
|
+
export declare const mockVerticalLine: () => import("react/jsx-runtime").JSX.Element;
|
|
25
|
+
export declare const mockLoadingIndicator: () => import("react/jsx-runtime").JSX.Element;
|
|
26
|
+
export declare const mockPassthrough: ({ children }: {
|
|
27
|
+
children: ReactNode;
|
|
28
|
+
}) => import("react/jsx-runtime").JSX.Element;
|
|
29
|
+
interface RenderOptions {
|
|
30
|
+
initialRoute?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function renderWithRouter(ui: ReactNode, { initialRoute }?: RenderOptions): import("@testing-library/react").RenderResult<typeof import("@testing-library/dom/types/queries"), HTMLElement, HTMLElement>;
|
|
33
|
+
export {};
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { render } from "@testing-library/react";
|
|
3
|
+
import { MemoryRouter } from "react-router-dom";
|
|
4
|
+
import Dtt from "../models/dtt";
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Shared mock tool metadata
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
export const mockToolMetadata = {
|
|
9
|
+
TupleToolKinematic: {
|
|
10
|
+
description: "Kinematic information",
|
|
11
|
+
documentation: "",
|
|
12
|
+
tags: [],
|
|
13
|
+
interface: [{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "Verbose output" }],
|
|
14
|
+
},
|
|
15
|
+
TupleToolPid: {
|
|
16
|
+
description: "PID information",
|
|
17
|
+
documentation: "",
|
|
18
|
+
tags: [],
|
|
19
|
+
interface: [{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "Verbose output" }],
|
|
20
|
+
},
|
|
21
|
+
TupleToolANNPID: {
|
|
22
|
+
description: "ANN PID",
|
|
23
|
+
documentation: "",
|
|
24
|
+
tags: [],
|
|
25
|
+
interface: [],
|
|
26
|
+
},
|
|
27
|
+
TupleToolGeometry: {
|
|
28
|
+
description: "Geometry",
|
|
29
|
+
documentation: "",
|
|
30
|
+
tags: [],
|
|
31
|
+
interface: [],
|
|
32
|
+
},
|
|
33
|
+
TupleToolEventInfo: {
|
|
34
|
+
description: "Event info",
|
|
35
|
+
documentation: "",
|
|
36
|
+
tags: [],
|
|
37
|
+
interface: [],
|
|
38
|
+
},
|
|
39
|
+
TupleToolL0Data: {
|
|
40
|
+
description: "L0 trigger data",
|
|
41
|
+
documentation: "",
|
|
42
|
+
tags: [],
|
|
43
|
+
interface: [{ name: "Verbose", type: "bool", cpp_type: "bool", default: false, description: "Verbose output" }],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
// ---------------------------------------------------------------------------
|
|
47
|
+
// Shared mock branch items (B+ -> K+ mu+ mu-)
|
|
48
|
+
// ---------------------------------------------------------------------------
|
|
49
|
+
export const mockBranchItems = [
|
|
50
|
+
{ branch: "head", particle: "B+" },
|
|
51
|
+
[
|
|
52
|
+
{ branch: "k", particle: "K+" },
|
|
53
|
+
{ branch: "mup", particle: "mu+" },
|
|
54
|
+
{ branch: "mum", particle: "mu-" },
|
|
55
|
+
],
|
|
56
|
+
];
|
|
57
|
+
// ---------------------------------------------------------------------------
|
|
58
|
+
// Shared mock decay data
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
export const mockDecay = {
|
|
61
|
+
descriptors: {
|
|
62
|
+
plain: "[B+ -> K+ mu+ mu-]cc",
|
|
63
|
+
latex: "B^+ \\to K^+ \\mu^+ \\mu^-",
|
|
64
|
+
// Variables appear BEFORE each particle name; ]CC (uppercase) is removed by cleanLoKiSelector
|
|
65
|
+
template: "[${head}B+ -> ${k}K+ ${mup}mu+ ${mum}mu-]CC",
|
|
66
|
+
mapped_list: mockBranchItems,
|
|
67
|
+
list: ["B+", "K+", "mu+", "mu-"],
|
|
68
|
+
},
|
|
69
|
+
lines: { "Leptonic/StrippingBuToKJpsiee2Line": ["28r2"] },
|
|
70
|
+
tags: [],
|
|
71
|
+
};
|
|
72
|
+
// ---------------------------------------------------------------------------
|
|
73
|
+
// Shared mock stripping line
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
export const mockStrippingLine = {
|
|
76
|
+
line: "StrippingBuToKJpsiee2Line",
|
|
77
|
+
stream: "Leptonic",
|
|
78
|
+
versions: ["28r2"],
|
|
79
|
+
};
|
|
80
|
+
export const mockStrippingLinePrescaled = {
|
|
81
|
+
line: "StrippingPrescaledTestLine",
|
|
82
|
+
stream: "Leptonic",
|
|
83
|
+
versions: ["28r2"],
|
|
84
|
+
};
|
|
85
|
+
// ---------------------------------------------------------------------------
|
|
86
|
+
// Helper to create a Dtt with a name set
|
|
87
|
+
// ---------------------------------------------------------------------------
|
|
88
|
+
export function createMockDtt(name = "MyTree") {
|
|
89
|
+
return Dtt.create("[B+ -> ${head} ${k} ${mup} ${mum}]cc", mockBranchItems, [], name, mockToolMetadata).withName(name);
|
|
90
|
+
}
|
|
91
|
+
// ---------------------------------------------------------------------------
|
|
92
|
+
// Shared mock row data
|
|
93
|
+
// ---------------------------------------------------------------------------
|
|
94
|
+
export function createMockRow(overrides = {}) {
|
|
95
|
+
return {
|
|
96
|
+
id: 0,
|
|
97
|
+
decay: mockDecay,
|
|
98
|
+
dtt: null,
|
|
99
|
+
line: null,
|
|
100
|
+
paths: [],
|
|
101
|
+
pathOptions: [],
|
|
102
|
+
...overrides,
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
// Shared mock particle properties
|
|
107
|
+
// ---------------------------------------------------------------------------
|
|
108
|
+
function mockParticle(overrides = {}) {
|
|
109
|
+
return {
|
|
110
|
+
antiparticle: "",
|
|
111
|
+
charge: 0,
|
|
112
|
+
hide: false,
|
|
113
|
+
html: "?",
|
|
114
|
+
latex: "?",
|
|
115
|
+
mass: 0,
|
|
116
|
+
pid: 0,
|
|
117
|
+
prefix: "",
|
|
118
|
+
stable: false,
|
|
119
|
+
tags: [],
|
|
120
|
+
...overrides,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
export const mockParticleProperties = {
|
|
124
|
+
"B+": mockParticle({ latex: "B^+", html: "B+", charge: 1, pid: 521 }),
|
|
125
|
+
"B-": mockParticle({ latex: "B^-", html: "B-", charge: -1, pid: -521 }),
|
|
126
|
+
"K+": mockParticle({ latex: "K^+", html: "K+", charge: 1, pid: 321 }),
|
|
127
|
+
"K-": mockParticle({ latex: "K^-", html: "K-", charge: -1, pid: -321 }),
|
|
128
|
+
"mu+": mockParticle({ latex: "\\mu^+", html: "μ+", charge: 1, pid: -13 }),
|
|
129
|
+
"mu-": mockParticle({ latex: "\\mu^-", html: "μ-", charge: -1, pid: 13 }),
|
|
130
|
+
};
|
|
131
|
+
// ---------------------------------------------------------------------------
|
|
132
|
+
// Shared mock MetadataContext
|
|
133
|
+
// ---------------------------------------------------------------------------
|
|
134
|
+
export const mockMetadata = {
|
|
135
|
+
dataset: [],
|
|
136
|
+
decays: {
|
|
137
|
+
"[B+ -> K+ mu+ mu-]cc": mockDecay,
|
|
138
|
+
},
|
|
139
|
+
embedding: {},
|
|
140
|
+
kgdoc: {},
|
|
141
|
+
lokiVariables: {
|
|
142
|
+
applicationInfo: { Analysis: "v25r1", DaVinci: "v45r7", Phys: "v26r2" },
|
|
143
|
+
lokiVariables: {},
|
|
144
|
+
},
|
|
145
|
+
particleProperties: mockParticleProperties,
|
|
146
|
+
stripping: {
|
|
147
|
+
"28r2": {
|
|
148
|
+
StrippingBuToKJpsiee2Line: {
|
|
149
|
+
full_decays: ["[B+ -> K+ J/psi(1S)]cc"],
|
|
150
|
+
output: "Particles",
|
|
151
|
+
prescale: 1,
|
|
152
|
+
stream: ["Leptonic"],
|
|
153
|
+
url: { Leptonic: "http://lhcbdoc.web.cern.ch/stripping/28r2/BuToKJpsiee2Line" },
|
|
154
|
+
},
|
|
155
|
+
StrippingPrescaledTestLine: {
|
|
156
|
+
full_decays: ["[B+ -> K+ J/psi(1S)]cc"],
|
|
157
|
+
output: "Particles",
|
|
158
|
+
prescale: 0.5,
|
|
159
|
+
stream: ["Leptonic"],
|
|
160
|
+
url: {},
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
},
|
|
164
|
+
strippingHints: {
|
|
165
|
+
"28r2": { davinci: "v40r4", description: "Stripping 28r2 (2016 data)" },
|
|
166
|
+
},
|
|
167
|
+
tupleTools: {
|
|
168
|
+
applicationInfo: { Analysis: "v25r1", DaVinci: "v45r7", Phys: "v26r2" },
|
|
169
|
+
tupleTools: mockToolMetadata,
|
|
170
|
+
},
|
|
171
|
+
userHints: {
|
|
172
|
+
decayTags: {
|
|
173
|
+
B2OC: { description: "B to open charm decay", hide: false, warn: false },
|
|
174
|
+
SLOW: { description: "Slow production", hide: false, warn: true },
|
|
175
|
+
},
|
|
176
|
+
particleTags: {
|
|
177
|
+
muon: { description: "Muon particle", group: "category", hide: false },
|
|
178
|
+
kaon: { description: "Kaon particle", group: "flavour", hide: false },
|
|
179
|
+
},
|
|
180
|
+
},
|
|
181
|
+
};
|
|
182
|
+
// ---------------------------------------------------------------------------
|
|
183
|
+
// Shared component stubs
|
|
184
|
+
//
|
|
185
|
+
// Names start with "mock" so Vitest's hoisting rules allow them to be
|
|
186
|
+
// referenced inside vi.mock() factory functions in any test file that imports
|
|
187
|
+
// them from here.
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
export const mockInlineMath = ({ math }) => _jsx("span", { "data-testid": "inline-math", children: math });
|
|
190
|
+
export const mockGuideLinkButton = () => _jsx("a", { "data-testid": "guide-link" });
|
|
191
|
+
export const mockVerticalLine = () => _jsx("div", { "data-testid": "vertical-line" });
|
|
192
|
+
export const mockLoadingIndicator = () => _jsx("div", { "data-testid": "loading-indicator" });
|
|
193
|
+
export const mockPassthrough = ({ children }) => _jsx(_Fragment, { children: children });
|
|
194
|
+
export function renderWithRouter(ui, { initialRoute = "/" } = {}) {
|
|
195
|
+
return render(_jsx(MemoryRouter, { initialEntries: [initialRoute], children: ui }));
|
|
196
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { convertParticleToLatex, selectionDescriptorToLatex, LATEX_SELECTED_COLOR } from "../../utils/latexUtils";
|
|
3
|
+
import { mockDecay, mockMetadata } from "../testUtils";
|
|
4
|
+
describe("convertParticleToLatex()", () => {
|
|
5
|
+
it("converts the arrow token to LaTeX \\to", () => {
|
|
6
|
+
expect(convertParticleToLatex(mockMetadata, "->")).toBe("\\to");
|
|
7
|
+
});
|
|
8
|
+
it("returns the LaTeX for a known particle", () => {
|
|
9
|
+
expect(convertParticleToLatex(mockMetadata, "B+")).toBe("B^+");
|
|
10
|
+
});
|
|
11
|
+
it("wraps a selected (^-prefixed) particle in \\textcolor", () => {
|
|
12
|
+
const result = convertParticleToLatex(mockMetadata, "^B+");
|
|
13
|
+
expect(result).toContain("\\textcolor");
|
|
14
|
+
expect(result).toContain(LATEX_SELECTED_COLOR);
|
|
15
|
+
expect(result).toContain("B^+");
|
|
16
|
+
});
|
|
17
|
+
it("wraps a highlighted=true particle in \\textcolor", () => {
|
|
18
|
+
const result = convertParticleToLatex(mockMetadata, "B+", true);
|
|
19
|
+
expect(result).toContain("\\textcolor");
|
|
20
|
+
expect(result).toContain("B^+");
|
|
21
|
+
});
|
|
22
|
+
it("does NOT wrap a non-selected, non-highlighted particle in \\textcolor", () => {
|
|
23
|
+
const result = convertParticleToLatex(mockMetadata, "B+", false);
|
|
24
|
+
expect(result).not.toContain("\\textcolor");
|
|
25
|
+
});
|
|
26
|
+
it("falls back to \\text{...} for particles not in metadata", () => {
|
|
27
|
+
const result = convertParticleToLatex(mockMetadata, "UnknownParticle999");
|
|
28
|
+
expect(result).toBe("\\text{UnknownParticle999}");
|
|
29
|
+
});
|
|
30
|
+
it("handles opening-parenthesis sub-decay prefix", () => {
|
|
31
|
+
const result = convertParticleToLatex(mockMetadata, "(K+");
|
|
32
|
+
expect(result.startsWith("(")).toBe(true);
|
|
33
|
+
expect(result).toContain("K^+");
|
|
34
|
+
});
|
|
35
|
+
it("handles closing-parenthesis sub-decay suffix", () => {
|
|
36
|
+
const result = convertParticleToLatex(mockMetadata, "K+)");
|
|
37
|
+
expect(result.endsWith(")")).toBe(true);
|
|
38
|
+
expect(result).toContain("K^+");
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
describe("selectionDescriptorToLatex()", () => {
|
|
42
|
+
it("returns a LaTeX string containing at least one particle symbol", () => {
|
|
43
|
+
const result = selectionDescriptorToLatex(mockMetadata, mockDecay, []);
|
|
44
|
+
expect(result.length).toBeGreaterThan(0);
|
|
45
|
+
});
|
|
46
|
+
it("highlights selected branches with \\textcolor", () => {
|
|
47
|
+
const result = selectionDescriptorToLatex(mockMetadata, mockDecay, ["head"]);
|
|
48
|
+
expect(result).toContain("\\textcolor");
|
|
49
|
+
});
|
|
50
|
+
it("does NOT highlight branches that are not selected", () => {
|
|
51
|
+
// Select only 'head'; 'k' should not be coloured
|
|
52
|
+
const result = selectionDescriptorToLatex(mockMetadata, mockDecay, ["head"]);
|
|
53
|
+
// K^+ should appear but not wrapped in textcolor
|
|
54
|
+
// Simplistic check: there's exactly one textcolor entry for B+
|
|
55
|
+
const colorCount = (result.match(/\\textcolor/g) || []).length;
|
|
56
|
+
expect(colorCount).toBe(1);
|
|
57
|
+
});
|
|
58
|
+
it("includes the arrow token as \\to", () => {
|
|
59
|
+
const result = selectionDescriptorToLatex(mockMetadata, mockDecay, []);
|
|
60
|
+
expect(result).toContain("\\to");
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|