1
0
mirror of https://pagure.io/fedora-qa/os-autoinst-distri-fedora.git synced 2024-11-16 19:53:09 +00:00
os-autoinst-distri-fedora/lib/cockpit.pm
Adam Williamson 20620236b3 Clean up minimal browser environment setup
Move the xauth disablement and the disabling of studies into
_setup_browser, instead of repeating it in a couple of other
places (but *not* doing it in the zezere test, where we should
be doing it). Drop some explicit package installs that should
no longer be needed as Firefox and/or X.org now depend on those
things. Install the current default fonts (Noto), not the old
ones (DejaVu).

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2023-03-02 13:51:08 -08:00

69 lines
2.2 KiB
Perl

package cockpit;
use strict;
use base 'Exporter';
use Exporter;
use lockapi;
use testapi;
use utils;
our @EXPORT = qw(start_cockpit select_cockpit_update check_updates);
sub start_cockpit {
# Starting from a console, get to a browser with Cockpit (running
# on localhost) shown. If login is truth-y, also log in. If login
# and admin are both truthy, also gain admin privileges. Assumes
# X and Firefox are installed.
my %args = @_;
$args{login} //= 0;
$args{admin} //= 1;
my $login = shift || 0;
# run firefox directly in X as root. never do this, kids!
type_string "startx /usr/bin/firefox -width 1024 -height 768 http://localhost:9090\n";
assert_screen "cockpit_login", 60;
wait_still_screen(stilltime => 5, similarity_level => 45);
if ($args{login}) {
type_safely "test";
wait_screen_change { send_key "tab"; };
type_safely get_var("USER_PASSWORD", "weakpassword");
send_key "ret";
if ($args{admin}) {
assert_and_click "cockpit_admin_enable";
assert_screen "cockpit_admin_password";
type_safely get_var("USER_PASSWORD", "weakpassword");
send_key "ret";
}
assert_screen "cockpit_main";
# wait for any animation or other weirdness
# can't use wait_still_screen because of that damn graph
sleep 3;
}
}
sub select_cockpit_update {
# This method navigates to to the updates screen
# From Firefox 100 on, we get 'adaptive scrollbars', which means
# the scrollbar is just invisible unless you moved the mouse
# recently. So we click in the search box and hit 'up' to scroll
# the sidebar to the bottom if necessary
assert_screen ["cockpit_software_updates", "cockpit_search"], 120;
click_lastmatch;
if (match_has_tag "cockpit_search") {
send_key "up";
wait_still_screen 2;
assert_and_click "cockpit_software_updates";
}
# wait for the updates to download
assert_screen 'cockpit_updates_check', 300;
}
sub check_updates {
my $logfile = shift;
sleep 2;
my $checkresult = script_run "dnf check-update > $logfile";
upload_logs "$logfile", failok => 1;
return ($checkresult);
}