#!/usr/bin/python3 # checkpoint: # 1. check default source # 2. add new source import composerlib import testlib @testlib.nondestructive class TestSource(composerlib.ComposerCase): def testBasic(self): b = self.browser m = self.machine # new repo info repo_url = "https://download.copr.fedorainfracloud.org/results" \ "/xiaofwan/sway-copr/fedora-31-x86_64" repo_name = "sway-copr" self.login_and_go("/composer", superuser=True) b.wait_present("#main") # open manage sources dialog drop_down_sel = ".toolbar-pf-action-right #dropdownKebab" b.click(drop_down_sel) b.wait_attr(drop_down_sel, "aria-expanded", "true") b.click("a:contains('Manage Sources')") b.wait_attr(drop_down_sel, "aria-expanded", "false") b.wait_present("#cmpsr-modal-manage-sources") # check default loaded sources sources = m.execute("composer-cli sources list").split() for source in sources: b.wait_present("div[data-source={}]".format(source)) # add new source b.click("input[value='Add Source']") # can't add srouce if type is empty b.set_input_text("#textInput1-modal-source", repo_name) b.set_input_text("#textInput2-modal-source", repo_url) b.wait_attr("button:contains('Add Source')", "disabled", "") b.click("button:contains('Cancel')") # new source b.click("input[value='Add Source']") b.set_input_text("#textInput1-modal-source", repo_name) b.set_input_text("#textInput2-modal-source", repo_url) # group actions for select from dropdown menu dropdown_menu_sel = "#textInput3-modal-source" b.wait_visible(dropdown_menu_sel) test_selector = "{} option[value='yum-baseurl']".format(dropdown_menu_sel) b.wait_present(test_selector) value_id = b.attr(test_selector, "value") b.set_val(dropdown_menu_sel, value_id) b.wait_val(dropdown_menu_sel, value_id) # groups action done b.click("button:contains('Add Source')") # HACK: workaround issue https://github.com/osbuild/cockpit-composer/issues/989 # open manage source again to continue running test if b.cdp.browser == "firefox": # open manage sources dialog b.wait_not_present("#cmpsr-modal-manage-sources") b.click(drop_down_sel) b.wait_attr(drop_down_sel, "aria-expanded", "true") b.click("a:contains('Manage Sources')") b.wait_attr(drop_down_sel, "aria-expanded", "false") b.wait_present("#cmpsr-modal-manage-sources") # endit new source to enable check SSL certificate and GPG key b.click("button[aria-label='Edit Source {}']".format(repo_name)) # SSL certificate b.click("#checkboxInput4-modal-source") # GPG key b.click("#checkboxInput5-modal-source") b.click("button:contains('Update Source')") # package from new added repo is here already b.click("button:contains('Close')") b.click("li[data-blueprint=openssh-server] a:contains('Edit Packages')") # wait for all available compontents visible with b.wait_timeout(300): b.wait_present("ul[data-list=inputs]") # search for kanshi which exists in added repo only b.set_input_text("#cmpsr-blueprint-input-filter", "kanshi") b.key_press("\r") with b.wait_timeout(120): b.wait_text("#kanshi-input", "kanshi") # new added reop works, go back # click back to blueprint link b.click("a:contains('Back to Blueprints')") # go to manage source b.click(drop_down_sel) b.wait_attr(drop_down_sel, "aria-expanded", "true") b.click("a:contains('Manage Sources')") b.wait_attr(drop_down_sel, "aria-expanded", "false") b.wait_present("#cmpsr-modal-manage-sources") # duplicated source can't be added b.click("input[value='Add Source']") b.set_input_text("#textInput2-modal-source", repo_url) b.wait_text("#textInput2-modal-source-help", "This source path already exists.") b.click("button:contains('Cancel')") # delete added source delete_drop_down_sel = "button[aria-label='Source Actions {}']".format(repo_name) b.click(delete_drop_down_sel) b.wait_attr(delete_drop_down_sel, "aria-expanded", "true") b.click("a:contains('Remove Source')") b.wait_not_present("div[data-source={}]".format(repo_name)) # close manage source dialog b.click("#cmpsr-modal-manage-sources .close") b.wait_not_present("#cmpsr-modal-manage-sources") # collect code coverage result self.check_coverage() if __name__ == '__main__': testlib.test_main()