use Mojo::Base -strict; use Test2::V0; use FindBin; use lib "${FindBin::Bin}/../lib/"; use lib "${FindBin::Bin}/lib/"; use Dashboard::Test qw(test_app); my $t = test_app(); $t->get_ok('/probes/ph') ->status_is(200) ->element_exists_not('#navbar-title') ->element_exists( 'main section[data-controls-panel][aria-labelledby="probe-controls-title"]' ) ->text_is( '#probe-controls-title', 'pH chart controls' ) ->element_exists('#probe-controls .graph-control') ->text_is( '#probe-controls [data-control-group="range"]', 'Range' ) ->text_is( '#probe-controls [data-control-group="timeframe"]', 'Timeframe' ) ->text_is( '.card-header h2 a[href="/probes/ph"]', 'pH' ) ->element_exists('.navbar-nav a.nav-link.active.dropdown-toggle') ->element_exists('section#probe-ph[data-panel="ph"] canvas#chart-ph') ->text_is( 'a[data-raw-download][data-probe="ph"]', 'Download data' ) ->element_exists( 'button[data-timeframe="day"].timeframe-button.dropdown-item') ->element_exists( '.timeframe-control.dropdown > button[data-timeframe-dropdown-label]') ->element_exists_not('.timeframe-control.btn-group') ->element_exists( 'script[src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/js/bootstrap.bundle.min.js"]' . '[integrity="sha384-YvpcrYf0tY3lHB60NNkmXc5s9fDVZLESaAA55NDzOxhy9GkcIdslK1eN7N6jIeHz"]' ) ->element_exists('tbody[data-reading-messages="ph"]') ->element_exists_not('section#probe-do[data-panel="do"]'); for my $timeframe (qw(hour day week month year)) { $t->element_exists( qq{.timeframe-control button[data-timeframe="$timeframe"]}); } $t->get_ok('/probes/unknown')->status_is(404); $t->get_ok('/graphs/ph')->status_is(404); $t->get_ok('/probes') ->status_is(200) ->element_exists( 'main section[data-controls-panel][aria-labelledby="probes-controls-title"]' ) ->text_is( '#probes-controls-title', 'Probe chart controls' ) ->element_exists( '#probes-controls .graph-control[data-default-timeframe="day"]') ->element_exists('main.container') ->element_exists('div.probes-grid') ->element_exists('.navbar-nav a.nav-link.active.dropdown-toggle'); for my $probe (qw(ph do orp ec)) { $t->element_exists( qq{div.probes-grid .card-header h2 a[href="/probes/$probe"]}); $t->element_exists( qq{section#probe-${probe}[data-panel="$probe"] canvas#chart-$probe}); $t->element_exists(qq{a[data-raw-download][data-probe="$probe"]}); } done_testing;