Skip to content

Commit

Permalink
without_field_autocomplete
Browse files Browse the repository at this point in the history
  • Loading branch information
ukrbublik committed Oct 25, 2023
1 parent 5fb631e commit 7163289
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
21 changes: 20 additions & 1 deletion packages/tests/specs/WidgetsMui.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import * as configs from "../support/configs";
import * as inits from "../support/inits";
import { with_qb_mui, hexToRgbString } from "../support/utils";
import { getAutocompleteUtils } from "../support/autocomplete";
import Select, { SelectChangeEvent } from "@mui/material/Select";

const ignoreLogDatePicker = (errText: string) => {
return errText.includes("The `anchorEl` prop provided to the component is invalid");
Expand All @@ -25,7 +26,7 @@ describe("mui theming", () => {
});

describe("mui core widgets", () => {
it("change field", async () => {
it("change field with autocomplete", async () => {
await with_qb_mui(configs.with_struct, inits.with_nested, "JsonLogic", async (qb) => {
const {
createCtx,
Expand Down Expand Up @@ -57,6 +58,24 @@ describe("mui core widgets", () => {
ignoreLog: ignoreLogDatePicker,
});
});

it("change field without autocomplete", async () => {
await with_qb_mui([configs.with_struct, configs.without_field_autocomplete], inits.with_nested, "JsonLogic", async (qb, onChange, {expect_jlogic}) => {
const sel = qb.find(".rule--field").find(Select).last();
sel.prop("onChange")?.({target: {value: "user.login"}} as SelectChangeEvent, null);
qb.update();

expect_jlogic([null,
{
"and": [
{ "==": [ { "var": "user.login" }, "abc" ] },
]
}
]);
}, {
ignoreLog: ignoreLogDatePicker,
});
});
});

describe("mui widgets interactions", () => {
Expand Down
21 changes: 21 additions & 0 deletions packages/tests/support/configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,27 @@ export const with_theme_material = (BasicConfig) => ({
}
});

export const without_field_autocomplete = (BasicConfig) => ({
...BasicConfig,
widgets: {
...BasicConfig.widgets,
field: {
...BasicConfig.widgets.field,
customProps: {
...(BasicConfig.widgets?.field?.customProps || {}),
showSearch: false
}
},
},
settings: {
...BasicConfig.settings,
customFieldSelectProps: {
...(BasicConfig.settings?.customFieldSelectProps || {}),
showSearch: false
},
}
});

export const with_theme_mui = (BasicConfig) => ({
...with_all_types(BasicConfig),
settings: {
Expand Down

0 comments on commit 7163289

Please sign in to comment.