Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test : add tests for pagination of progresses api #2328

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

AnujChhikara
Copy link

Date: 30 Dec 2024

Developer Name: @AnujChhikara


Issue Ticket Number

Description

Addes tests for the pagination of the progresses API

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1

Test Coverage

Screenshot 1

image
image
Screenshot 2024-12-30 150131
Screenshot 2024-12-30 150042
image

Additional Notes

Added tests for PR - #2325

@pankajjs
Copy link
Contributor

Why are we not using typescript?

@@ -516,4 +516,104 @@ describe("Test Progress Updates API for Tasks", function () {
});
});
});

describe("GET /progresses (getPaginatedProgressDocument)", function () {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use arrow function declaration?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm following the same approach as the other tests in this file, where regular function declarations are used. If necessary, I can switch to arrow functions

Comment on lines 525 to 533
beforeEach(async function () {
userId = await addUser(userData[1]);
taskObject1 = await tasks.updateTask(taskData[0]);
taskId1 = taskObject1.taskId;
const progressData1 = stubbedModelTaskProgressData(userId, taskId1, 1683626400000, 1683590400000); // 2023-05-09
const progressData2 = stubbedModelTaskProgressData(userId, taskId1, 1683885600000, 1683849600000); // 2023-05-12
await firestore.collection("progresses").doc("taskProgressDocument1").set(progressData1);
await firestore.collection("progresses").doc("taskProgressDocument2").set(progressData2);
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are not clearing the data in afterEach hook?

Copy link
Author

@AnujChhikara AnujChhikara Dec 30, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tthe cleanDb() function is already being called in the afterEach hook of the parent describe block, which ensures the database is cleaned after every test and we are only doing get requests in the whole test

Comment on lines 521 to 523
let userId;
let taskObject1;
let taskId1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a need to declare these variables here? I don't see them being utilized anywhere apart from beforeEach.
Can't we move these inside beforeEach like this?

beforeEach(async function () {
      const userId = await addUser(userData[1]);
      const taskObject1 = await tasks.updateTask(taskData[0]);
      const taskId1 = taskObject1.taskId;

return done();
});
});
});
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing case where api might return a 500.

Comment on lines 425 to 426
let userId1;
let userId2;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, we can move this inside the beforeEach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement Pagination with Limit for getProgressDocument
3 participants