Database-BI
view release on metacpan or search on metacpan
->status_is(200);
like($t->tx->res->body, qr/maxZoom:\s*0/, '?max_zoom=0 is a legal value (zero is valid)');
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon'))
->status_is(200);
# The tile layer's options: fitBounds has a maxZoom of its own, the zoom it
# fits to at most
unlike($t->tx->res->body, qr/attribution: '(?:[^'\\]|\\.)*',\s*maxZoom/, 'absent max_zoom= means no maxZoom option emitted');
};
subtest 'max_zoom= can come from config (map_max_zoom)' => sub {
local $t->app->config->{map_max_zoom} = 18;
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon'))->status_is(200);
like($t->tx->res->body, qr/maxZoom:\s*18/,
'map_max_zoom config key sets maxZoom when no URL param is supplied');
# URL param overrides config
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon', max_zoom => 14))
->status_is(200);
like($t->tx->res->body, qr/maxZoom:\s*14/,
'URL ?max_zoom= takes precedence over the config value');
};
subtest 'An unopenable source is a 404' => sub {
$t->get_ok(_url(l => 'path:/nonexistent/nothing.csv', loc => 'place'))
->status_is(404);
};
subtest 'Dashboard map panel exposes heat layer and zoom controls' => sub {
# The map panel in dashboard.html.tt should contain the new options row
# with the heatmap checkbox, weight column select, and zoom input.
$t->get_ok('/open?path=' . url_escape($places_csv))->status_is(200);
my $dash = $t->tx->res->body;
like($dash, qr/id="map-opts-row"/, 'map options row is in the panel');
like($dash, qr/id="map-heat-chk"/, 'heatmap layer checkbox is present');
like($dash, qr/id="map-weight-sel"/, 'heatmap weight column select is present');
like($dash, qr/id="map-zoom-inp"/, 'initial zoom input is present');
# Weight field starts hidden; it is shown when heatmap is checked
like($dash, qr/id="map-weight-field" hidden/, 'weight field starts hidden');
};
subtest 'Map panel colour-by select includes categorical columns' => sub {
# Before the fix, buildColorSelect filtered to numeric-only columns.
# Categorical columns (region) should now appear so eq/ne rules work.
# virginia_counties.csv has a non-numeric "region" column.
my $vc = File::Spec->catfile('data', 'virginia_counties.csv');
SKIP: {
skip 'data/virginia_counties.csv not found', 2 unless -f $vc;
$t->get_ok('/open?path=' . url_escape($vc))->status_is(200);
my $page = $t->tx->res->body;
# The color select options are built dynamically in JS from table headers,
# but the panel HTML must exist with the correct structure.
like($page, qr/id="map-color-sel"/, 'colour-by select is in the page');
# The JS function no longer filters to numeric-only: verify the
# numeric-guard line is absent from buildColorSelect specifically.
my $tpl = do { local $/; open(my $fh, '<', 'templates/web/en/dashboard.html.tt') or die; <$fh> };
# Extract just the buildColorSelect function body by finding it and
# the closing brace of the function's forEach callback.
my ($color_fn) = ($tpl =~ /(function buildColorSelect.*?^ \})/ms);
unlike($color_fn // '', qr/isNaN.*parseAccounting/,
'buildColorSelect no longer has the numeric-only filter');
}
};
subtest 'size= draws circle markers with a radius scaled from the column' => sub {
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon', size => 'amount'))
->status_is(200)
->content_like(qr/L\.circleMarker\(/, 'bubble map uses L.circleMarker')
->content_unlike(qr/data:image\/svg/, 'pins are not also drawn')
->content_like(qr/radius:\s*30\b/, 'largest amount gets the largest radius')
->content_like(qr/radius:\s*6\b/, 'smallest amount gets the smallest radius');
};
subtest 'size= with an unknown column is a 400' => sub {
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon', size => 'nope'))
->status_is(400)
->content_like(qr/Column not found: nope/);
};
subtest 'series= colours markers by category from the named scheme' => sub {
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon',
series => 'place', scheme => 'set2'))
->status_is(200)
->content_like(qr/data:image\/svg/, 'per-marker coloured icons are emitted')
->content_like(qr/var legendEntries = /, 'a colour key is drawn on the map')
->content_like(qr/Ramsgate/, 'the key names a category')
->content_like(qr/#66c2a5/, 'the first set2 colour is used');
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon',
series => 'place', scheme => 'not-a-scheme'))
->status_is(400)
->content_like(qr/Unknown colour scheme/);
};
subtest 'color= and series= are mutually exclusive' => sub {
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon',
color => 'place', series => 'place'))
->status_is(400)
->content_like(qr/color= or series=/);
};
subtest 'color rules colour the markers' => sub {
$t->get_ok(_url(l => $places_spec, lat => 'lat', lon => 'lon',
color => 'amount', color_rule => 'gt:6:#ff0000', color_default => '#00ff00'))
->status_is(200)
->content_like(qr/data:image\/svg/, 'coloured marker icons are emitted')
->content_like(qr/%23ff0000/, 'the matching rule colour is used');
};
subtest 'an absolute data_dir still resolves table: specs' => sub {
my $dd = tempdir(CLEANUP => 1);
_write_file(File::Spec->catfile($dd, 'places.csv'),
"id,place,lat,lon\n1,Ramsgate,51.33,1.42\n");
local $t->app->config->{data_dir} = $dd;
$t->get_ok(_url(l => 'table:places', lat => 'lat', lon => 'lon'))
->status_is(200)
->content_like(qr/L\.marker\(/, 'the table is found under an absolute data_dir');
};
( run in 1.486 second using v1.01-cache-2.11-cpan-60884a8df76 )