| 1 |
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/../common/pywrap", sys.argv) |
| 2 |
|
| 3 |
# |
| 4 |
# Copyright (C) 2017 Red Hat, Inc. |
| 5 |
# SPDX-License-Identifier: LGPL-2.1-or-later |
| 6 |
|
| 7 |
|
| 8 |
import testlib |
| 9 |
|
| 10 |
|
| 11 |
@testlib.nondestructive |
| 12 |
class TestActivePages(testlib.MachineCase): |
| 13 |
def testBasic(self): |
| 14 |
b = self.browser |
| 15 |
m = self.machine |
| 16 |
|
| 17 |
# disable preloads; they are different between OSes, make the counting hard, and happen asynchronously |
| 18 |
self.disable_preload("packagekit", "playground", "systemd") |
| 19 |
|
| 20 |
self.login_and_go("/system") |
| 21 |
|
| 22 |
b.wait_visible("#overview") |
| 23 |
|
| 24 |
def showPagesAssertCount(count): |
| 25 |
b.switch_to_top() |
| 26 |
b.mouse("#toggle-menu", "click", altKey=True) |
| 27 |
b.click("#active-pages") |
| 28 |
b.wait_visible("#active-pages-dialog") |
| 29 |
b.wait_count("#active-pages-dialog tr", count) |
| 30 |
|
| 31 |
# Initially we have /system |
| 32 |
showPagesAssertCount(1) |
| 33 |
b.click("button:contains('Cancel')") |
| 34 |
b.wait_not_present("#active-pages-dialog") |
| 35 |
|
| 36 |
b.go("/users") |
| 37 |
b.enter_page("/users") |
| 38 |
b.wait_visible("#accounts-list") |
| 39 |
|
| 40 |
# now we have the users page be present in the pages menu |
| 41 |
showPagesAssertCount(2) |
| 42 |
b.click("button:contains('Cancel')") |
| 43 |
b.wait_not_present("#active-pages-dialog") |
| 44 |
|
| 45 |
# open the terminal page and start a session we can see on the machine |
| 46 |
# Remove failed units which will show up in the first terminal line |
| 47 |
m.execute("systemctl reset-failed") |
| 48 |
b.go("/system/terminal") |
| 49 |
b.enter_page("/system/terminal") |
| 50 |
|
| 51 |
def line_sel(i): |
| 52 |
return '.terminal .xterm-accessibility-tree div:nth-child(%d)' % i |
| 53 |
|
| 54 |
# WebGL2 is not supported in firefox headless mode |
| 55 |
if b.browser != "firefox": |
| 56 |
# wait for prompt in first line |
| 57 |
b.wait_visible(".terminal .xterm-accessibility-tree") |
| 58 |
b.wait_in_text(line_sel(1), '$') |
| 59 |
|
| 60 |
# run a command that we can easily identify, and which will die with the terminal |
| 61 |
b.input_text("sleep 42\n") |
| 62 |
|
| 63 |
# wait for command to run |
| 64 |
m.execute("until pgrep -afx 'sleep 42'; do sleep 1; done") |
| 65 |
|
| 66 |
# now close the page |
| 67 |
showPagesAssertCount(3) |
| 68 |
# terminal should be pre-checked by default |
| 69 |
b.wait_visible('tr[data-row-id="cockpit1:localhost/system/terminal"] input[type=checkbox]:checked') |
| 70 |
# click on the main page as well |
| 71 |
b.click('tr[data-row-id="cockpit1:localhost/system"] input[type=checkbox]') |
| 72 |
# wait until it's highlighted |
| 73 |
b.wait_visible('tr[data-row-id="cockpit1:localhost/system"] input[type=checkbox]:checked') |
| 74 |
# close |
| 75 |
b.click("#active-pages-dialog button.pf-m-primary") |
| 76 |
b.wait_not_present("#active-pages-dialog") |
| 77 |
|
| 78 |
# this should kill the two frames |
| 79 |
b.wait_not_present("iframe[name='cockpit1:localhost/system']") |
| 80 |
b.wait_not_present("iframe[name='cockpit1:localhost/system/terminal']") |
| 81 |
|
| 82 |
# running shell command should disappear on the system |
| 83 |
m.execute("while pgrep -afx 'sleep 42'; do sleep 1; done") |
| 84 |
|
| 85 |
# there should only be the original page left |
| 86 |
showPagesAssertCount(1) |
| 87 |
|
| 88 |
|
| 89 |
if __name__ == '__main__': |
| 90 |
testlib.test_main() |