Skip to content

Commit 31d654d

Browse files
Add tests of showing validation errors
1 parent 553435d commit 31d654d

File tree

1 file changed

+58
-0
lines changed

1 file changed

+58
-0
lines changed

extensions/ql-vscode/src/view/model-editor/__tests__/MethodRow.spec.tsx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,4 +438,62 @@ describe(MethodRow.name, () => {
438438
{ ...modeledMethod, type: "summary" },
439439
]);
440440
});
441+
442+
it("does not display validation errors when everything is valid", () => {
443+
render({
444+
modeledMethods: [
445+
{ ...modeledMethod, type: "source" },
446+
{ ...modeledMethod, type: "sink" },
447+
],
448+
viewState: {
449+
...viewState,
450+
showMultipleModels: true,
451+
},
452+
});
453+
454+
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
455+
});
456+
457+
it("displays a single validation error", () => {
458+
render({
459+
modeledMethods: [
460+
{ ...modeledMethod, type: "source" },
461+
{ ...modeledMethod, type: "source" },
462+
],
463+
viewState: {
464+
...viewState,
465+
showMultipleModels: true,
466+
},
467+
});
468+
469+
expect(screen.getByRole("alert")).toBeInTheDocument();
470+
expect(
471+
screen.getByText("Error: Duplicated classification"),
472+
).toBeInTheDocument();
473+
expect(
474+
screen.queryByText("Error: Conflicting classification"),
475+
).not.toBeInTheDocument();
476+
});
477+
478+
it("displays multiple validation errors", () => {
479+
render({
480+
modeledMethods: [
481+
{ ...modeledMethod, type: "source" },
482+
{ ...modeledMethod, type: "source" },
483+
{ ...modeledMethod, type: "neutral", kind: "source" },
484+
],
485+
viewState: {
486+
...viewState,
487+
showMultipleModels: true,
488+
},
489+
});
490+
491+
expect(screen.getAllByRole("alert").length).toBe(2);
492+
expect(
493+
screen.getByText("Error: Duplicated classification"),
494+
).toBeInTheDocument();
495+
expect(
496+
screen.getByText("Error: Conflicting classification"),
497+
).toBeInTheDocument();
498+
});
441499
});

0 commit comments

Comments
 (0)