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 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); }); 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 dis.waitForItemToBeVisible(dis.routeModalCloseBtn); await expect(dis.modalTitle.getText()).toBe(dis.routeModalTitle); await browser.sleep(5000); }); it ('should assigned vehicle and driver to a route', async () =>{ await dis.assignedVehicleAndDriver(); await dis.driver.getText().then (function (getDriverName){ dis.routeModalCloseBtn.click(); expect(getDriverName).toBe(dis.tableDriverName.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); }); });