@ -34,6 +34,25 @@ sub ctr_customer {
$ c - > create_contact ( $ contactmail , $ resellername ) ;
$ c - > create_billing_profile ( $ billingname , $ resellername ) ;
diag ( "Go to Customers page" ) ;
$ d - > find_element ( '//*[@id="main-nav"]//*[contains(text(),"Settings")]' ) - > click ( ) ;
$ d - > find_element ( "Customers" , 'link_text' ) - > click ( ) ;
diag ( "Trying to create a empty Customer" ) ;
$ d - > find_element ( 'Create Customer' , 'link_text' ) - > click ( ) ;
$ d - > scroll_to_element ( $ d - > find_element ( '//table[@id="contactidtable"]/tbody/tr[1]/td//input[@type="checkbox"]' ) ) ;
$ d - > unselect_if_selected ( '//table[@id="contactidtable"]/tbody/tr[1]/td//input[@type="checkbox"]' ) ;
$ d - > scroll_to_element ( $ d - > find_element ( '//table[@id="billing_profileidtable"]/tbody/tr[1]/td//input[@type="checkbox"]' ) ) ;
$ d - > unselect_if_selected ( '//table[@id="billing_profileidtable"]/tbody/tr[1]/td//input[@type="checkbox"]' ) ;
$ d - > find_element ( '#save' , 'css' ) - > click ( ) ;
diag ( "Check if error messages appear" ) ;
ok ( $ d - > find_element_by_xpath ( '//form//div//span[contains(text(), "Contact field is required")]' ) ) ;
ok ( $ d - > find_element_by_xpath ( '//form//div//span[contains(text(), "Invalid \'billing_profile_id\', not defined.")]' ) ) ;
diag ( "Continuing creating a legit customer" ) ;
$ d - > find_element ( '//*[@id="mod_close"]' ) - > click ( ) ;
if ( $ pbx == 1 ) {
$ c - > create_customer ( $ customerid , $ contactmail , $ billingname , 1 ) ;
} else {
@ -51,6 +70,17 @@ sub ctr_customer {
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' ) ;
diag ( "Edit Customer" ) ;
$ 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'" ) ;
$ d - > scroll_to_element ( $ d - > find_element ( '//*[@id="status"]' ) ) ;
$ d - > find_element ( '//*[@id="status"]/option[contains(text(), "locked")]' ) - > click ( ) ;
$ d - > find_element ( '#save' , 'css' ) - > click ( ) ;
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' ) ;
diag ( "Open Details for our just created Customer" ) ;
$ d - > move_and_click ( '//*[@id="Customer_table"]/tbody/tr[1]//td//div//a[contains(text(),"Details")]' , 'xpath' , '//*[@id="Customer_table_filter"]//input' ) ;
@ -92,7 +122,16 @@ sub ctr_customer {
diag ( "Create a new Phonebook entry" ) ;
$ d - > find_element ( '//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]' ) - > click ( ) ;
$ d - > scroll_to_element ( $ d - > find_element ( '//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]' ) ) ;
diag ( "Trying to create a empty Phonebook entry" ) ;
$ d - > find_element ( "Create Phonebook Entry" , 'link_text' ) - > click ( ) ;
$ d - > find_element ( '//*[@id="save"]' ) - > click ( ) ;
diag ( "Check if error messages appear" ) ;
ok ( $ d - > find_element_by_xpath ( '//form//div//span[contains(text(), "Name field is required")]' ) ) ;
ok ( $ d - > find_element_by_xpath ( '//form//div//span[contains(text(), "Number field is required")]' ) ) ;
diag ( "Enter Information" ) ;
$ d - > fill_element ( '//*[@id="name"]' , 'xpath' , 'Tester' ) ;
$ d - > fill_element ( '//*[@id="number"]' , 'xpath' , '0123456789' ) ;
$ d - > find_element ( '//*[@id="save"]' ) - > click ( ) ;
@ -108,11 +147,36 @@ sub ctr_customer {
ok ( $ d - > find_element_by_xpath ( '//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "Tester")]' ) , "Name is correct" ) ;
ok ( $ d - > find_element_by_xpath ( '//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "0123456789")]' ) , "Number is correct" ) ;
diag ( "Edit Phonebook entry" ) ;
$ d - > move_and_click ( '//*[@id="phonebook_table"]//tr[1]//td//a[contains(text(), "Edit")]' , 'xpath' , '//*[@id="customer_details"]//div//a[contains(text(), "Phonebook")]' ) ;
diag ( "Change Information" ) ;
$ d - > fill_element ( '//*[@id="name"]' , 'xpath' , 'TesterTester' ) ;
$ d - > fill_element ( '//*[@id="number"]' , 'xpath' , '987654321' ) ;
$ d - > find_element ( '//*[@id="save"]' ) - > click ( ) ;
diag ( "Check if information has changed" ) ;
$ d - > find_element ( '//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]' ) - > click ( ) ;
$ d - > scroll_to_element ( $ d - > find_element ( '//*[@id="customer_details"]//div//a[contains(text(),"Phonebook")]' ) ) ;
$ d - > fill_element ( '//*[@id="phonebook_table_filter"]/label/input' , 'xpath' , 'thisshouldnotexist' ) ;
ok ( $ d - > find_element_by_css ( '#phonebook_table tr > td.dataTables_empty' , 'css' ) , 'Garbage text was not found' ) ;
$ d - > fill_element ( '//*[@id="phonebook_table_filter"]/label/input' , 'xpath' , 'TesterTester' ) ;
ok ( $ d - > find_element_by_xpath ( '//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "TesterTester")]' ) , "Name is correct" ) ;
ok ( $ d - > find_element_by_xpath ( '//*[@id="phonebook_table"]/tbody/tr[1]/td[contains(text(), "987654321")]' ) , "Number is correct" ) ;
diag ( "Create a new Location" ) ;
$ d - > find_element ( '//*[@id="customer_details"]//div//a[contains(text(), "Locations")]' ) - > click ( ) ;
$ d - > find_element ( "Create Location" , 'link_text' ) - > click ( ) ;
diag ( 'Enter necessary information' ) ;
diag ( "Trying to create a empty Location" ) ;
$ d - > find_element ( '//*[@id="save"]' ) - > click ( ) ;
diag ( "Check if Error messages appear" ) ;
ok ( $ d - > find_element_by_xpath ( '//form//div//span[contains(text(), "Location 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 ( 'Enter information' ) ;
$ d - > fill_element ( '//*[@id="name"]' , 'xpath' , 'Test Location' ) ;
$ d - > fill_element ( '//*[@id="description"]' , 'xpath' , 'This is a Test Location' ) ;
$ d - > fill_element ( '//*[@id="name"]' , 'xpath' , 'Test Location' ) ;
@ -122,6 +186,7 @@ sub ctr_customer {
diag ( "Search for Location" ) ;
$ d - > find_element ( '//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]' ) - > click ( ) ;
$ d - > scroll_to_element ( $ d - > find_element ( '//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]' ) ) ;
$ d - > fill_element ( '//*[@id="locations_table_filter"]/label/input' , 'xpath' , 'thisshouldnotexist' ) ;
ok ( $ d - > find_element_by_css ( '#locations_table tr > td.dataTables_empty' , 'css' ) , 'Garbage text was not found' ) ;
$ d - > fill_element ( '//*[@id="locations_table_filter"]/label/input' , 'xpath' , 'Test Location' ) ;
@ -131,6 +196,26 @@ sub ctr_customer {
ok ( $ d - > find_element_by_xpath ( '//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "This is a Test Location")]' ) , "Description is correct" ) ;
ok ( $ d - > find_element_by_xpath ( '//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "127.0.0.1/16")]' ) , "Network block is correct" ) ;
diag ( "Edit Location" ) ;
$ d - > move_and_click ( '//*[@id="locations_table"]//tr[1]//td//a[contains(text(), "Edit")]' , 'xpath' , '//*[@id="customer_details"]//div//a[contains(text(), "Locations")]' ) ;
$ d - > fill_element ( '//*[@id="description"]' , 'xpath' , 'This is a very Test Location' ) ;
$ d - > fill_element ( '//*[@id="name"]' , 'xpath' , 'TestTest Location' ) ;
$ d - > fill_element ( '//*[@id="blocks.0.row.ip"]' , 'xpath' , '10.0.0.138' ) ;
$ d - > fill_element ( '//*[@id="blocks.0.row.mask"]' , 'xpath' , '16' ) ;
$ d - > find_element ( '//*[@id="save"]' ) - > click ( ) ;
diag ( "Search for Location" ) ;
$ d - > find_element ( '//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]' ) - > click ( ) ;
$ d - > scroll_to_element ( $ d - > find_element ( '//*[@id="customer_details"]//div//div//a[contains(text(),"Locations")]' ) ) ;
$ d - > fill_element ( '//*[@id="locations_table_filter"]/label/input' , 'xpath' , 'thisshouldnotexist' ) ;
ok ( $ d - > find_element_by_css ( '#locations_table tr > td.dataTables_empty' , 'css' ) , 'Garbage text was not found' ) ;
$ d - > fill_element ( '//*[@id="locations_table_filter"]/label/input' , 'xpath' , 'TestTest Location' ) ;
diag ( "Check location details" ) ;
ok ( $ d - > find_element_by_xpath ( '//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "TestTest Location")]' ) , "Name is correct" ) ;
ok ( $ d - > find_element_by_xpath ( '//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "This is a very Test Location")]' ) , "Description is correct" ) ;
ok ( $ d - > find_element_by_xpath ( '//*[@id="locations_table"]/tbody/tr[1]/td[contains(text(), "10.0.0.138/16")]' ) , "Network block is correct" ) ;
diag ( "Open delete dialog and press cancel" ) ;
$ c - > delete_customer ( $ customerid , 1 ) ;
$ d - > fill_element ( '//*[@id="Customer_table_filter"]/label/input' , 'xpath' , $ customerid ) ;