Skip to content

Commit

Permalink
feat(DRIVER-APP): cypress test cases for landing page with new ride d…
Browse files Browse the repository at this point in the history
…river app
  • Loading branch information
imrthr committed Oct 28, 2024
1 parent 2a44fbe commit 4056b5d
Show file tree
Hide file tree
Showing 10 changed files with 132 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ const OfflineModal: React.FC<OfflineModalProps> = ({ isOpen }) => {
text={t.offlineTitle}
fontWeight="500"
fontSize={'20px'}
data-test={testIds.taxi_BPP_offlineMode_offlineTitle}
dataTest={testIds.taxi_BPP_offlineMode_offlineTitle}
/>
<Typography
text={t.offlineDescription}
data-test={testIds.taxi_BPP_offlineMode_offlineDescription}
dataTest={testIds.taxi_BPP_offlineMode_offlineDescription}
/>
</Flex>
</Box>
Expand Down
5 changes: 3 additions & 2 deletions apps/taxi-bpp-v2/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const Homepage = () => {
const { currentAcceptedRideRequest, driverStatus } = useSelector((state: RideStatusRootState) => state.rideStatus)
const apiKeyForGoogle = process.env.NEXT_PUBLIC_GOOGLE_API_KEY
const strapiUrl = process.env.NEXT_PUBLIC_STRAPI_URL

console.log(currentRideRequest)
const socket = useSocket(strapiUrl!, {
query: {
agentId: user?.agent?.id
Expand Down Expand Up @@ -288,7 +288,8 @@ const Homepage = () => {
handleModalSubmit('COMPLETED', data)
dispatch(updateDriverStatus(RIDE_STATUS_CODE.AWAITING_DRIVER_APPROVAL))
}

// console.log(RIDE_STATUS_CODE.AWAITING_DRIVER_APPROVAL)
localStorage.setItem('actionType', RIDE_STATUS_CODE.AWAITING_DRIVER_APPROVAL)
const getModalButtons = (
actionType: ModalTypes,
data: RideDetailsModel
Expand Down
3 changes: 3 additions & 0 deletions apps/taxi-bpp-v2/store/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ const store = configureStore({
}).concat(api.middleware)
})

if (process.env.NODE_ENV === 'development' && typeof window !== 'undefined') {
window.store = store
}
export const persistor = persistStore(store)

export type RootState = ReturnType<typeof store.getState>
Expand Down
2 changes: 1 addition & 1 deletion cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default defineConfig({
openMode: 0
},
setupNodeEvents(on, config) {
// implement node event listeners here
// Implement node event listeners here
}
}
})
52 changes: 52 additions & 0 deletions cypress/e2e/taxi-bpp/landingPage.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { testIds } from '../../../shared/dataTestIds'

describe('Landing page of Taxi-Bpp (Driver Application) test cases', () => {
before(() => {
cy.login(testIds.url_base, '[email protected]', 'Abcd@1234')
})

it('should display the top header with current location and switch button visible', () => {
cy.getByData(testIds.locationIcon).should('exist').and('be.visible')
cy.getByData(testIds.yourLocation).should('exist').and('be.visible')
cy.wait(10000)
// cy.getByData(testIds.location).should('be.visible')
cy.getByData(testIds.downArrow).should('exist').and('be.visible')
cy.getByData(testIds.taxi_BPP_switch_toggle_button).should('exist').and('be.visible')
})
it('should display the top header with current location and switch button disabled', () => {
cy.getByData(testIds.taxi_BPP_offlineMode_image).should('exist').and('be.visible')
cy.getByData(testIds.taxi_BPP_offlineMode_offlineTitle).should('exist').and('be.visible')
cy.getByData(testIds.taxi_BPP_offlineMode_offlineDescription).should('exist').and('be.visible')
})
it('should display the top header with current location and switch button enabled', () => {
cy.intercept('POST', 'https://bpp-unified-strapi1-prod.becknprotocol.io/driver-app/toggle-availability', {
fixture: 'TAXI-BPP/toggleAvailabiltiyResponse.json'
}).as('toggleAvailabiltiyResponse')
cy.getByData(testIds.taxi_BPP_switch_toggle_button).click()
cy.wait('@toggleAvailabiltiyResponse').its('response.statusCode').should('eq', 200)
cy.getByData(testIds.taxi_BPP_switch_toggle_button).should('exist')
cy.wait(10000)
})

it('displays a new ride request modal and verifies ride details', () => {
cy.fixture('TAXI-BPP/newRide.json').then(rideRequestData => {
cy.setRideRequestState(rideRequestData)
})
cy.getByData(testIds.taxi_BPP_pickup_location_text).should('be.visible')
cy.getByData(testIds.taxi_BPP_drop_location_text).should('be.visible')
cy.getByData(testIds.taxi_BPP_km_away_text).should('be.visible')
cy.getByData(testIds.taxi_BPP_km_distance_text).should('be.visible')
cy.getByData(testIds.taxi_BPP_accept_button).should('be.visible')
cy.getByData(testIds.taxi_BPP_decline_button).should('be.visible')
})
it('Decline button should be clickable', () => {
cy.getByData(testIds.taxi_BPP_decline_button).click()
cy.wait(10000)
cy.fixture('TAXI-BPP/newRide.json').then(rideRequestData => {
cy.setRideRequestState(rideRequestData)
})
})
it('Accept button should be clickable', () => {
cy.getByData(testIds.taxi_BPP_accept_button).click()
})
})
22 changes: 22 additions & 0 deletions cypress/fixtures/TAXI-BPP/newRide.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"id": "REQ_NEW_RIDE",
"title": "New Ride Request",
"subTitle": "",
"rideDetails": {
"orderId": 2130,
"source": "FW2M+WV8, Pandhari Nagar, Handewadi, Pune, Maharashtra 412308, India",
"sourceGeoLocation": {
"latitude": 18.4520848,
"longitude": 73.9339347
},
"destinationGeoLocation": {
"latitude": 18.5214945,
"longitude": 73.93047109999999
},
"destination": "P1002, MARVEL DIVA, P1002, Kirtane Baugh, Phase 1, Hadapsar, Pune, Maharashtra 411028, India",
"distance": 9.88,
"time": "30",
"driverStatus": "AWAITING_DRIVER_APPROVAL",
"contact": "9999999999"
}
}
28 changes: 28 additions & 0 deletions cypress/fixtures/TAXI-BPP/toggleAvailabiltiyResponse.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"toggleAvailabiltiyResponse": {
"id": 4,
"day_of_week": "Suresh Driver Availability",
"start_time": null,
"end_time": null,
"is_available": true,
"unavailability_reason": null,
"createdAt": "2024-05-15T07:39:47.366Z",
"updatedAt": "2024-10-24T08:48:21.057Z",
"publishedAt": "2024-05-15T07:39:48.455Z"
},
"updateLocationResponse": {
"id": 55,
"address": "Suresh Cab Driver GPS Location",
"city": "Suresh Cab Driver GPS Location",
"state": null,
"country": null,
"zip": null,
"createdAt": "2024-05-15T07:39:08.851Z",
"updatedAt": "2024-10-24T08:48:21.073Z",
"publishedAt": "2024-05-15T07:39:11.633Z",
"latitude": null,
"longitude": null,
"map_url": null,
"gps": "28.6094734, 77.4570594"
}
}
8 changes: 8 additions & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ declare global {
loginDynamic(email: string, password: string): Chainable<void>
performSearchDynamic(searchTerm: string): Chainable<void>
updatePolygon(aliasName: string): Chainable<void>
setRideRequestState(aliasName: string): Chainable<void>
}
}
}
Expand Down Expand Up @@ -345,6 +346,13 @@ Cypress.Commands.add('fillDSEP_x_inputScholarshipApplyForm', () => {
cy.get('#submitButton').click()
})

