Skip to content

Commit

Permalink
Added route image and navigation url to response of select_route call
Browse files Browse the repository at this point in the history
  • Loading branch information
mayurvir committed Apr 18, 2024
1 parent f6ce817 commit d00c7d2
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
10 changes: 9 additions & 1 deletion services/MapService.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {Client} from "@googlemaps/google-maps-services-js";
import logger from '../utils/logger.js'
import polyline from '@mapbox/polyline';
import get_text_by_key from '../utils/language.js';

class MapsService {
constructor() {
Expand Down Expand Up @@ -78,7 +79,14 @@ class MapsService {
this.session.profile.selected_route = {
polyline: this.session.routes[index.index].overview_polyline.points
}
return true;

// set route image in map instance
this.routes_image = await this.get_static_image_path([this.session.routes[index.index]]);

return {
status: true,
message: get_text_by_key('route_selected', {url : this.session.routes[index.index].navigation_url})
};
} else {
return false;
}
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/controllers/agent.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ describe('API tests for getResponse() function', () => {
expect(response.text).to.be.a('string');
})

it('Should select a route and get route map wit navigation link', async () => {
const message = "Lets select the first one"
const response = await request(app).post('/webhook').send({
From: process.env.TEST_RECEPIENT_NUMBER,
Body: message,
raw_yn: true
})
expect(response.body).to.have.property('data');
expect(response.body).to.have.property('media_urls');
expect(response.body.data).to.be.an('object');
expect(response.body.data.message).to.be.a('string');
expect(response.body.media_urls).to.be.an('array').that.is.not.empty;
expect(response.body.media_urls[0]).to.be.a('string');
})

it('Should return a list of hotels', async () => {
const message = "Can you please find hotels near Yellowstone national park?"
const response = await request(app).post('/webhook').send({
Expand Down

0 comments on commit d00c7d2

Please sign in to comment.