#!/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

        m.execute("zypper --non-interactive addrepo https://test/ test-repo")
        self.login_and_go("/cockpit-repos")
        # verify expected heading
        b.wait_text(".pf-v6-c-card__title", "Software Repositories")

        # verify expected host name
        b.wait_in_text("#repos-list", "test-repo")

        # delete test-repo
        b.click(".pf-v6-c-table__tbody:nth-of-type(8) .pf-v6-c-table__action button")
        b.click("button:contains('Delete repo')")
        b.click(".pf-v6-c-modal-box button:contains('Delete')")

        b.wait_not_present(".pf-v6-c-table__tbody:nth-of-type(8)")


if __name__ == '__main__':
    testlib.test_main()
