Developer-Dashboard
view release on metacpan or search on metacpan
t/38-web-no-editor-browser.t view on Meta::CPAN
my $ua = LWP::UserAgent->new( timeout => 2 );
for ( 1 .. _http_probe_attempts() ) {
my $response = $ua->get($url);
return 1 if $response->is_success;
sleep 0.25;
}
die "Timed out waiting for dashboard HTTP URL $url\n";
}
sub _http_probe_attempts {
my $perl5opt = join ' ', grep { defined $_ && $_ ne '' } ( $ENV{PERL5OPT}, $ENV{HARNESS_PERL_SWITCHES} );
return 240 if $perl5opt =~ /Devel::Cover/;
return 80;
}
sub _coverage_requested {
my $perl5opt = join ' ', grep { defined $_ && $_ ne '' } ( $ENV{PERL5OPT}, $ENV{HARNESS_PERL_SWITCHES} );
return $perl5opt =~ /Devel::Cover/ ? 1 : 0;
}
# _read_text($path)
# Purpose: slurp one text file for browser-smoke diagnostics.
# Input: absolute file path string.
# Output: entire file contents as a string.
sub _read_text {
my ($path) = @_;
open my $fh, '<', $path or die "Unable to read $path: $!";
local $/;
my $text = <$fh>;
close $fh or die "Unable to close $path: $!";
return defined $text ? $text : '';
}
__END__
=head1 NAME
38-web-no-editor-browser.t - Chromium smoke for the no-editor browser mode
=head1 DESCRIPTION
This test verifies the browser-visible happy and sad paths for
C<dashboard serve --no-editor>. It confirms that a saved page still renders in
Chromium while the Share, Play, and View Source chrome is hidden, and it also
confirms that direct browser requests to the saved bookmark edit and source
routes return the explicit read-only denial instead of exposing bookmark
content.
=for comment FULL-POD-DOC START
=head1 PURPOSE
This test is the executable browser regression contract for the no-editor web
mode. Use it when changing served bookmark chrome, bookmark editor access
rules, or any route that is supposed to stay read-only in browser mode.
=head1 WHY IT EXISTS
It exists because a cosmetic-only lock would be too weak here. The browser can
hide links while the real edit and source routes still exist, so this test
keeps one real Chromium render path and a couple of blocked sad paths under
the repository gate.
=head1 WHEN TO USE
Use this file when changing C<dashboard serve>, bookmark editor exposure, top
chrome links, or read-only browser behavior.
=head1 HOW TO USE
Run it directly with C<prove -lv t/38-web-no-editor-browser.t> when Chromium
is available. It starts an isolated foreground dashboard server in
C<--no-editor> mode, dumps the rendered DOM for one saved page, then checks
the blocked edit and source routes through the same browser.
=head1 WHAT USES IT
Developers during TDD, the full repository suite, and release verification all
use this test to keep the read-only browser promise honest.
=head1 EXAMPLES
Example 1:
prove -lv t/38-web-no-editor-browser.t
Run the focused Chromium regression by itself while changing read-only browser
behavior.
Example 2:
prove -lr t
Put the browser no-editor regression back through the whole repository suite
before release.
Example 3:
chromium --headless --dump-dom http://127.0.0.1:7890/app/readonly
Manually inspect the served DOM if you need an extra browser-level spot check
outside the Perl harness.
=for comment FULL-POD-DOC END
=cut
( run in 1.701 second using v1.01-cache-2.11-cpan-5837b0d9d2c )