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

[#9534] Deleting the last instructor in the course leaves a dangling course object in the database #11930

Merged

Conversation

mattlim1207
Copy link
Contributor

Fixes #9534

Outline of Solution

  1. Removed the truth check in DeleteInstructorAction that allowed admins to bypass the truth checking stopping the last instructor of a course from being deleted from said course.
  2. Modified the corresponding unit test, testExecute_deleteLastInstructorByGoogleId_shouldPass, by flipping asserts, and renaming accordingly.

@mattlim1207
Copy link
Contributor Author

Just noticed end-to-end testing needs to be updated as well, working on that now

@mattlim1207
Copy link
Contributor Author

The only E2E test that should be affected now passes, and the consistently failing test seems to fail both on my feature branch and master

@NicolasCwy
Copy link
Contributor

NicolasCwy commented Aug 13, 2022

@mattlim1207 will be checking this out

Edit: reran the E2E test and all seem ok

"name": "Teammates Instr3",
"email": "AAccounts.instr3@gmail.tmt",
"role": "Co-owner",
"isDisplayedToStudents": true,
Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason why an additional instructor account for courseId tm.e2e.AAccounts.CS2103 is needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So from what I gathered about E2E tests and the "happy path," I figured a test should check the admin can successfully delete an instructor, as deleting a last instructor of a course is more of an edge case. Thus, it required another instructor to be created

Copy link
Contributor

@NicolasCwy NicolasCwy Aug 15, 2022

Choose a reason for hiding this comment

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

Which E2E test are you referring to? From what I understand this PR only touches the unit test DeleteInstructorActionTest.java

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's the AdminAccountsPageE2ETest. I figured I should fix the issue, and all associated unit tests and E2E tests, in one PR. The E2E test was set up to create a course with one invisible instructor, then simulate the admin deleting the instructor. Because this behavior was changed with this PR, I modified the initial parameters.

Copy link
Contributor

@NicolasCwy NicolasCwy Aug 16, 2022

Choose a reason for hiding this comment

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

I see, so the changes you have made in DeleteInstructorAction would cause AdminAccountsPageE2ETest to fail as the there is currently 1 instructor attached to the course CS2103 (they are invisible as well, causing the test to fail too).

Thanks for clarifying, this makes sense to me

Co-authored-by: Nicolas Chang Weng Yew <nicolas.chang99@gmail.com>
Copy link
Contributor

@NicolasCwy NicolasCwy left a comment

Choose a reason for hiding this comment

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

LGTM! Nice work and thanks for contributing

@NicolasCwy NicolasCwy requested review from ziqing26 and removed request for fsgmhoward August 16, 2022 02:00
@NicolasCwy NicolasCwy added the s.FinalReview The PR is ready for final review label Aug 16, 2022
Copy link
Contributor

@ziqing26 ziqing26 left a comment

Choose a reason for hiding this comment

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

LGTM!

@ziqing26 ziqing26 added s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging c.Task Other non-user-facing works, e.g. refactoring, adding tests and removed s.FinalReview The PR is ready for final review labels Aug 17, 2022
@NicolasCwy NicolasCwy merged commit 39192f4 into TEAMMATES:master Aug 17, 2022
@mattlim1207 mattlim1207 deleted the 9534-delete-last-instructor-fix branch August 19, 2022 01:19
@wkurniawan07 wkurniawan07 added this to the V8.20.0 milestone Dec 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c.Task Other non-user-facing works, e.g. refactoring, adding tests s.ToMerge The PR is approved by all reviewers including final reviewer; ready for merging
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Deleting the last instructor in the course leaves a dangling course object in the database.
4 participants