f1542d54db rewrote
the language selector dialog. Update the tests to also work with
cockpit ≥ 233.
Do the version comparison dynamically for the time being, as this breaks
several image refreshes. We can drop this again and only use the new
code once all of these landed.
61 lines
2.3 KiB
Python
Executable file
61 lines
2.3 KiB
Python
Executable file
#!/usr/bin/python3
|
|
# Run this with --help to see available options for tracing and debugging
|
|
# See https://github.com/cockpit-project/cockpit/blob/master/test/common/testlib.py
|
|
# "class Browser" and "class MachineCase" for the available API.
|
|
|
|
import os
|
|
import sys
|
|
|
|
# import Cockpit's machinery for test VMs and its browser test API
|
|
TEST_DIR = os.path.dirname(__file__)
|
|
sys.path.append(os.path.join(TEST_DIR, "common"))
|
|
sys.path.append(os.path.join(os.path.dirname(TEST_DIR), "bots/machine"))
|
|
import testlib
|
|
|
|
|
|
class TestApplication(testlib.MachineCase):
|
|
def testBasic(self):
|
|
b = self.browser
|
|
m = self.machine
|
|
|
|
self.login_and_go("/starter-kit")
|
|
# verify expected heading
|
|
b.wait_text(".pf-c-card__title", "Starter Kit")
|
|
|
|
# verify expected host name
|
|
hostname = m.execute("hostname").strip()
|
|
b.wait_in_text(".pf-c-alert__title", "Running on " + hostname)
|
|
|
|
# change current hostname
|
|
m.execute("echo new-%s > /etc/hostname" % hostname)
|
|
# verify new hostname name
|
|
b.wait_in_text(".pf-c-alert__title", "Running on new-" + hostname)
|
|
|
|
# change language to German
|
|
b.switch_to_top()
|
|
b.click("#navbar-dropdown")
|
|
b.click(".display-language-menu a")
|
|
b.wait_popup('display-language')
|
|
# the dialog changed in cockpit 233
|
|
cockpit_version = float(m.execute("cockpit-bridge --version | sed -n '/Version:/ s/^.*: //p'").strip())
|
|
if cockpit_version >= 233:
|
|
b.set_val("#display-language-modal select", "de-de")
|
|
b.click("#display-language-modal button.pf-m-primary")
|
|
else:
|
|
b.set_val("#display-language select", "de-de")
|
|
b.click("#display-language-select-button")
|
|
b.expect_load()
|
|
# HACK: work around language switching in Chrome not working in current session (Cockpit issue #8160)
|
|
b.reload(ignore_cache=True)
|
|
b.wait_present("#content")
|
|
# menu label (from manifest) should be translated
|
|
b.wait_text("#host-apps a[href='/starter-kit']", "Bausatz")
|
|
|
|
b.go("/starter-kit")
|
|
b.enter_page("/starter-kit")
|
|
# page label (from js) should be translated
|
|
b.wait_in_text(".pf-c-alert__title", "Läuft auf")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
testlib.test_main()
|