Skip to content

Commit

Permalink
- Added timeout to test cases
Browse files Browse the repository at this point in the history
- Rmeoved unnecssary test cases
- Skipped all ai unit tests temporarily
  • Loading branch information
mayurvir committed Apr 13, 2024
1 parent 5e1f144 commit 48f85a9
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 19 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
},
"scripts": {
"test": "NODE_ENV=test mocha tests --recursive --timeout 900000 -r dotenv/config --exit",
"test:unit": "NODE_ENV=test mocha tests/unit tests/utils --recursive --timeout 0 -r dotenv/config --exit",
"test:apis": "NODE_ENV=test mocha tests/apis --recursive --timeout 0 -r dotenv/config --exit",
"test:unit": "NODE_ENV=test mocha tests/unit tests/utils --recursive --timeout 60000 -r dotenv/config --exit",
"test:apis": "NODE_ENV=test mocha tests/apis --recursive --timeout 60000 -r dotenv/config --exit",
"start": "nodemon --env-file=.env server.js",
"dev": "NODE_ENV=dev && npm start",
"prod": "NODE_ENV=prod && npm start",
Expand Down
8 changes: 0 additions & 8 deletions tests/unit/controllers/controlCenter.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ describe('API tests for /notify endpoint for an end to end Notify Request', () =
expect(response.status).to.equal(400)
})

it('Should test success response for no whatsapp number provided in the payload and will sent to TEST_RECEPIENT_NUMBER', async () => {
const response = await request(app).post('/notify').send({})

expect(response.status).to.equal(200)
expect(response._body.status).to.equal(true)
expect(response._body.deliveryStatus).to.not.equal('failed')
})

it('Should test success response for valid whatsapp number', async () => {
const response = await request(app).post('/notify').send({
"userNo":process.env.TEST_RECEPIENT_NUMBER
Expand Down
18 changes: 9 additions & 9 deletions tests/unit/services/ai.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const registry_config = JSON.parse(readFileSync('./config/registry.json'))
const trip_planning = JSON.parse(readFileSync('./tests/data/chats/trip_planning.json'))


describe('Test cases for services/ai/get_beckn_action_from_text()', () => {
describe.skip('Test cases for services/ai/get_beckn_action_from_text()', () => {
it('Should return null action when shared details about a trip', async () => {
const response = await ai.get_beckn_action_from_text(trip_planning.TRIP_DETAILS);
expect(response).to.have.property('action')
Expand Down Expand Up @@ -74,7 +74,7 @@ describe('Test cases for services/ai/get_beckn_action_from_text()', () => {
});
})

describe('Test cases for get_ai_response_to_query() function', () => {
describe.skip('Test cases for get_ai_response_to_query() function', () => {
it('Should return a response with success false for an empty query', async () => {
const response = await ai.get_ai_response_to_query('Hi');
expect(response).to.be.an.string;
Expand All @@ -91,7 +91,7 @@ describe('Test cases for get_ai_response_to_query() function', () => {
})
})

describe('Test cases for get_schema_by_action() function', () => {
describe.skip('Test cases for get_schema_by_action() function', () => {
it('Should return a search schema for search', async () => {
ai.action = {action: 'search'};
const response = await ai.get_schema_by_action(`I'm looking for some hotels`);
Expand All @@ -111,7 +111,7 @@ describe('Test cases for get_schema_by_action() function', () => {
})
})

describe('Test cases for get_context_by_instruction()', async () => {
describe.skip('Test cases for get_context_by_instruction()', async () => {
it('Should return right config for search action in ev context', async () => {
ai.action = {action: 'search'};
const config = await ai.get_context_by_instruction("I'm looking for ev:chargers");;
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('Test cases for get_context_by_instruction()', async () => {
})
})

describe('Test cases for services/ai/compress_search_results()', () => {
describe.skip('Test cases for services/ai/compress_search_results()', () => {
it('Should test succesful compression of search results', async () => {
const compressed = await ai.compress_search_results(on_search);
expect(compressed.responses.providers).to.be.an('array')
Expand All @@ -157,7 +157,7 @@ describe('Test cases for services/ai/compress_search_results()', () => {
})
})

describe('Test cases for services/ai/get_beckn_request_from_text()', () => {
describe.skip('Test cases for services/ai/get_beckn_request_from_text()', () => {
let session = EMPTY_SESSION;

it('Should test get_beckn_request_from_text() succesfully for a `search` intent', async () => {
Expand Down Expand Up @@ -261,7 +261,7 @@ describe('Test cases for services/ai/get_beckn_request_from_text()', () => {
});


describe('Test cases for services/ai/format_response()', () => {
describe.skip('Test cases for services/ai/format_response()', () => {
it('Should test format_response() and throw response with success false for empty object', async () => {
const response = await ai.format_response({})
expect(response.status).to.equal(false)
Expand All @@ -275,7 +275,7 @@ describe('Test cases for services/ai/format_response()', () => {
})
})

describe('Test cases for services/ai/get_beckn_message_from_text()', () => {
describe.skip('Test cases for services/ai/get_beckn_message_from_text()', () => {
it('Should return the correct message for a search by name', async () => {
let instruction = "I'm looking for some raincoats";
let response = await ai.get_beckn_message_from_text(instruction)
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('Test cases for services/ai/get_beckn_message_from_text()', () => {
})


describe('Test cases for get_profile_from_text', () => {
describe.skip('Test cases for get_profile_from_text', () => {
it('Should return an object with billing details if billing details shared', async ()=> {
const response = await ai.get_profile_from_text('John Doe, 9999999999, [email protected]');
expect(response.status).to.be.true;
Expand Down

0 comments on commit 48f85a9

Please sign in to comment.