From 33b96031ca5f0334b515b45ec4aa98f7ee1c3c81 Mon Sep 17 00:00:00 2001 From: Nico Schedel Date: Wed, 25 Sep 2019 12:46:50 +0200 Subject: [PATCH] TT#56376 selenium: add file controller_terminate.t Termination tests are now in a seperate file, since integrating them in already existing files was messy at best. controller_terminate.t was added to the experimental test plan and can also be manually executed Change-Id: I58a83ae1fb525f481294d74acac33fa193ee0b96 --- t/selenium/controller_customer.t | 101 +++++------ t/selenium/controller_reseller.t | 61 ------- t/selenium/controller_subscriber.t | 75 +------- t/selenium/controller_terminate.t | 267 +++++++++++++++++++++++++++++ t/selenium/runner.t | 5 + 5 files changed, 325 insertions(+), 184 deletions(-) create mode 100644 t/selenium/controller_terminate.t diff --git a/t/selenium/controller_customer.t b/t/selenium/controller_customer.t index ff157916f6..af7fa22afb 100644 --- a/t/selenium/controller_customer.t +++ b/t/selenium/controller_customer.t @@ -367,69 +367,70 @@ $d->fill_element('//*[@id="Customer_table_filter"]/label/input', 'xpath', $custo ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Customer was deleted'); $c->delete_contact($contactmail); +$c->delete_reseller_contract($contractid); +$c->delete_reseller($resellername); -diag('Create a new Contact for termination testing'); -$contactmail = ("contact" . int(rand(100000)) . '@test.org'); -$c->create_contact($contactmail, $resellername); +diag('Create default Reseller + Contract'); +$d->find_element('//*[@id="content"]//div//form//button[contains(text(), "Create Reseller with default values")]')->click(); +ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details for")]'), "We are on the correct page"); +diag('Get Reseller Name'); +if($d->find_element_by_xpath('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]/../../../div')->get_attribute('class', 1) eq 'accordion-group') { + $d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]')->click(); +} +$resellername = $d->get_text('//*[@id="Reseller_table"]/tbody/tr/td[2]'); +my $temp = substr($resellername, 8); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully created with login Default" . $temp . " and password defaultresellerpassword, please review your settings below", "Correct Alert was shown"); + +diag('Add unique name to Contract'); +$contractid = ("contract" . int(rand(100000)) . "term"); +$d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Contract")]')->click(); +$d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Contract")]')->click(); +$d->move_and_click('//*[@id="Contract_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details")]'); +$d->fill_element('//*[@id="external_id"]', 'xpath', $contractid); +$d->find_element('//*[@id="save"]')->click(); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contract successfully changed!", "Correct Alert was shown"); -diag('Create a new customer for termination testing'); -$c->create_customer($customerid, $contactmail, $billingname); +diag("Go to Reseller Contracts"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element('Reseller and Peering Contracts', 'link_text')->click(); -diag("Search for Customer"); -$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); -ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Garbage test not found'); -$d->fill_element('#Customer_table_filter input', 'css', $customerid); -ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $customerid . '")]'), 'Customer found'); -$custnum = $d->get_text('//*[@id="Customer_table"]//tr[1]//td[1]'); -$compstring = "Customer #" . $custnum . " successfully created - Details"; -is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), $compstring, "Correct Alert was shown"); +diag("Search for Reseller Contract"); +$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid); +ok($d->wait_for_text('//*[@id="contract_table"]/tbody/tr[1]/td[2]', $contractid), 'Reseller contract found'); -diag('Edit customer status to terminated'); -$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Customer_table_filter"]//input'); +diag("Terminate Reseller Contract"); +$d->move_and_click('//*[@id="contract_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="contract_table_filter"]/label/input'); $d->scroll_to_element($d->find_element('//*[@id="status"]')); $d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); -$d->find_element('#save', 'css')->click(); +$d->find_element('//*[@id="save"]')->click(); -diag('Check if customer was deleted'); -$compstring = "Customer #" . $custnum . " successfully updated"; -is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), $compstring, "Correct Alert was shown"); -$d->fill_element('//*[@id="Customer_table_filter"]/label/input', 'xpath', $customerid); -ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Customer was deleted'); +diag("Check if Reseller Contract was terminated"); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contract successfully changed!", "Correct Alert was shown"); +$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid); +ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Reseller Contract was terminated'); -diag('Go to Contacts page'); +diag("Go to Reseller"); $d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); -$d->find_element("Contacts", 'link_text')->click(); - -diag('Search for Contact'); -$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); -ok($d->find_element_by_css('#contact_table tr > td.dataTables_empty', 'css'), 'Garbage test not found'); -$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', $contactmail); -ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "' . $contactmail . '")]'), 'Contact found'); - -diag('Check if Editing Contact works'); -$d->move_and_click('//*[@id="contact_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="contact_table_filter"]//input'); -ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Contact")]'), "'Edit Contact' window has been opened"); -$d->fill_element('//*[@id="firstname"]', 'xpath', 'TestContactAndStuff'); -$d->find_element('//*[@id="save"]')->click(); +$d->find_element('Resellers', 'link_text')->click(); -diag('Check if Contact was edited'); -$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); -ok($d->find_element_by_css('#contact_table tr > td.dataTables_empty', 'css'), 'Garbage test not found'); -$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', $contactmail); -ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "' . $contactmail . '")]'), 'Contact found'); -ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "TestContactAndStuff")]'), 'Name was edited'); +diag("Search reseller"); +$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist'); +ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); +ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct'); -diag('Delete Contact'); -$d->move_and_click('//*[@id="contact_table"]/tbody/tr[1]//td//div//a[contains(text(),"Delete")]', 'xpath', '//*[@id="contact_table_filter"]//input'); -$d->find_element('//*[@id="dataConfirmOK"]')->click(); +diag("Terminate Reseller"); +$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Resellers_table_filter"]//input'); +$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); +$d->find_element('//*[@id="save"]')->click(); -diag('Check if Contact has been deleted'); -is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contact successfully terminated", "Correct Alert was shown"); -$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', $contactmail); -ok($d->find_element_by_css('#contact_table tr > td.dataTables_empty', 'css'), 'Contact has been deleted'); +diag("Check if Reseller was terminated"); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully updated", "Correct Alert was shown"); +$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); +ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Reseller was deleted'); -$c->delete_reseller_contract($contractid); -$c->delete_reseller($resellername); $c->delete_billing_profile($billingname); diag("This test run was successfull"); diff --git a/t/selenium/controller_reseller.t b/t/selenium/controller_reseller.t index c7995c9977..0bef0d816e 100644 --- a/t/selenium/controller_reseller.t +++ b/t/selenium/controller_reseller.t @@ -241,67 +241,6 @@ is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Suc $d->fill_element('//*[@id="Resellers_table_filter"]/label/input', 'xpath', $resellername); ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty'), 'Reseller was deleted'); -diag('Create default Reseller + Contract for termination testing'); -$d->find_element('//*[@id="content"]//div//form//button[contains(text(), "Create Reseller with default values")]')->click(); -ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details for")]'), "We are on the correct page"); -diag('Get Reseller Name'); -if($d->find_element_by_xpath('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]/../../../div')->get_attribute('class', 1) eq 'accordion-group') { - $d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]')->click(); -} -$resellername = $d->get_text('//*[@id="Reseller_table"]/tbody/tr/td[2]'); -my $temp = substr($resellername, 8); -is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully created with login Default" . $temp . " and password defaultresellerpassword, please review your settings below", "Correct Alert was shown"); - -diag('Add unique name to Contract'); -$contractid = ("contract" . int(rand(100000)) . "term"); -$d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Contract")]')->click(); -$d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Contract")]')->click(); -$d->move_and_click('//*[@id="Contract_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details")]'); -$d->fill_element('//*[@id="external_id"]', 'xpath', $contractid); -$d->find_element('//*[@id="save"]')->click(); -is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contract successfully changed!", "Correct Alert was shown"); - -diag("Go to Reseller Contracts"); -$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); -$d->find_element('Reseller and Peering Contracts', 'link_text')->click(); - -diag("Search for Reseller Contract"); -$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); -ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); -$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid); -ok($d->wait_for_text('//*[@id="contract_table"]/tbody/tr[1]/td[2]', $contractid), 'Reseller contract found'); - -diag("Terminate Reseller Contract"); -$d->move_and_click('//*[@id="contract_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="contract_table_filter"]/label/input'); -$d->scroll_to_element($d->find_element('//*[@id="status"]')); -$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); -$d->find_element('//*[@id="save"]')->click(); - -diag("Check if Reseller Contract was terminated"); -is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contract successfully changed!", "Correct Alert was shown"); -$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid); -ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Reseller Contract was terminated'); - -diag("Go to Reseller"); -$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); -$d->find_element('Resellers', 'link_text')->click(); - -diag("Search reseller"); -$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist'); -ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); -$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); -ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct'); - -diag("Terminate Reseller"); -$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Resellers_table_filter"]//input'); -$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); -$d->find_element('//*[@id="save"]')->click(); - -diag("Check if Reseller was terminated"); -is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully updated", "Correct Alert was shown"); -$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); -ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Reseller was deleted'); - diag("This test run was successfull"); $run_ok = 1; diff --git a/t/selenium/controller_subscriber.t b/t/selenium/controller_subscriber.t index 6285fd098d..70530cdc4a 100644 --- a/t/selenium/controller_subscriber.t +++ b/t/selenium/controller_subscriber.t @@ -199,6 +199,7 @@ ok($d->find_element_by_xpath('//*[@id="subscribers_table"]//tr//td[contains(text diag('Unlock Subscriber'); $d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Data")]')->click(); +$d->scroll_to_element($d->find_element("Edit", 'link_text')); $d->find_element("Edit", 'link_text')->click(); $d->find_element('//*[@id="lock"]')->click(); $d->find_element('//*[@id="lock"]/option[contains(text(), "none")]')->click(); @@ -407,79 +408,7 @@ is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Sub $d->fill_element('//*[@id="subscriber_profile_sets_table_filter"]/label/input', 'xpath', $setname); ok($d->find_element_by_css('#subscriber_profile_sets_table tr > td.dataTables_empty'), 'Table is empty'); -diag("Go to Customers page"); -$d->find_element('//*[@id="content"]//div//a[contains(text(), "Back")]')->click(); -$d->scroll_to_element($d->find_element('//*[@id="main-nav"]')); -$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); -$d->find_element("Customers", 'link_text')->click(); - -diag('Create Subscriber for Termination Test'); -$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); -ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Garbage test not found'); -$d->fill_element('#Customer_table_filter input', 'css', $customerid); -ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Customer found'); -$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input'); -$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')->click(); -$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')); -$d->find_element('Create Subscriber', 'link_text')->click(); -$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist'); -ok($d->find_element_by_css('#domainidtable tr > td.dataTables_empty'), 'Table is empty'); -$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', $domainstring); -ok($d->wait_for_text('//*[@id="domainidtable"]/tbody/tr[1]/td[3]', $domainstring), 'Domain found'); -$d->select_if_unselected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input'); -$d->find_element('//*[@id="username"]')->send_keys($username); -$d->find_element('//*[@id="password"]')->send_keys('testing1234'); -$d->find_element('//*[@id="save"]')->click(); - -diag('Go to Subscribers page'); -$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); -$d->find_element("Subscribers", 'link_text')->click(); - -diag('Terminate Subscriber'); -$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); -ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty'); -$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username); -ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber was found'); -$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Details")]', 'xpath', '//*[@id="subscriber_table_filter"]//input'); -$d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Data")]')->click(); -$d->find_element('//*[@id="collapse_master"]/div/a[contains(text(), "Edit")]')->click(); -$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); -$d->find_element('//*[@id="save"]')->click(); -ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")][contains(text(), "Subscriber does not exist")]'), "Correct Alert was shown"); - -diag('Check if Subscriber was deleted'); -$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username); -ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Subscriber was deleted'); - -diag('Go to Customers Page'); -$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); -$d->find_element("Customers", 'link_text')->click(); - -diag('Check if Customer can be edited'); -$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); -ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty'), 'Garbage text was not found'); -$d->fill_element('#Customer_table_filter input', 'css', $customerid); -ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Found customer'); -$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Customer_table_filter"]/label/input'); -ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Customer")]'), "Edit Dialog has been opened"); -$d->find_element('//*[@id="status"]/option[@value="locked"]')->click(); -$d->find_element('//*[@id="save"]')->click(); - -diag('Check if Customer was edited'); -$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); -ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty'), 'Garbage text was not found'); -$d->fill_element('#Customer_table_filter input', 'css', $customerid); -ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Found customer'); -ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[8]', 'locked'), 'Status was changed'); - -diag('Delete Customer'); -$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Terminate")]', 'xpath', '//*[@id="Customer_table_filter"]/label/input'); -$d->find_element('//*[@id="dataConfirmOK"]')->click(); - -diag('Check if Customer was deleted'); -$d->fill_element('#Customer_table_filter input', 'css', $customerid); -ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty'), 'Customer was deleted'); - +$c->delete_customer($customerid); $c->delete_reseller_contract($contractid); $c->delete_reseller($resellername); $c->delete_contact($contactmail); diff --git a/t/selenium/controller_terminate.t b/t/selenium/controller_terminate.t new file mode 100644 index 0000000000..0faed64a6b --- /dev/null +++ b/t/selenium/controller_terminate.t @@ -0,0 +1,267 @@ +use warnings; +use strict; + +use lib 't/lib'; +use Test::More import => [qw(done_testing is ok diag todo_skip)]; +use Selenium::Remote::Driver::FirefoxExtensions; +use Selenium::Collection::Common; +use Selenium::Collection::Functions; + +my ($port) = @_; +my $d = Selenium::Collection::Functions::create_driver($port); +my $c = Selenium::Collection::Common->new( + driver => $d +); + +my $customerid = ("id" . int(rand(100000)) . "ok"); +my $resellername = ("reseller" . int(rand(100000)) . "test"); +my $contractid = ("contract" . int(rand(100000)) . "test"); +my $contactmail = ("contact" . int(rand(100000)) . '@test.org'); +my $billingname = ("billing" . int(rand(100000)) . "test"); +my $domainstring = ("domain" . int(rand(100000)) . ".example.org"); +my $username = ("demo" . int(rand(10000)) . "name"); +my $run_ok = 0; +my $custnum; +my $compstring; + +$c->login_ok(); +$c->create_domain($domainstring); +$c->create_reseller_contract($contractid); +$c->create_reseller($resellername, $contractid); +$c->create_contact($contactmail, $resellername); +$c->create_billing_profile($billingname, $resellername); +$c->create_customer($customerid, $contactmail, $billingname); + +diag("Go to Customers page"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element("Customers", 'link_text')->click(); + +diag('Create Subscriber for Termination Test'); +$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); +ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Garbage test not found'); +$d->fill_element('#Customer_table_filter input', 'css', $customerid); +ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Customer found'); +$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input'); +$d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')->click(); +$d->scroll_to_element($d->find_element('//*[@id="customer_details"]//div//a[contains(text(), "Subscribers")]')); +$d->find_element('Create Subscriber', 'link_text')->click(); +$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#domainidtable tr > td.dataTables_empty'), 'Table is empty'); +$d->fill_element('//*[@id="domainidtable_filter"]/label/input', 'xpath', $domainstring); +ok($d->wait_for_text('//*[@id="domainidtable"]/tbody/tr[1]/td[3]', $domainstring), 'Domain found'); +$d->select_if_unselected('//*[@id="domainidtable"]/tbody/tr[1]/td[4]/input'); +$d->find_element('//*[@id="username"]')->send_keys($username); +$d->find_element('//*[@id="password"]')->send_keys('testing1234'); +$d->find_element('//*[@id="save"]')->click(); + +diag('Go to Subscribers page'); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Subscriber successfully created", "Correct Alert was shown"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element("Subscribers", 'link_text')->click(); + +diag('Terminate Subscriber'); +$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Table is empty'); +$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username); +ok($d->wait_for_text('//*[@id="subscriber_table"]/tbody/tr/td[4]', $username), 'Subscriber was found'); +$d->move_and_click('//*[@id="subscriber_table"]/tbody/tr[1]/td/div/a[contains(text(), "Details")]', 'xpath', '//*[@id="subscriber_table_filter"]//input'); +$d->find_element('//*[@id="subscriber_data"]//div//a[contains(text(), "Master Data")]')->click(); +$d->find_element('//*[@id="collapse_master"]/div/a[contains(text(), "Edit")]')->click(); +$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); +$d->find_element('//*[@id="save"]')->click(); +ok($d->find_element_by_xpath('//*[@id="content"]//div[contains(@class, "alert")][contains(text(), "Subscriber does not exist")]'), "Correct Alert was shown"); + +diag('Check if Subscriber was terminated'); +$d->fill_element('//*[@id="subscriber_table_filter"]/label/input', 'xpath', $username); +ok($d->find_element_by_css('#subscriber_table tr > td.dataTables_empty'), 'Subscriber was deleted'); + +diag('Go to Customers Page'); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element("Customers", 'link_text')->click(); + +diag('Check if Customer can be edited'); +$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); +ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty'), 'Garbage text was not found'); +$d->fill_element('#Customer_table_filter input', 'css', $customerid); +ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Found customer'); +$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Customer_table_filter"]/label/input'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Customer")]'), "Edit Dialog has been opened"); +$d->find_element('//*[@id="status"]/option[@value="locked"]')->click(); +$d->find_element('//*[@id="save"]')->click(); + +diag('Check if Customer was edited'); +$d->fill_element('#Customer_table_filter input', 'css', 'thisshouldnotexist'); +ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty'), 'Garbage text was not found'); +$d->fill_element('#Customer_table_filter input', 'css', $customerid); +ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[2]', $customerid), 'Found customer'); +ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[8]', 'locked'), 'Status was changed'); +$custnum = $d->get_text('//*[@id="Customer_table"]//tr[1]//td[1]'); +$compstring = "Customer #" . $custnum . " successfully updated"; +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), $compstring, "Correct Alert was shown"); + +diag('Edit customer status to terminated'); +$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Customer_table_filter"]//input'); +$d->scroll_to_element($d->find_element('//*[@id="status"]')); +$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); +$d->find_element('#save', 'css')->click(); + +diag('Check if customer was terminated'); +$compstring = "Customer #" . $custnum . " successfully updated"; +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), $compstring, "Correct Alert was shown"); +$d->fill_element('//*[@id="Customer_table_filter"]/label/input', 'xpath', $customerid); +ok($d->find_element_by_css('#Customer_table tr > td.dataTables_empty', 'css'), 'Customer was terminated'); + +diag('Go to Contacts page'); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element("Contacts", 'link_text')->click(); + +diag('Search for Contact'); +$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#contact_table tr > td.dataTables_empty', 'css'), 'Garbage test not found'); +$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', $contactmail); +ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "' . $contactmail . '")]'), 'Contact found'); + +diag('Check if Editing Contact works'); +$d->move_and_click('//*[@id="contact_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="contact_table_filter"]//input'); +ok($d->find_element_by_xpath('//*[@id="mod_edit"]/div/h3[contains(text(), "Edit Contact")]'), "'Edit Contact' window has been opened"); +$d->fill_element('//*[@id="firstname"]', 'xpath', 'TestFistName'); +$d->fill_element('//*[@id="lastname"]', 'xpath', 'TestLastName'); +$d->fill_element('//*[@id="company"]', 'xpath', 'TestCompany'); +$d->find_element('//*[@id="save"]')->click(); + +diag('Check if Contact was edited'); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contact successfully changed", "Correct Alert was shown"); +$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#contact_table tr > td.dataTables_empty', 'css'), 'Garbage test not found'); +$d->fill_element('//*[@id="contact_table_filter"]/label/input', 'xpath', $contactmail); +ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "' . $contactmail . '")]'), 'Contact found'); +ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "TestFistName")]'), 'First Name was edited'); +ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "TestLastName")]'), 'Last Name was edited'); +ok($d->find_element_by_xpath('//*[@id="contact_table"]/tbody/tr[1]/td[contains(text(), "TestCompany")]'), 'Company was edited'); + +$c->delete_contact($contactmail); +$c->delete_reseller_contract($contractid); +$c->delete_reseller($resellername); + +diag('Create default Reseller + Contract for termination testing'); +$d->find_element('//*[@id="content"]//div//form//button[contains(text(), "Create Reseller with default values")]')->click(); +ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details for")]'), "We are on the correct page"); +diag('Get Reseller Name'); +if($d->find_element_by_xpath('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]/../../../div')->get_attribute('class', 1) eq 'accordion-group') { + $d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]')->click(); +} +$resellername = $d->get_text('//*[@id="Reseller_table"]/tbody/tr/td[2]'); +my $temp = substr($resellername, 8); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully created with login Default" . $temp . " and password defaultresellerpassword, please review your settings below", "Correct Alert was shown"); + +diag('Add unique name to Contract'); +$contractid = ("contract" . int(rand(100000)) . "term"); +sleep 1; +$d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Contract")]')->click(); +$d->move_and_click('//*[@id="Contract_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details")]'); +$d->fill_element('//*[@id="external_id"]', 'xpath', $contractid); +$d->find_element('//*[@id="save"]')->click(); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contract successfully changed!", "Correct Alert was shown"); + +diag("Go to Reseller Contracts"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element('Reseller and Peering Contracts', 'link_text')->click(); + +diag("Search for Reseller Contract"); +$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid); +ok($d->wait_for_text('//*[@id="contract_table"]/tbody/tr[1]/td[2]', $contractid), 'Reseller contract found'); + +diag("Terminate Reseller Contract"); +$d->move_and_click('//*[@id="contract_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="contract_table_filter"]/label/input'); +$d->scroll_to_element($d->find_element('//*[@id="status"]')); +$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); +$d->find_element('//*[@id="save"]')->click(); + +diag("Check if Reseller Contract was terminated"); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contract successfully changed!", "Correct Alert was shown"); +$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid); +ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Reseller Contract was terminated'); + +diag("Go to Reseller"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element('Resellers', 'link_text')->click(); + +diag("Search reseller"); +$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist'); +ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); +ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct'); + +diag("Terminate Reseller"); +$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Resellers_table_filter"]//input'); +$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); +$d->find_element('//*[@id="save"]')->click(); + +diag("Check if Reseller was terminated"); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully updated", "Correct Alert was shown"); +$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); +ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Reseller was deleted'); + +diag('Create default Reseller + Contract for termination testing'); +$d->find_element('//*[@id="content"]//div//form//button[contains(text(), "Create Reseller with default values")]')->click(); +ok($d->find_element_by_xpath('//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details for")]'), "We are on the correct page"); +diag('Get Reseller Name'); +if($d->find_element_by_xpath('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]/../../../div')->get_attribute('class', 1) eq 'accordion-group') { + $d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Base Information")]')->click(); +} +$resellername = $d->get_text('//*[@id="Reseller_table"]/tbody/tr/td[2]'); +$temp = substr($resellername, 8); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully created with login Default" . $temp . " and password defaultresellerpassword, please review your settings below", "Correct Alert was shown"); + +diag('Add unique name to Contract'); +$contractid = ("contract" . int(rand(100000)) . "term"); +sleep 1; +$d->find_element('//*[@id="reseller_details"]//div//a[contains(text(), "Reseller Contract")]')->click(); +$d->move_and_click('//*[@id="Contract_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="masthead"]//div//h2[contains(text(), "Reseller Details")]'); +$d->fill_element('//*[@id="external_id"]', 'xpath', $contractid); +$d->find_element('//*[@id="save"]')->click(); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Contract successfully changed!", "Correct Alert was shown"); + +diag("Go to Reseller"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element('Resellers', 'link_text')->click(); + +diag("Search reseller"); +$d->fill_element('#Resellers_table_filter label input', 'css', 'thisshouldnotexist'); +ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); +ok($d->wait_for_text('//*[@id="Resellers_table"]/tbody/tr[1]/td[3]', $resellername), 'Reseller Name is correct'); + +diag("Terminate Reseller"); +$d->move_and_click('//*[@id="Resellers_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Resellers_table_filter"]//input'); +$d->find_element('//*[@id="status"]/option[@value="terminated"]')->click(); +$d->find_element('//*[@id="save"]')->click(); + +diag("Check if Reseller was terminated"); +is($d->get_text_safe('//*[@id="content"]//div[contains(@class, "alert")]'), "Reseller successfully updated", "Correct Alert was shown"); +$d->fill_element('#Resellers_table_filter label input', 'css', $resellername); +ok($d->find_element_by_css('#Resellers_table tr > td.dataTables_empty', 'css'), 'Reseller was deleted'); + +diag("Go to Reseller Contracts"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element('Reseller and Peering Contracts', 'link_text')->click(); + +diag("Check if Reseller Contract was terminated"); +$d->fill_element('//*[@id="contract_table_filter"]/label/input', 'xpath', $contractid); +ok($d->find_element_by_css('#contract_table tr > td.dataTables_empty', 'css'), 'Reseller Contract was terminated'); + +$c->delete_billing_profile($billingname); +$c->delete_domain($domainstring); + +diag("This test run was successfull"); +$run_ok = 1; + +END { + if(!$run_ok) { + $c->crash_handler("/results/crash_terminate.png"); + } + $d->quit(); + done_testing; +} \ No newline at end of file diff --git a/t/selenium/runner.t b/t/selenium/runner.t index 147360afc3..d137e0351e 100644 --- a/t/selenium/runner.t +++ b/t/selenium/runner.t @@ -60,6 +60,7 @@ if($testplan eq $dir . 'runner.t') { $dir . 'controller_rw_ruleset.t', $dir . 'controller_soundset.t', $dir . 'controller_subscriber.t', + $dir . 'controller_terminate.t', $dir . 'controller_timeset.t', ); @@ -128,6 +129,10 @@ if($testplan eq $dir . 'runner.t') { $string = $dir . 'controller_subscriber.t'; push @tests, $string; }; + if (index($testplan, $dir . 'controller_terminate.t') != -1 || index($testplan, $dir . 'terminate') != -1) { + $string = $dir . 'controller_terminate.t'; + push @tests, $string; + }; if (index($testplan, $dir . 'controller_timeset.t') != -1 || index($testplan, $dir . 'timeset') != -1) { $string = $dir . 'controller_timeset.t'; push @tests, $string;