diff --git a/t/selenium/controller_billing.t b/t/selenium/controller_billing.t index 06b7835346..72c6c72ac3 100644 --- a/t/selenium/controller_billing.t +++ b/t/selenium/controller_billing.t @@ -16,6 +16,7 @@ my $c = Selenium::Collection::Common->new( my $billingname = ("billing" . int(rand(100000)) . "test"); my $resellername = ("reseller" . int(rand(100000)) . "test"); my $contractid = ("contract" . int(rand(100000)) . "test"); +my $billingnetwork = ("billing" . int(rand(100000)) . "network"); my $run_ok = 0; $c->login_ok(); @@ -219,6 +220,93 @@ diag("Check if Billing Profile has been removed"); $d->fill_element('#billing_profile_table_filter label input', 'css', $billingname); ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty', 'css'), 'Billing Profile has been removed'); +diag("Go to billing networks page"); +$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); +$d->find_element('Billing Networks', 'link_text')->click(); + +diag("Trying to create a empty billing network"); +$d->find_element('Create Billing Network', 'link_text')->click(); +$d->find_element('//*[@id="save"]')->click(); + +diag('Check if Errors show up'); +ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Billing Network Name field is required")]')); +ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Description field is required")]')); +ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Blocks field is required")]')); + +diag('Fill in values'); +$d->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#reselleridtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', $resellername); +ok($d->wait_for_text('//*[@id="reselleridtable"]/tbody/tr[1]/td[2]', $resellername), 'Reseller was found'); +$d->select_if_unselected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input'); +$d->fill_element('//*[@id="name"]', 'xpath', $billingnetwork); +$d->fill_element('//*[@id="description"]', 'xpath', 'Very nice description'); + +diag('Fill in invalid ip and subnet mask'); +$d->fill_element('//*[@id="blocks.0.row.ip"]', 'xpath', 'invalid'); +$d->fill_element('//*[@id="blocks.0.row.mask"]', 'xpath', 'ip'); +$d->find_element('//*[@id="save"]')->click(); + +diag('Check if Errors show up'); +ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Ip is no valid IPv4 or IPv6 address.")]')); +ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Value must be an integer")]')); +ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invalid IP address")]')); + +diag('Fill in valid ip and subnet mask'); +$d->fill_element('//*[@id="blocks.0.row.ip"]', 'xpath', '127.0.0.1'); +$d->fill_element('//*[@id="blocks.0.row.mask"]', 'xpath', '8'); +$d->find_element('//*[@id="save"]')->click(); + +diag('Search for Billing network'); +$d->fill_element('//*[@id="networks_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#networks_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('//*[@id="networks_table_filter"]/label/input', 'xpath', $billingnetwork); + +diag('Check Details'); +ok($d->wait_for_text('//*[@id="networks_table"]//tr[1]/td[2]', $resellername), "Reseller is correct"); +ok($d->wait_for_text('//*[@id="networks_table"]//tr[1]/td[3]', $billingnetwork), "Billing network name is correct"); +ok($d->find_element_by_xpath('//*[@id="networks_table"]//tr[1]/td[contains(text(), "127.0.0.1/8")]'), "Network Block is correct"); + +diag('Edit Billing Network'); +$billingnetwork = ("billing" . int(rand(100000)) . "network"); +$d->move_and_click('//*[@id="networks_table"]//tr[1]//td//a[contains(text(), "Edit")]', 'xpath', '//*[@id="networks_table_filter"]/label/input'); +$d->fill_element('//*[@id="name"]', 'xpath', $billingnetwork); +$d->fill_element('//*[@id="description"]', 'xpath', 'also good description'); + +diag('Add new billing network block'); +$d->find_element('//*[@id="blocks_add"]')->click(); +$d->fill_element('//*[@id="blocks.1.row.ip"]', 'xpath', '10.0.0.138'); +$d->fill_element('//*[@id="blocks.1.row.mask"]', 'xpath', '16'); +$d->find_element('//*[@id="save"]')->click(); + +diag('Search for Billing network'); +$d->fill_element('//*[@id="networks_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#networks_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('//*[@id="networks_table_filter"]/label/input', 'xpath', $billingnetwork); + +diag('Check Details'); +ok($d->wait_for_text('//*[@id="networks_table"]//tr[1]/td[2]', $resellername), "Reseller is correct"); +ok($d->wait_for_text('//*[@id="networks_table"]//tr[1]/td[3]', $billingnetwork), "Billing network name is correct"); +ok($d->find_element_by_xpath('//*[@id="networks_table"]//tr[1]/td[contains(text(), "127.0.0.1/8, 10.0.0.138/16")]'), "Network Block is correct"); + +diag('Try to NOT delete Billing Network'); +$d->move_and_click('//*[@id="networks_table"]//tr[1]//td//a[contains(text(), "Terminate")]', 'xpath', '//*[@id="networks_table_filter"]/label/input'); +$d->find_element('//*[@id="dataConfirmCancel"]')->click(); + +diag('Check if Billing Network is still here'); +$d->fill_element('//*[@id="networks_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); +ok($d->find_element_by_css('#networks_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); +$d->fill_element('//*[@id="networks_table_filter"]/label/input', 'xpath', $billingnetwork); +ok($d->wait_for_text('//*[@id="networks_table"]//tr[1]/td[3]', $billingnetwork), "Billing Network is still here"); + +diag('Try to delete Billing Network'); +$d->move_and_click('//*[@id="networks_table"]//tr[1]//td//a[contains(text(), "Terminate")]', 'xpath', '//*[@id="networks_table_filter"]/label/input'); +$d->find_element('//*[@id="dataConfirmOK"]')->click(); + +diag('Check if Billing Network has been deleted'); +$d->fill_element('//*[@id="networks_table_filter"]/label/input', 'xpath', $billingnetwork); +ok($d->find_element_by_css('#networks_table tr > td.dataTables_empty', 'css'), 'Billing network was deleted'); + $c->delete_reseller_contract($contractid); $c->delete_reseller($resellername);