public void NoCustomersOnCardView() { NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET(/^\/app\/partials\//).passThrough(); $httpBackend.whenGET(/^\/app\/views\//).passThrough(); $httpBackend.whenGET('\/api/dataservice/customersSummary?$top=10&$skip=0').respond( // status 200, // body [], // headers { 'X-InlineCount': 0 } );" ); var ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); var cardElement = ngDriver.FindElement(By.ClassName("cardContainer")); Assert.AreEqual(0, cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")).Count); Assert.IsTrue(ngDriver.FindElement(By.XPath("//h4[contains(.,'No customers found')]")).Displayed); }
public void DeleteCustomerOnCardView() { NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET(/^\/app\/partials\//).passThrough(); $httpBackend.whenGET(/^\/app\/views\//).passThrough(); $httpBackend.whenGET('\/api/dataservice/customersSummary?$top=10&$skip=0').respond( // status 200, // body [ { id:1, firstName:'Marcus', lastName:'HighTower', city:'Phoenix', state: { id:1, abbreviation:'AZ', name:' Arizona' }, orderCount:6, gender:'Male' }, { id:2, firstName:'Dan', lastName:'Wahlin', city:'Chandler', state:{ id:1, abbreviation:'AZ', name:' Arizona' }, orderCount:5, gender:'Male' } ], // headers { 'X-InlineCount': 2 } );" ); var ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); var customersPage = new CustomersPage(ngDriver); Assert.AreEqual(2, customersPage.GetCustomersCount()); Assert.AreEqual("Showing 2 of 2 total customers", customersPage.GetFooterText()); // Delete Dan (sorry...) customersPage.DeleteCustomer(2).ConfirmDelete(); Assert.AreEqual(1, customersPage.GetCustomersCount()); Assert.AreEqual("Showing 1 of 1 total customers", customersPage.GetFooterText()); // Fail! }
public void NoCustomersOnCardView() { NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET(/^\/app\/partials\//).passThrough(); $httpBackend.whenGET(/^\/app\/views\//).passThrough(); $httpBackend.whenGET('\/api/dataservice/customersSummary?$top=10&$skip=0').respond( // status 200, // body [], // headers { 'X-InlineCount': 0 } );" ); var ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); var customersPage = new CustomersPage(ngDriver); Assert.AreEqual(0, customersPage.GetCustomersCount()); Assert.AreEqual("No customers found", customersPage.GetFooterText()); }
public void DeleteCustomerOnCardView() { NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET(/^\/app\/partials\//).passThrough(); $httpBackend.whenGET(/^\/app\/views\//).passThrough(); $httpBackend.whenGET('\/api/dataservice/customersSummary?$top=10&$skip=0').respond( // status 200, // body [ { id:1, firstName:'Marcus', lastName:'HighTower', city:'Phoenix', state: { id:1, abbreviation:'AZ', name:' Arizona' }, orderCount:6, gender:'Male' }, { id:2, firstName:'Dan', lastName:'Wahlin', city:'Chandler', state:{ id:1, abbreviation:'AZ', name:' Arizona' }, orderCount:5, gender:'Male' } ], // headers { 'X-InlineCount': 2 } );" ); var ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); var cardElement = ngDriver.FindElement(By.ClassName("cardContainer")); var footer = ngDriver.FindElement(NgBy.Binding("totalRecords")); Assert.AreEqual("Showing 2 of 2 total customers", footer.Text); var customers = cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")); Assert.AreEqual(2, customers.Count); // Delete Dan (sorry...) foreach (var customer in customers) { if ((long)customer.Evaluate("customer.id") == 2) { // Close card customer.FindElement(By.ClassName("cardClose")).Click(); // Popup to confirm ngDriver.FindElement(By.XPath("//button[contains(.,'Delete Customer')]")).Click(); break; } } Assert.AreEqual(1, cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")).Count); Assert.AreEqual("Showing 1 of 1 total customers", footer.Text); // Fail! }
public void NoCustomersOnCardView() { NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET(/^\/app\/partials\//).passThrough(); $httpBackend.whenGET(/^\/app\/views\//).passThrough(); $httpBackend.whenGET('\/api/dataservice/customersSummary?$top=10&$skip=0').respond( // status 200, // body [], // headers { 'X-InlineCount': 0 } );" ); var ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); var cardElement = ngDriver.FindElement(By.ClassName("cardContainer")); Assert.AreEqual(0, cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")).Count); Assert.IsTrue(ngDriver.FindElement(By.XPath("//h4[contains(.,'No customers found')]")).Displayed); }
public void DeleteCustomerOnCardView() { NgMockE2EModule mockModule = new NgMockE2EModule(@" $httpBackend.whenGET(/^\/app\/partials\//).passThrough(); $httpBackend.whenGET(/^\/app\/views\//).passThrough(); $httpBackend.whenGET('\/api/dataservice/customersSummary?$top=10&$skip=0').respond( // status 200, // body [ { id:1, firstName:'Marcus', lastName:'HighTower', city:'Phoenix', state: { id:1, abbreviation:'AZ', name:' Arizona' }, orderCount:6, gender:'Male' }, { id:2, firstName:'Dan', lastName:'Wahlin', city:'Chandler', state:{ id:1, abbreviation:'AZ', name:' Arizona' }, orderCount:5, gender:'Male' } ], // headers { 'X-InlineCount': 2 } );" ); var ngDriver = new NgWebDriver(driver, mockModule); ngDriver.Navigate().GoToUrl("http://localhost:58000/#/customers"); var cardElement = ngDriver.FindElement(By.ClassName("cardContainer")); var footer = ngDriver.FindElement(NgBy.Binding("totalRecords")); Assert.AreEqual("Showing 2 of 2 total customers", footer.Text); var customers = cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")); Assert.AreEqual(2, customers.Count); // Delete Dan (sorry...) foreach (var customer in customers) { if ((long)customer.Evaluate("customer.id") == 2) { // Close card customer.FindElement(By.ClassName("cardClose")).Click(); // Popup to confirm ngDriver.FindElement(By.XPath("//button[contains(.,'Delete Customer')]")).Click(); break; } } Assert.AreEqual(1, cardElement.FindElements(NgBy.Repeater("customer in filteredCustomers")).Count); Assert.AreEqual("Showing 1 of 1 total customers", footer.Text); // Fail! }