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

Add more tests for instructor permissions to fetch ddahs #599

Merged
merged 17 commits into from
Jun 20, 2021

Conversation

alex-kozin
Copy link
Contributor

@alex-kozin alex-kozin commented May 31, 2021

More tests for fetching DDAHs for instructor. Related to issue #597

@alex-kozin alex-kozin changed the title Feat/test fetch instructor ddahs [WIP] Feat/test fetch instructor ddahs May 31, 2021
@alex-kozin alex-kozin force-pushed the feat/test-fetch-instructor-ddahs branch from 0a942d9 to 2c27c54 Compare May 31, 2021 01:54
@alex-kozin alex-kozin changed the title [WIP] Feat/test fetch instructor ddahs Feat/test fetch instructor ddahs Jun 8, 2021
@alex-kozin alex-kozin changed the title Feat/test fetch instructor ddahs Add more tests for instructor permissions to fetch ddahs Jun 8, 2021
@alex-kozin alex-kozin marked this pull request as ready for review June 8, 2021 18:02
@alex-kozin alex-kozin requested review from mertkaya1033 and a user June 8, 2021 18:02
@alex-kozin alex-kozin changed the title Add more tests for instructor permissions to fetch ddahs [WIP] Add more tests for instructor permissions to fetch ddahs Jun 9, 2021
@alex-kozin alex-kozin force-pushed the feat/test-fetch-instructor-ddahs branch from 3339cde to 4697c51 Compare June 9, 2021 13:26
@alex-kozin alex-kozin changed the title [WIP] Add more tests for instructor permissions to fetch ddahs Add more tests for instructor permissions to fetch ddahs Jun 9, 2021
Copy link
Contributor

@mertkaya1033 mertkaya1033 left a comment

Choose a reason for hiding this comment

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

This is a great PR only with a single minor issue.

frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
expect(resp).toHaveStatus("success");

// Only one DDAH is intially seeded for this instructor
expect(resp.payload).toHaveLength(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Even though this implementation should be fine, I think you should not assume that only one DDAH is initially seeded for the instructor unless you are seeding the instructor within the test. This is because someone may need to seed more DDAH for this particular instructor in the future and might run into problems with this test.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

While I don't like this approach either, that is similar to what's done here for the ddah tests. I see before it used .toContain() and I like that better too. I am not sure that's the direction we will be going in though. @siefkenj do you have a preference?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should fetch all DDAHs as admin and filter that list to contain only those for that instructor. Then check the list the instructor retrieves is the same.

Copy link
Contributor Author

@alex-kozin alex-kozin Jun 14, 2021

Choose a reason for hiding this comment

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

It's a great idea! For the implementation though, we don't have an endpoint to get all DDAHs per instructor? That means we will have to fetch all positions, filter them per instructor, then get all assignments for these positions and then get their respective DDAHs? That would complicate the test a lot imo, even though that will yield the most predictable outcome regardless of the seeded data.

That also conflicts with the idea that we "know the seeded data" and can rely on it unless I am missing something of course

frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
@alex-kozin alex-kozin requested a review from siefkenj June 13, 2021 13:04
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/instructor-permission-test.js Outdated Show resolved Hide resolved
frontend/src/tests/setup.js Outdated Show resolved Hide resolved
frontend/src/tests/setup.js Outdated Show resolved Hide resolved
@siefkenj siefkenj merged commit 0cffc80 into uoft-tapp:master Jun 20, 2021
// Cleanup
for (const assignment of seeded.assignments) {
if (assignment._temp_id) {
const { temp_id, ...cleanAssignment } = assignment;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alex-kozin Fix this - delete all properties with an underscore

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