Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix in and not in filter UI bug #2403

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,13 @@ impl Component for ConfigSelector {
let mut tokens = current.split(',').collect::<Vec<_>>();
tokens.pop();
tokens.push(&input);
filter[index].2 = FilterTerm::Scalar(Scalar::String(tokens.join(",")));
filter[index].2 = FilterTerm::Array(
tokens
.iter()
.map(|x| Scalar::String(x.trim().to_owned()))
.collect(),
);

let filter = Some(filter);
ViewConfigUpdate {
filter,
Expand Down
58 changes: 58 additions & 0 deletions rust/perspective-viewer/test/js/regressions.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,64 @@ test.describe("Regression tests", () => {
]);
});

test("in filter generates correct array-encoded config", async ({
page,
}) => {
await page.evaluate(async () => {
const viewer = document.querySelector("perspective-viewer");
await viewer.restore({
group_by: ["State"],
columns: ["Sales"],
settings: true,
filter: [["State", "in", []]],
});

const filter = viewer.shadowRoot.querySelector(
".pivot-column input[type=text]"
);
filter.value = "C";
const event = new Event("input", {
bubbles: true,
cancelable: true,
});

filter.dispatchEvent(event);
});

const elem = await page.waitForSelector("perspective-dropdown");
await page.evaluate((elem) => {
let node = elem.shadowRoot.querySelector("span:first-of-type");
var clickEvent = document.createEvent("MouseEvents");
clickEvent.initEvent("mousedown", true, true);
node.dispatchEvent(clickEvent);
}, elem);

const config = await page.evaluate(async () => {
const viewer = document.querySelector("perspective-viewer");
return await viewer.save();
});

expect(config).toEqual({
aggregates: {},
columns: ["Sales"],
expressions: [],
filter: [["State", "in", ["California"]]],
group_by: ["State"],
plugin: "Debug",
plugin_config: {},
settings: true,
sort: [],
split_by: [],
theme: "Pro Light",
title: null,
});

const contents = await get_contents(page);
await compareContentsToSnapshot(contents, [
"regressions-in-filter-generates-correct-config.txt",
]);
});

test("Numeric filter input does not trigger render on trailing zeroes", async ({
page,
}) => {
Expand Down
Binary file modified tools/perspective-test/results.tar.gz
Binary file not shown.
Loading