diff --git a/t/selenium/controller_invoice.t b/t/selenium/controller_invoice.t index 686b6434f0..b20ce7bcbd 100644 --- a/t/selenium/controller_invoice.t +++ b/t/selenium/controller_invoice.t @@ -21,14 +21,13 @@ sub ctr_invoice { my $billingname = ("billing" . int(rand(100000)) . "test"); my $customerid = ("id" . int(rand(100000)) . "ok"); - $c->login_ok(); $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("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'); @@ -40,8 +39,16 @@ sub ctr_invoice { $d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); $d->find_element("Invoice Templates", 'link_text')->click(); - diag("Trying to create a new Invoice Template"); + diag("Trying to create a empty Invoice Template"); $d->find_element("Create Invoice Template", 'link_text')->click(); + $d->unselect_if_selected('//*[@id="reselleridtable"]/tbody/tr[1]/td[5]/input'); + $d->find_element('//*[@id="save"]')->click(); + + diag("Check Error messages"); + ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Reseller field is required")]')); + ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Name 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); @@ -60,12 +67,38 @@ sub ctr_invoice { ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Name is correct'); ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[4]', 'svg'), 'Type is correct'); + diag("Try to edit Invoice Template Information"); + $templatename = ("invoice" . int(rand(100000)) . "tem"); + $d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Edit Meta")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]//input'); + $d->fill_element('//*[@id="name"]', 'xpath', $templatename); + $d->find_element('//*[@id="save"]')->click(); + + diag("Search for Template"); + $d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); + ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); + $d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename); + + diag("Check details"); + ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[2]', $resellername), 'Reseller is correct'); + ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Name is correct'); + ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[4]', 'svg'), 'Type is correct'); + diag('Go to Invoices page'); $d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); $d->find_element("Invoices", 'link_text')->click(); - diag("Trying to create a new Invoice"); + diag("Trying to create a empty Invoice"); $d->find_element("Create Invoice", 'link_text')->click(); + $d->unselect_if_selected('//*[@id="templateidtable"]/tbody/tr[1]/td[4]/input'); + $d->unselect_if_selected('//*[@id="contractidtable"]/tbody/tr[1]/td[6]/input'); + $d->find_element('//*[@id="save"]')->click(); + + diag("Check Error messages"); + ok($d->find_element_by_xpath('//form//div//span[contains(text(), "field is required")]')); + ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Customer field is required")]')); + ok($d->find_element_by_xpath('//form//div//span[contains(text(), "Invoice Period field is required")]')); + + diag("Fill in Values"); $d->fill_element('//*[@id="templateidtable_filter"]/label/input', 'xpath', 'thisshouldnotexist'); ok($d->find_element_by_css('#templateidtable tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); $d->fill_element('//*[@id="templateidtable_filter"]/label/input', 'xpath', $templatename); @@ -90,6 +123,17 @@ sub ctr_invoice { ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[2]', $customernumber), 'Customer# is correct'); ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[3]', $contactmail), 'Customer Email is correct'); + diag("Trying to NOT delete Invoice"); + $d->move_and_click('//*[@id="Invoice_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="Invoice_table_filter"]/label/input'); + $d->find_element('//*[@id="dataConfirmCancel"]')->click(); + + diag("Check if Invoice is still here"); + $d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); + ok($d->find_element_by_css('#Invoice_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); + $d->fill_element('//*[@id="Invoice_table_filter"]/label/input', 'xpath', $contactmail); + ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[2]', $customernumber), 'Invoice is still here'); + ok($d->wait_for_text('//*[@id="Invoice_table"]/tbody/tr/td[3]', $contactmail), 'Invoice is still here'); + diag("Trying to delete Invoice"); $d->move_and_click('//*[@id="Invoice_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="Invoice_table_filter"]/label/input'); $d->find_element('//*[@id="dataConfirmOK"]')->click(); @@ -102,6 +146,19 @@ sub ctr_invoice { $d->find_element('//*[@id="main-nav"]//*[contains(text(),"Settings")]')->click(); $d->find_element("Invoice Templates", 'link_text')->click(); + diag("Trying to NOT delete Invoice Template"); + $d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); + ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); + $d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename); + $d->move_and_click('//*[@id="InvoiceTemplate_table"]//tr[1]//td//a[contains(text(), "Delete")]', 'xpath', '//*[@id="InvoiceTemplate_table_filter"]/label/input'); + $d->find_element('//*[@id="dataConfirmCancel"]')->click(); + + diag("Check if Invoice Template was deleted"); + $d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); + ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found'); + $d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', $templatename); + ok($d->wait_for_text('//*[@id="InvoiceTemplate_table"]/tbody/tr/td[3]', $templatename), 'Template is still here'); + diag("Trying to delete Invoice Template"); $d->fill_element('//*[@id="InvoiceTemplate_table_filter"]/label/input', 'xpath', 'thisshouldnotexist'); ok($d->find_element_by_css('#InvoiceTemplate_table tr > td.dataTables_empty', 'css'), 'Garbage text was not found');