Cypress.Commands.add('setRideRequestState', rideRequestData => {
cy.window().then(win => {
const { store } = win
console.log(store)
store.dispatch({ type: 'rider/setCurrentRideRequest', payload: rideRequestData })
})
})
// Cypress.Commands.add('updatePolygon', coordinates => {
// cy.window().its('store').invoke('dispatch', {
// type: 'policy/updatePolygon',
Expand Down
8 changes: 7 additions & 1 deletion packages/common/src/components/topSheet/topSheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,15 @@ const TopSheet: React.FC<TopSheetComponentProps> = ({
columnGap="10px"
pl="unset"
>
<Image src={'/images/setLocation.svg'} />
<Image
src={'/images/setLocation.svg'}
data-test={testIds.locationIcon}
/>
<Box>
<Text
fontSize="12px"
fontWeight={400}
data-test={testIds.yourLocation}
>
{t('yourLocation')}
</Text>
Expand All @@ -78,6 +82,7 @@ const TopSheet: React.FC<TopSheetComponentProps> = ({
<Skeleton
height="10px"
width="200px"
data-test={testIds.skeleton}
/>
) : (
<>
Expand All @@ -98,6 +103,7 @@ const TopSheet: React.FC<TopSheetComponentProps> = ({
cursor={'pointer'}
pt="4px"
src="/images/downArrow.svg"
data-test={testIds.downArrow}
/>
</>
)}
Expand Down
7 changes: 6 additions & 1 deletion shared/dataTestIds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,12 @@ const testIds = {
taxi_BPP_myRides_riderName: 'taxi_BPP-myRides-riderName',
taxi_BPP_myRides_date: 'taxi_BPP-myRides-date',
taxi_BPP_myRides_time: 'taxi-BPP-myRides-time',
taxi_BPP_myRides_status: 'taxi-BPP-myRides-status'
taxi_BPP_myRides_status: 'taxi-BPP-myRides-status',
locationIcon: 'location-icon',
current_location: 'current-location',
yourLocation: 'your-location',
skeleton: 'skeleton-loader',
downArrow: 'down-arrow'
}

export { testIds }

0 comments on commit 4056b5d

Please sign in to comment.