PFE uses lit, so it makes sense to just use that for the main application as well. Web components are pretty much React built into the web platform, and lit adds some convenience around that. This is mostly a demo -- for real Cockpit pages, PF Elements is still missing too many components.
53 lines
2.1 KiB
Python
Executable file
53 lines
2.1 KiB
Python
Executable file
#!/usr/bin/python3 -cimport os, sys; os.execv(os.path.dirname(sys.argv[1]) + "/common/pywrap", sys.argv)
|
|
|
|
# Run this with --help to see available options for tracing and debugging
|
|
# See https://github.com/cockpit-project/cockpit/blob/main/test/common/testlib.py
|
|
# "class Browser" and "class MachineCase" for the available API.
|
|
|
|
import testlib
|
|
|
|
|
|
# Nondestructive tests all run in the same running VM. This allows them to run in Packit, Fedora, and
|
|
# RHEL dist-git gating. They must not permanently change any file or configuration on the system in a
|
|
# way that influences other tests.
|
|
@testlib.nondestructive
|
|
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-card [slot='header']", "Starter Kit")
|
|
|
|
# verify expected host name
|
|
hostname = m.execute("cat /etc/hostname").strip()
|
|
b.wait_in_text("pf-card .running-on", "Running on " + hostname)
|
|
|
|
# change current hostname
|
|
self.write_file("/etc/hostname", "new-" + hostname)
|
|
# verify new hostname name
|
|
b.wait_in_text("pf-card .running-on", "Running on new-" + hostname)
|
|
|
|
# change language to German
|
|
b.switch_to_top()
|
|
# the menu and dialog changed several times
|
|
b.click("#toggle-menu")
|
|
b.click("button.display-language-menu")
|
|
b.wait_popup('display-language-modal')
|
|
b.click("#display-language-modal [data-value='de-de'] button")
|
|
b.click("#display-language-modal button.pf-m-primary")
|
|
b.wait_visible("#content")
|
|
# menu label (from manifest) should be translated
|
|
b.wait_text("#host-apps a[href='/starter-kit']", "Bausatz")
|
|
# window title should be translated; this is not considered as "visible"
|
|
self.assertIn("Bausatz", b.call_js_func("ph_text", "head title"))
|
|
|
|
b.go("/starter-kit")
|
|
b.enter_page("/starter-kit")
|
|
# page label (from js) should be translated
|
|
b.wait_in_text("pf-card .running-on", "Läuft auf")
|
|
|
|
|
|
if __name__ == '__main__':
|
|
testlib.test_main()
|