import { browser, element, by } from 'protractor'; import { DispatchPage } from './dispatch.po'; type result = any; let dis = new DispatchPage(); describe('Dispatch Page', () => { it ('should show the dispatch page', async () => { await dis.waitForItemNotToBePresent(dis.spinner); await dis.waitForItemToBeVisible(dis.subHeader); await browser.sleep(10000); await expect(dis.pageHeader.getText()).toBe(dis.disTitle); }); it ('should show previous date and filter location', async () => { await dis.filterdate(); await dis.datePicker.getText().then (async function (getDate){ await browser.sleep(2000) await dis.closeIcon.click(); //await element(by.xpath('//controller-main/div[2]')).click();; await expect(dis.date.getText()).toContain(getDate); }); }); it ("Click today's button", async () => { await dis.todaysButton.click(); await browser.sleep(3000); await dis.waitForItemNotToBePresent(dis.spinner); await dis.waitForItemToBeVisible(dis.routes); //await expect(dis.date.getText()).toBe(dis.today()); //await dis.waitForItemNotToBePresent(dis.spinner); }); // it ("should generate route for today", async() =>{ // await dis.filterBtn.click(); // await dis.waitForItemToBeVisible(dis.flyout); // await dis.updateRoutesBtn.click(); // await dis.waitForItemToBeVisible(dis.genModal); // await dis.waitForItemToBeVisible(dis.endGen); // await expect(dis.genModalTitle).toBe(dis.gmTitle); // await dis.waitForItemNotToBePresent(dis.spinner); // await dis.genModalClose.click(); // }); it ('Hide and Show KPI', async () =>{ await dis.hideKPILab(); await expect(dis.kpiBoxLab.isDisplayed()).toBeFalsy(); await dis.hideKPILab(); await expect(dis.kpiBoxLab.isDisplayed()).toBeTruthy(); }); it ('should show the route details', async () => { await dis.showRouteDetails(); await expect(dis.modalTitle.getText()).toBe(dis.routeModalTitle); await browser.sleep(5000); }); it ('should assigned vehicle and driver to a route', async () =>{ var vehicleName = dis.vehicle var driverName = dis.driver await dis.assignedVehicleAndDriver(); await expect(vehicleName.getText()).toContain(driverName.getText()); await driverName.getText().then (function (getDriverName){ dis.routeModalCloseBtn.click(); expect(getDriverName).toBe(driverName.getText()); }); await dis.waitForItemNotToBePresent(dis.spinner); }) it ('should lock and unlocked route', async() => { await dis.inlineActionsBtn.click(); await dis.lockRoute.click(); await expect(dis.lockIcon.isDisplayed()).toBeTruthy(); await dis.lockIcon.click(); }); it ('should show the Orders tab', async () => { await dis.ordersTab.click(); await dis.waitForItemNotToBePresent(dis.spinner); await dis.waitForItemToBeVisible(dis.badge); await browser.sleep(3000); }); it ('should show the Packages tab', async () => { await dis.packagesTab.click(); await dis.waitForItemNotToBePresent(dis.spinner); await browser.sleep(3000); }); it ('should show the vehicles tab', async () => { await dis.vehiclesTab.click(); await dis.waitForItemNotToBePresent(dis.spinner); await browser.sleep(1000); }); it ('should show the Drivers tab', async () => { await dis.driversTab.click(); await dis.waitForItemNotToBePresent(dis.spinner); }); it ('should show the Routes tab', async () => { await dis.routesTab.click(); await dis.waitForItemNotToBePresent(dis.spinner); await dis.waitForItemToBeVisible(dis.routes); await browser.sleep(5000); }); }); describe('Select Route',() => { it ('First Route', async() => { var l= dis.location.getText(); var d= dis.date.getText(); var getLocAndDate = l+" " +d; await browser.sleep(3000); await dis.routeLists.get(3).click(); await dis.waitForItemToBeVisible(dis.routeDetailsBadge); expect(dis.pageHeader.getText()).toBe(dis.routeTitle); expect(dis.rdHeader.getText()).toContain(getLocAndDate); }); it ('have the Antech Lab for last stop', async () =>{ var row = element.all(by.className('ui-table-tbody')); var value = row.all(by.tagName("tr")).last(); await expect(value.getText()).toContain(dis.lastStop); await dis.waitForItemNotToBePresent(dis.spinner); }); it ('open the order details', async ()=>{ await dis.order.first().click(); await expect(dis.pageHeader.getText()).toBe(dis.orderTitle); await dis.waitForItemToBeVisible(dis.orderstatusBadge); await dis.waitForItemNotToBePresent(dis.spinner); }); it('should go back to dispatch page', async ()=>{ await dis.menulist.first().click(); await browser.sleep(5000); await dis.waitForItemNotToBePresent(dis.spinner); }); }); describe('Select Next Route',() => { it ('Next Route', async() => { var l= dis.location.getText(); var d= dis.date.getText(); var getLocAndDate = l+" " +d; await browser.sleep(3000); await dis.routeLists.get(8).click(); await dis.waitForItemToBeVisible(dis.routeDetailsBadge); expect(dis.pageHeader.getText()).toBe(dis.routeTitle); expect(dis.rdHeader.getText()).toContain(getLocAndDate); }); it ('have the Antech Lab for last stop', async () =>{ var row = element.all(by.className('ui-table-tbody')); var value = row.all(by.tagName("tr")).last(); await expect(value.getText()).toContain(dis.lastStop); await dis.waitForItemNotToBePresent(dis.spinner); }); it ('open the order details', async ()=>{ await dis.order.get(5).click(); await expect(dis.pageHeader.getText()).toBe(dis.orderTitle); await dis.waitForItemToBeVisible(dis.orderstatusBadge); await dis.waitForItemNotToBePresent(dis.spinner); await browser.sleep(5000); }); it('should go back to dispatch page', async ()=>{ await dis.menulist.first().click(); await browser.sleep(5000); await dis.waitForItemNotToBePresent(dis.spinner); await dis.refreshBtn.click(); await dis.waitForItemNotToBePresent(dis.spinner); await browser.sleep(6000); }); }); // // describe('Route Details ',() => { // // it ('Second Route', async() => { // // let route = element(by.xpath("//tr[4]/td[3]/div/div/a")); // // await route.click(); // // //await dis.routeLists.last().click(); // // await expect(dis.pageHeader.getText()).toBe(dis.routeTitle); // // await expect(dis.backBtn.isDisplayed()).toBeTruthy(); // // await dis.waitForItemToBeVisible(dis.routeDetailsBadge); // // }); // // it ('have the LA Antech Lab for last stop', async () =>{ // // var row = element.all(by.className('ui-table-tbody')); // // var value = row.all(by.tagName("tr")).last(); // // await expect(value.getText()).toContain(dis.LAlastStop); // // }); // // it ('open the order details', async ()=>{ // // await dis.order.first().click(); // await expect(dis.pageHeader.getText()).toBe(dis.orderTitle); // }); // it ('goback to Route Detais', async ()=>{ // await dis.backBtn.click(); // await expect(dis.pageHeader.getText()).toBe(dis.routeTitle); // }); // it ('go back to dispatch', async ()=> { // await dis.backBtn.click(); // await expect(dis.pageHeader.getText()).toBe(dis.disTitle); // }); //});