TT#56376 selenium: add function create/delete_billing_profile()

Common.pm:
- add new functions create_billing_profile() and delete_billing_profile()
- it now allows to specify a custom reseller, which will be important for
later tests
- these will be used for more tests in controller_customer

controller_billing.t
- adjusted code to use these new functions

Change-Id: Ied8bf9e579d77228dc1bc6c3ad7b0cdc0edb321a
changes/32/30532/2
Nico Schedel 6 years ago
parent 45b34265de
commit 22ab442c06

@ -293,6 +293,47 @@ sub delete_contact {
};
}
sub create_billing_profile {
my($self, $billingname, $resellername) = @_;
return unless $billingname && $resellername;
diag("Go to Billing page");
$self->driver->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$self->driver->find_element('//a[contains(@href,"/domain")]');
$self->driver->find_element("Billing", 'link_text')->click();
diag("Create a billing profile");
$self->driver->find_element('Create Billing Profile', 'link_text')->click();
$self->driver->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', 'thisshouldnotexist');
ok($self->driver->find_element_by_css('#reselleridtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$self->driver->fill_element('//*[@id="reselleridtable_filter"]/label/input', 'xpath', $resellername);
ok($self->driver->wait_for_text('//*[@id="reselleridtable"]/tbody/tr[1]/td[2]', $resellername), 'Reseller was found');
$self->driver->select_if_unselected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input');
$self->driver->fill_element('#name', 'css', $billingname);
$self->driver->fill_element('[name=handle]', 'css', $billingname);
$self->driver->find_element('//select[@id="fraud_interval_lock"]/option[contains(text(),"foreign calls")]')->click();
$self->driver->find_element('//div[contains(@class,"modal")]//input[@type="submit"]')->click();
}
sub delete_billing_profile {
my($self, $billingname, $cancel) = @_;
return unless $billingname;
diag("Terminate our Billing Profile");
$self->driver->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$self->driver->find_element("Billing", 'link_text')->click();
$self->driver->fill_element('#billing_profile_table_filter label input', 'css', 'thisshouldnotexist');
ok($self->driver->find_element_by_css('#billing_profile_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$self->driver->fill_element('#billing_profile_table_filter label input', 'css', $billingname);
ok($self->driver->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
$self->driver->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Terminate")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
if($cancel){
popup_confirm_cancel($self, 'We are NOT going to terminate this billing profile');
} else {
popup_confirm_ok($self, 'We are going to terminate this billing profile');
};
}
sub popup_confirm_ok {
my($self, $message) = @_;

@ -15,22 +15,13 @@ sub ctr_billing {
);
my $billingname = ("billing" . int(rand(100000)) . "test");
my $resellername = ("reseller" . int(rand(100000)) . "test");
my $contractid = ("contract" . int(rand(100000)) . "test");
$c->login_ok();
diag("Go to Billing page");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element('//a[contains(@href,"/domain")]');
$d->find_element("Billing", 'link_text')->click();
diag("Create a billing profile");
$d->find_element('//*[@id="masthead"]//h2[contains(text(),"Billing Profiles")]')->click();
$d->find_element('Create Billing Profile', 'link_text')->click();
$d->find_element('//div[contains(@class,modal-body)]//table[@id="reselleridtable"]/tbody/tr[1]/td//input[@type="checkbox"]')->click();
$d->fill_element('#name', 'css', $billingname);
$d->fill_element('[name=handle]', 'css', $billingname);
$d->find_element('//select[@id="fraud_interval_lock"]/option[contains(text(),"foreign calls")]')->click();
$d->find_element('//div[contains(@class,"modal")]//input[@type="submit"]')->click();
$c->create_reseller_contract($contractid);
$c->create_reseller($resellername, $contractid);
$c->create_billing_profile($billingname, $resellername);
diag('Search for Test Profile in billing profile');
$d->fill_element('//*[@id="billing_profile_table_filter"]//input', 'xpath', 'thisshouldnotexist');
@ -39,7 +30,7 @@ sub ctr_billing {
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
diag('Check if other values are correct');
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[3]', 'default'), 'Correct reseller was found');
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[3]', $resellername), 'Correct reseller was found');
diag("Open edit dialog for Test Profile");
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Edit")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
@ -155,16 +146,7 @@ sub ctr_billing {
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
diag("Terminate our Billing Profile");
$d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click();
$d->find_element("Billing", 'link_text')->click();
$d->fill_element('#billing_profile_table_filter label input', 'css', 'thisshouldnotexist');
ok($d->find_element_by_css('#billing_profile_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');
$d->fill_element('#billing_profile_table_filter label input', 'css', $billingname);
ok($d->wait_for_text('//*[@id="billing_profile_table"]/tbody/tr/td[2]', $billingname), 'Billing profile was found');
$d->move_and_click('//*[@id="billing_profile_table"]/tbody/tr[1]//td//div//a[contains(text(), "Terminate")]', 'xpath', '//*[@id="billing_profile_table_filter"]//input');
ok($d->find_text("Are you sure?"), 'Delete dialog appears');
$d->find_element('#dataConfirmOK', 'css')->click();
$c->delete_billing_profile($billingname);
diag("Check if Billing Profile has been removed");
$d->fill_element('#billing_profile_table_filter label input', 'css', $billingname);

Loading…
Cancel
Save