TT#56376 selenium: add test: create locked customer and unlock them

Common.pm:
- reworked arguments system. pbx tests require 'pbx' flag, creating locked
accounts requires 'locked' flag

controller_customer.t:
- edit functions to use this new flag system
- addting test to check in customer details if customer is locked. unlock
it afterwards

Change-Id: I02bfae8a9db6afbad4d5bb1b5a17cd8913c7ffa7
changes/01/31701/2
Nico Schedel 6 years ago
parent 007b1a4d98
commit 2237af73f3

@ -210,7 +210,7 @@ sub delete_rw_ruleset {
}
sub create_customer {
my($self, $customerid, $contactmail, $billingname, $pbx) = @_;
my($self, $customerid, $contactmail, $billingname, $special) = @_;
return unless $customerid && $contactmail && $billingname;
diag("Go to Customers page");
@ -227,9 +227,14 @@ sub create_customer {
$self->driver->find_element('#billing_profileidtable tr > td.dataTables_empty', 'css');
$self->driver->fill_element('#billing_profileidtable_filter input', 'css', $billingname);
$self->driver->select_if_unselected('//table[@id="billing_profileidtable"]/tbody/tr[1]/td//input[@type="checkbox"]');
if(index($special, 'locked') != -1) {
diag('Creating a locked customer');
$self->driver->scroll_to_element($self->driver->find_element('//*[@id="status"]'));
$self->driver->find_element('//*[@id="status"]/option[contains(text(), "locked")]')->click();
}
$self->driver->scroll_to_id('external_id');
$self->driver->fill_element('#external_id', 'css', $customerid);
if($pbx) {
if(index($special, 'pbx') != -1) {
diag("Creating customer for PBX testing");
$self->driver->select_if_unselected('//table[@id="productidtable"]/tbody/tr[1]/td[contains(text(),"Basic SIP Account")]/..//input[@type="checkbox"]');
}

@ -56,9 +56,9 @@ diag("Continuing creating a legit customer");
$d->find_element('//*[@id="mod_close"]')->click();
if($pbx == 1){
$c->create_customer($customerid, $contactmail, $billingname, 1);
$c->create_customer($customerid, $contactmail, $billingname, 'pbx locked');
} else {
$c->create_customer($customerid, $contactmail, $billingname);
$c->create_customer($customerid, $contactmail, $billingname, 'locked');
}
diag("Search for Customer");
@ -71,16 +71,26 @@ ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $resellername . '")]'), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[4]', $contactmail), 'Contact Email is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $billingname . '")]'), 'Billing Profile is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "locked")]'), 'Status is correct');
$custnum = $d->get_text('//*[@id="Customer_table"]//tr[1]//td[1]');
$compstring = "Customer #" . $custnum . " successfully created - Details";
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), $compstring, "Correct Alert was shown");
diag("Edit Customer");
diag("Check if Customer is locked");
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), 'Customer is locked', "Correct Alert was shown");
diag("Go back and edit Customer");
$d->find_element('Back', 'link_text')->click();
$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 ID is correct');
$d->move_and_click('//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Edit")]', 'xpath', '//*[@id="Customer_table_filter"]//input');
diag("Set status to 'locked'");
diag("Set status to 'active'");
$d->scroll_to_element($d->find_element('//*[@id="status"]'));
$d->find_element('//*[@id="status"]/option[contains(text(), "locked")]')->click();
$d->find_element('//*[@id="status"]/option[contains(text(), "active")]')->click();
$d->find_element('#save', 'css')->click();
diag("Search for Customer");
@ -88,9 +98,12 @@ $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);
diag("Check if status has changed for customer");
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "locked")]'), 'Status has changed');
$compstring = "Customer #" . $custnum . " successfully updated";
diag("Check customer details");
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $customerid . '")]'), 'Customer ID is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $resellername . '")]'), 'Reseller is correct');
ok($d->wait_for_text('//*[@id="Customer_table"]/tbody/tr[1]/td[4]', $contactmail), 'Contact Email is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "' . $billingname . '")]'), 'Billing Profile is correct');
ok($d->find_element_by_xpath('//*[@id="Customer_table"]/tbody/tr[1]/td[contains(text(), "active")]'), 'Status is correct');$compstring = "Customer #" . $custnum . " successfully updated";
is($d->get_text('//*[@id="content"]//div[contains(@class, "alert")]'), $compstring, "Correct Alert was shown");
diag("Open Details for our just created Customer");

Loading…
Cancel
Save