diff --git a/test-runtime/index.html b/test-runtime/index.html index 456d6084b2b..931e7bc2c41 100644 --- a/test-runtime/index.html +++ b/test-runtime/index.html @@ -45,15 +45,6 @@ target.dispatchEvent(type === 'wheel' ? new WheelEvent('wheel', opts) : new MouseEvent(type, opts)); } - function pureClear(id, parent, targetBrush) { - const el0 = mark(id, parent); - const [clientX, clientY] = coords(el0); - - pureMouseEvt('mousedown', el0, {clientX, clientY}); - pureMouseEvt('mouseup', window, {clientX, clientY}); - pureMouseEvt('click', el0, {clientX, clientY}); - } - function mark(id, parent) { return document.querySelector((parent ? `g.${parent} ` : '') + `g.mark-symbol.role-mark path:nth-child(${id})`); } diff --git a/test-runtime/region.test.ts b/test-runtime/region.test.ts index 3e81258a502..2ea652ed48d 100644 --- a/test-runtime/region.test.ts +++ b/test-runtime/region.test.ts @@ -1,6 +1,6 @@ import {TopLevelSpec} from '../src'; import {SELECTION_ID, SelectionType} from '../src/selection'; -import {clear, embedFn, circleRegion, polygonRegion, spec, testRenderFn, hits} from './util'; +import {clearRegion, embedFn, circleRegion, polygonRegion, spec, testRenderFn, hits} from './util'; import {Page} from 'puppeteer/lib/cjs/puppeteer/common/Page'; describe('region selections at runtime in unit views', () => { @@ -60,8 +60,8 @@ describe('region selections at runtime in unit views', () => { let store = await page.evaluate(circleRegion(hit.id)); expect(store).toHaveLength(hit.count); - store = await page.evaluate(clear(hits.region.circle_clear[0].id)); - expect(store).toBeUndefined(); + store = await page.evaluate(clearRegion(hits.region.circle_clear[0].id)); + expect(store).toHaveLength(0); await testRender(`clear_0`); }); diff --git a/test-runtime/resolve.test.ts b/test-runtime/resolve.test.ts index d3873dffde2..e465d341c3f 100644 --- a/test-runtime/resolve.test.ts +++ b/test-runtime/resolve.test.ts @@ -3,6 +3,7 @@ import { compositeTypes, embedFn, hits as hitsMaster, + multiviewRegion, parentSelector, pt, resolutions, @@ -14,10 +15,15 @@ import { import {Page} from 'puppeteer/lib/cjs/puppeteer/common/Page'; import {TopLevelSpec} from '../src'; +const fns = { + point: pt, + interval: brush, + region: multiviewRegion +}; + for (const type of selectionTypes) { - const isInterval = type === 'interval'; const hits = hitsMaster[type]; - const fn = isInterval ? brush : pt; + const fn = fns[type]; describe(`${type} selections at runtime`, () => { let page: Page; @@ -49,7 +55,7 @@ for (const type of selectionTypes) { const selection = { type, resolve: 'global', - ...(specType === 'facet' ? {encodings: ['y']} : {}) + ...(specType === 'facet' && type !== 'region' ? {encodings: ['y']} : {}) }; for (let i = 0; i < hits[specType].length; i++) { @@ -72,7 +78,7 @@ for (const type of selectionTypes) { const selection = { type, resolve, - ...(specType === 'facet' ? {encodings: ['x']} : {}) + ...(specType === 'facet' && type !== 'region' ? {encodings: ['x']} : {}) }; /** diff --git a/test-runtime/resources/region/facet/global_0.svg b/test-runtime/resources/region/facet/global_0.svg new file mode 100644 index 00000000000..e9b60bbfb9f --- /dev/null +++ b/test-runtime/resources/region/facet/global_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/global_1.svg b/test-runtime/resources/region/facet/global_1.svg new file mode 100644 index 00000000000..9914adb83d2 --- /dev/null +++ b/test-runtime/resources/region/facet/global_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/global_2.svg b/test-runtime/resources/region/facet/global_2.svg new file mode 100644 index 00000000000..fc5392f14c3 --- /dev/null +++ b/test-runtime/resources/region/facet/global_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/global_clear_2.svg b/test-runtime/resources/region/facet/global_clear_2.svg new file mode 100644 index 00000000000..cb25b91108f --- /dev/null +++ b/test-runtime/resources/region/facet/global_clear_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_0.svg b/test-runtime/resources/region/facet/intersect_0.svg new file mode 100644 index 00000000000..eb6da9e8efd --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_1.svg b/test-runtime/resources/region/facet/intersect_1.svg new file mode 100644 index 00000000000..33125299375 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_2.svg b/test-runtime/resources/region/facet/intersect_2.svg new file mode 100644 index 00000000000..9683dc23066 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_clear_0.svg b/test-runtime/resources/region/facet/intersect_clear_0.svg new file mode 100644 index 00000000000..2884ee4b8e0 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_clear_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_clear_1.svg b/test-runtime/resources/region/facet/intersect_clear_1.svg new file mode 100644 index 00000000000..be479fff920 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_clear_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/intersect_clear_2.svg b/test-runtime/resources/region/facet/intersect_clear_2.svg new file mode 100644 index 00000000000..b9bfcf6b8c4 --- /dev/null +++ b/test-runtime/resources/region/facet/intersect_clear_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_0.svg b/test-runtime/resources/region/facet/union_0.svg new file mode 100644 index 00000000000..eb6da9e8efd --- /dev/null +++ b/test-runtime/resources/region/facet/union_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_1.svg b/test-runtime/resources/region/facet/union_1.svg new file mode 100644 index 00000000000..5e1dc0206c8 --- /dev/null +++ b/test-runtime/resources/region/facet/union_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_2.svg b/test-runtime/resources/region/facet/union_2.svg new file mode 100644 index 00000000000..c60a6315900 --- /dev/null +++ b/test-runtime/resources/region/facet/union_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_clear_0.svg b/test-runtime/resources/region/facet/union_clear_0.svg new file mode 100644 index 00000000000..2884ee4b8e0 --- /dev/null +++ b/test-runtime/resources/region/facet/union_clear_0.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_clear_1.svg b/test-runtime/resources/region/facet/union_clear_1.svg new file mode 100644 index 00000000000..be479fff920 --- /dev/null +++ b/test-runtime/resources/region/facet/union_clear_1.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/facet/union_clear_2.svg b/test-runtime/resources/region/facet/union_clear_2.svg new file mode 100644 index 00000000000..ed821edf5a1 --- /dev/null +++ b/test-runtime/resources/region/facet/union_clear_2.svg @@ -0,0 +1 @@ +c012 \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_0.svg b/test-runtime/resources/region/repeat/global_0.svg new file mode 100644 index 00000000000..3aa27092c9e --- /dev/null +++ b/test-runtime/resources/region/repeat/global_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_1.svg b/test-runtime/resources/region/repeat/global_1.svg new file mode 100644 index 00000000000..79477098ba4 --- /dev/null +++ b/test-runtime/resources/region/repeat/global_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_2.svg b/test-runtime/resources/region/repeat/global_2.svg new file mode 100644 index 00000000000..81dd340021d --- /dev/null +++ b/test-runtime/resources/region/repeat/global_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/global_clear_2.svg b/test-runtime/resources/region/repeat/global_clear_2.svg new file mode 100644 index 00000000000..35d7e51bbfd --- /dev/null +++ b/test-runtime/resources/region/repeat/global_clear_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_0.svg b/test-runtime/resources/region/repeat/intersect_0.svg new file mode 100644 index 00000000000..18ba0ea4421 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_1.svg b/test-runtime/resources/region/repeat/intersect_1.svg new file mode 100644 index 00000000000..12d9e4d08e1 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_2.svg b/test-runtime/resources/region/repeat/intersect_2.svg new file mode 100644 index 00000000000..b5ed167f3b5 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_clear_0.svg b/test-runtime/resources/region/repeat/intersect_clear_0.svg new file mode 100644 index 00000000000..3574852192a --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_clear_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_clear_1.svg b/test-runtime/resources/region/repeat/intersect_clear_1.svg new file mode 100644 index 00000000000..3882d40c820 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_clear_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/intersect_clear_2.svg b/test-runtime/resources/region/repeat/intersect_clear_2.svg new file mode 100644 index 00000000000..3d2e06adf79 --- /dev/null +++ b/test-runtime/resources/region/repeat/intersect_clear_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_0.svg b/test-runtime/resources/region/repeat/union_0.svg new file mode 100644 index 00000000000..18ba0ea4421 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_1.svg b/test-runtime/resources/region/repeat/union_1.svg new file mode 100644 index 00000000000..76b0bb9287d --- /dev/null +++ b/test-runtime/resources/region/repeat/union_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_2.svg b/test-runtime/resources/region/repeat/union_2.svg new file mode 100644 index 00000000000..f01ab7a7e36 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_clear_0.svg b/test-runtime/resources/region/repeat/union_clear_0.svg new file mode 100644 index 00000000000..3574852192a --- /dev/null +++ b/test-runtime/resources/region/repeat/union_clear_0.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_clear_1.svg b/test-runtime/resources/region/repeat/union_clear_1.svg new file mode 100644 index 00000000000..3882d40c820 --- /dev/null +++ b/test-runtime/resources/region/repeat/union_clear_1.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/repeat/union_clear_2.svg b/test-runtime/resources/region/repeat/union_clear_2.svg new file mode 100644 index 00000000000..edd1fa5361f --- /dev/null +++ b/test-runtime/resources/region/repeat/union_clear_2.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/test-runtime/resources/region/unit/clear_0.svg b/test-runtime/resources/region/unit/clear_0.svg index a442a6aea6e..1b119829d88 100644 --- a/test-runtime/resources/region/unit/clear_0.svg +++ b/test-runtime/resources/region/unit/clear_0.svg @@ -1 +1 @@ - \ No newline at end of file + \ No newline at end of file diff --git a/test-runtime/util.ts b/test-runtime/util.ts index d1de67175f0..6f3e2a0d810 100644 --- a/test-runtime/util.ts +++ b/test-runtime/util.ts @@ -10,7 +10,7 @@ const generate = process.env.VL_GENERATE_TESTS; const output = 'test-runtime/resources'; export type ComposeType = 'unit' | 'repeat' | 'facet'; -export const selectionTypes: SelectionType[] = ['point', 'interval']; +export const selectionTypes: SelectionType[] = ['point', 'interval', 'region']; export const compositeTypes: ComposeType[] = ['repeat', 'facet']; export const resolutions: SelectionResolution[] = ['union', 'intersect']; @@ -139,7 +139,13 @@ export const hits = { ], count: 2 } - ] + ], + + facet: [2, 4, 7], + facet_clear: [3, 5, 8], + + repeat: [5, 10, 16], + repeat_clear: [13, 14, 2] } }; @@ -294,8 +300,8 @@ export function parentSelector(compositeType: ComposeType, index: number) { return compositeType === 'facet' ? `cell > g:nth-child(${index + 1})` : `${UNIT_NAMES.repeat[index]}_group`; } -export function clear(idx: number, parent?: string, targetBrush?: boolean) { - return `pureClear(${idx}, ${stringValue(parent)}, ${!!targetBrush})`; +export function clearRegion(idx: number, parent?: string, targetBrush?: boolean) { + return `clear(${idx}, ${stringValue(parent)}, ${!!targetBrush})`; } export function circleRegion(idx: number, parent?: string, targetBrush?: boolean, radius = 40, segments = 20) { @@ -306,6 +312,12 @@ export function polygonRegion(idx: number, polygon: number[][], parent?: string, return `polygonRegion(${idx}, ${JSON.stringify(polygon)}, ${stringValue(parent)}, ${!!targetBrush})`; } +export function multiviewRegion(key: string, idx: number, parent?: string, targetBrush?: boolean) { + return key.match('_clear') + ? clearRegion(hits.region[key][idx], parent, targetBrush) + : circleRegion(hits.region[key][idx], parent, targetBrush, 10); +} + export function brush(key: string, idx: number, parent?: string, targetBrush?: boolean) { const fn = key.match('_clear') ? 'clear' : 'brush'; return `${fn}(${hits.interval[key][idx].join(', ')}, ${stringValue(parent)}, ${!!targetBrush})`;