Skip to content

Commit ad10912

Browse files
committed
Fix formatting
1 parent 80a535e commit ad10912

2 files changed

Lines changed: 81 additions & 40 deletions

File tree

client/src/components/__tests__/DynamicJsonForm.test.tsx

Lines changed: 56 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -676,10 +676,18 @@ describe("DynamicJsonForm Validation Functionality", () => {
676676
onClick={() => {
677677
const result = formRef.current?.validateJson();
678678
// Add data attributes to make validation result testable
679-
const button = document.querySelector('[data-testid="validate-button"]') as HTMLElement;
679+
const button = document.querySelector(
680+
'[data-testid="validate-button"]',
681+
) as HTMLElement;
680682
if (button && result) {
681-
button.setAttribute('data-validation-valid', result.isValid.toString());
682-
button.setAttribute('data-validation-error', result.error || '');
683+
button.setAttribute(
684+
"data-validation-valid",
685+
result.isValid.toString(),
686+
);
687+
button.setAttribute(
688+
"data-validation-error",
689+
result.error || "",
690+
);
683691
}
684692
}}
685693
data-testid="validate-button"
@@ -702,7 +710,7 @@ describe("DynamicJsonForm Validation Functionality", () => {
702710

703711
const TestComponent = () => {
704712
const formRef = useRef<DynamicJsonFormRef>(null);
705-
713+
706714
return (
707715
<div>
708716
<DynamicJsonForm
@@ -714,10 +722,18 @@ describe("DynamicJsonForm Validation Functionality", () => {
714722
<button
715723
onClick={() => {
716724
const result = formRef.current?.validateJson();
717-
const button = document.querySelector('[data-testid="validate-button"]') as HTMLElement;
725+
const button = document.querySelector(
726+
'[data-testid="validate-button"]',
727+
) as HTMLElement;
718728
if (button && result) {
719-
button.setAttribute('data-validation-valid', result.isValid.toString());
720-
button.setAttribute('data-validation-error', result.error || '');
729+
button.setAttribute(
730+
"data-validation-valid",
731+
result.isValid.toString(),
732+
);
733+
button.setAttribute(
734+
"data-validation-error",
735+
result.error || "",
736+
);
721737
}
722738
}}
723739
data-testid="validate-button"
@@ -733,8 +749,8 @@ describe("DynamicJsonForm Validation Functionality", () => {
733749
const validateButton = screen.getByTestId("validate-button");
734750
fireEvent.click(validateButton);
735751

736-
expect(validateButton.getAttribute('data-validation-valid')).toBe('true');
737-
expect(validateButton.getAttribute('data-validation-error')).toBe('');
752+
expect(validateButton.getAttribute("data-validation-valid")).toBe("true");
753+
expect(validateButton.getAttribute("data-validation-error")).toBe("");
738754
});
739755

740756
it("should return valid for valid JSON in JSON mode", () => {
@@ -743,8 +759,8 @@ describe("DynamicJsonForm Validation Functionality", () => {
743759
const validateButton = screen.getByTestId("validate-button");
744760
fireEvent.click(validateButton);
745761

746-
expect(validateButton.getAttribute('data-validation-valid')).toBe('true');
747-
expect(validateButton.getAttribute('data-validation-error')).toBe('');
762+
expect(validateButton.getAttribute("data-validation-valid")).toBe("true");
763+
expect(validateButton.getAttribute("data-validation-error")).toBe("");
748764
});
749765

750766
it("should return invalid for malformed JSON in JSON mode", async () => {
@@ -759,8 +775,12 @@ describe("DynamicJsonForm Validation Functionality", () => {
759775
const validateButton = screen.getByTestId("validate-button");
760776
fireEvent.click(validateButton);
761777

762-
expect(validateButton.getAttribute('data-validation-valid')).toBe('false');
763-
expect(validateButton.getAttribute('data-validation-error')).toContain('JSON');
778+
expect(validateButton.getAttribute("data-validation-valid")).toBe(
779+
"false",
780+
);
781+
expect(validateButton.getAttribute("data-validation-error")).toContain(
782+
"JSON",
783+
);
764784
});
765785
});
766786

@@ -769,37 +789,43 @@ describe("DynamicJsonForm Validation Functionality", () => {
769789

770790
// Clear the textarea
771791
const textarea = screen.getByRole("textbox");
772-
fireEvent.change(textarea, { target: { value: '' } });
792+
fireEvent.change(textarea, { target: { value: "" } });
773793

774794
const validateButton = screen.getByTestId("validate-button");
775795
fireEvent.click(validateButton);
776796

777-
expect(validateButton.getAttribute('data-validation-valid')).toBe('true');
778-
expect(validateButton.getAttribute('data-validation-error')).toBe('');
797+
expect(validateButton.getAttribute("data-validation-valid")).toBe("true");
798+
expect(validateButton.getAttribute("data-validation-error")).toBe("");
779799
});
780800

781801
it("should set error state when validation fails", async () => {
782802
renderFormWithRef();
783803

784804
// Enter invalid JSON
785805
const textarea = screen.getByRole("textbox");
786-
fireEvent.change(textarea, { target: { value: '{ "trailing": "comma", }' } });
806+
fireEvent.change(textarea, {
807+
target: { value: '{ "trailing": "comma", }' },
808+
});
787809

788810
// Trigger validation
789811
const validateButton = screen.getByTestId("validate-button");
790812
fireEvent.click(validateButton);
791813

792814
// Check that validation result shows error
793-
expect(validateButton.getAttribute('data-validation-valid')).toBe('false');
794-
expect(validateButton.getAttribute('data-validation-error')).toContain('JSON');
815+
expect(validateButton.getAttribute("data-validation-valid")).toBe(
816+
"false",
817+
);
818+
expect(validateButton.getAttribute("data-validation-error")).toContain(
819+
"JSON",
820+
);
795821
});
796822
});
797823

798824
describe("forwardRef functionality", () => {
799825
it("should expose validateJson method through ref", () => {
800826
const TestComponent = () => {
801827
const formRef = useRef<DynamicJsonFormRef>(null);
802-
828+
803829
return (
804830
<div>
805831
<DynamicJsonForm
@@ -815,10 +841,16 @@ describe("DynamicJsonForm Validation Functionality", () => {
815841
/>
816842
<button
817843
onClick={() => {
818-
const hasValidateMethod = typeof formRef.current?.validateJson === 'function';
819-
const button = document.querySelector('[data-testid="ref-test-button"]') as HTMLElement;
844+
const hasValidateMethod =
845+
typeof formRef.current?.validateJson === "function";
846+
const button = document.querySelector(
847+
'[data-testid="ref-test-button"]',
848+
) as HTMLElement;
820849
if (button) {
821-
button.setAttribute('data-has-validate-method', hasValidateMethod.toString());
850+
button.setAttribute(
851+
"data-has-validate-method",
852+
hasValidateMethod.toString(),
853+
);
822854
}
823855
}}
824856
data-testid="ref-test-button"
@@ -834,7 +866,7 @@ describe("DynamicJsonForm Validation Functionality", () => {
834866
const testButton = screen.getByTestId("ref-test-button");
835867
fireEvent.click(testButton);
836868

837-
expect(testButton.getAttribute('data-has-validate-method')).toBe('true');
869+
expect(testButton.getAttribute("data-has-validate-method")).toBe("true");
838870
});
839871
});
840872
});

client/src/components/__tests__/ToolsTab.test.tsx

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,8 @@ describe("ToolsTab", () => {
671671

672672
// Enter invalid JSON in the first textarea
673673
const configTextarea = textareas[0];
674-
fireEvent.change(configTextarea, {
675-
target: { value: '{ "invalid": json }' }
674+
fireEvent.change(configTextarea, {
675+
target: { value: '{ "invalid": json }' },
676676
});
677677

678678
// Try to run the tool
@@ -695,15 +695,18 @@ describe("ToolsTab", () => {
695695

696696
// Find JSON editor textareas
697697
const textareas = screen.getAllByRole("textbox");
698-
698+
699699
// Enter valid JSON in the first textarea
700-
fireEvent.change(textareas[0], {
701-
target: { value: '{ "config": { "setting": "value" }, "data": ["item1", "item2"] }' }
700+
fireEvent.change(textareas[0], {
701+
target: {
702+
value:
703+
'{ "config": { "setting": "value" }, "data": ["item1", "item2"] }',
704+
},
702705
});
703706

704707
// Wait for debounced updates
705708
await act(async () => {
706-
await new Promise(resolve => setTimeout(resolve, 350));
709+
await new Promise((resolve) => setTimeout(resolve, 350));
707710
});
708711

709712
// Try to run the tool
@@ -725,10 +728,13 @@ describe("ToolsTab", () => {
725728
});
726729

727730
const textareas = screen.getAllByRole("textbox");
728-
731+
729732
// Enter invalid JSON that contains both valid and invalid parts
730-
fireEvent.change(textareas[0], {
731-
target: { value: '{ "config": { "setting": "value" }, "data": ["unclosed array" }' }
733+
fireEvent.change(textareas[0], {
734+
target: {
735+
value:
736+
'{ "config": { "setting": "value" }, "data": ["unclosed array" }',
737+
},
732738
});
733739

734740
// Try to run the tool
@@ -764,7 +770,7 @@ describe("ToolsTab", () => {
764770
// Fill in the simple parameters
765771
const messageInput = screen.getByRole("textbox");
766772
const countInput = screen.getByRole("spinbutton");
767-
773+
768774
fireEvent.change(messageInput, { target: { value: "test message" } });
769775
fireEvent.change(countInput, { target: { value: "5" } });
770776

@@ -775,10 +781,13 @@ describe("ToolsTab", () => {
775781
});
776782

777783
// Tool should have been called successfully (no JSON validation needed)
778-
expect(mockCallTool).toHaveBeenCalledWith(simpleToolWithStringParam.name, {
779-
message: "test message",
780-
count: 5,
781-
});
784+
expect(mockCallTool).toHaveBeenCalledWith(
785+
simpleToolWithStringParam.name,
786+
{
787+
message: "test message",
788+
count: 5,
789+
},
790+
);
782791
});
783792

784793
it("should handle empty JSON parameters correctly", async () => {
@@ -790,9 +799,9 @@ describe("ToolsTab", () => {
790799
});
791800

792801
const textareas = screen.getAllByRole("textbox");
793-
802+
794803
// Clear the textarea (empty JSON should be valid)
795-
fireEvent.change(textareas[0], { target: { value: '' } });
804+
fireEvent.change(textareas[0], { target: { value: "" } });
796805

797806
// Try to run the tool
798807
const runButton = screen.getByRole("button", { name: /run tool/i });

0 commit comments

Comments
 (0)