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

[#13066] Combine Admin Add Account Request Flow into Instructor Account Request Flow #13124

Open
wants to merge 29 commits into
base: master
Choose a base branch
from

Conversation

Andy-W-Developer
Copy link
Contributor

@Andy-W-Developer Andy-W-Developer commented May 30, 2024

Fixes #13066

Outline of Solution
The "Add Instructor" and "Add Instructors" buttons now create account requests and pushes them to accountReqs for account-request-table to manage.

Removed the results table, some related functions and tests.
Changed remaining tests to reflect the changes.

Adding, removing and editing is now handled by account-request-table.

new_account_request_test.mp4

@weiquu weiquu added the s.Ongoing The PR is being worked on by the author(s) label Jun 10, 2024
@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

1 similar comment
@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 9 days). 🐌 😢
Hope someone can get it to move forward again soon...

@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 8 days). 🐌 😢
Hope someone can get it to move forward again soon...

Copy link
Contributor

@mingyuanc mingyuanc left a comment

Choose a reason for hiding this comment

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

LGTM

@mingyuanc mingyuanc removed the s.Ongoing The PR is being worked on by the author(s) label Jul 30, 2024
@mingyuanc
Copy link
Contributor

@Andy-W-Developer is the PR done? or isit still on going. Your current changes LGTM

@Andy-W-Developer
Copy link
Contributor Author

@mingyuanc Yes this PR is done, if there's anything else that could be added, let me know, thanks.

Copy link
Contributor

@domoberzin domoberzin left a comment

Choose a reason for hiding this comment

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

Sorry for getting to this so late, thanks a lot of taking this issue on, it definitely isn't a small one to handle. I think some changes need to be made, please review the comments and let us know if you need any assistance

@@ -34,16 +34,6 @@ public void testAll() {

homePage.queueInstructorForAdding(singleLineDetails);

homePage.addAllInstructors();
Copy link
Contributor

Choose a reason for hiding this comment

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

As part of our migration to SQL, please keep the E2E tests the same as its non-SQL counterpart as much as possible. The logic here does not represent the same logic in src/e2e/java/teammates/e2e/cases/AdminHomePageE2ETest.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.

Both tests use the same logic now, the page reload was removed because fetchAccountRequests() makes it unnecessary.

instructorInstitution: instructorDetailSplit[2],
};

this.accountService.createAccountRequest(requestData)
Copy link
Contributor

Choose a reason for hiding this comment

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

This batch processing needs better error handling, this implementation essentially ignores any errors. I understand that this is for the first input form. Perhaps a better way to do this is push back to the invalid lines upon error and show an error toast to indicate that the creation of certain requests. Note that requests may fail for different reasons too (duplicate email, invalid email etc.)

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 now on error, pushes the line to invalidLines, rejoins invalidLines then shows an error toast.

}

public String getMessageForInstructor(int i) {
By by = By.id("message-instructor-" + i);
public String getToastTextContent() {
Copy link
Contributor

Choose a reason for hiding this comment

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

There should be a method (i think its named verifyStatusMessage) in the superclass AppPage to verify the toast contents. I'd suggest using that method as it has a retry mechanism

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Switched over to verifyStatusMessage, thanks.

this.accountService.createAccountRequest(requestData)
.subscribe({
next: () => {
this.fetchAccountRequests();
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes an API call for each account request, I think you can just call this once at the end of the entire loop after all requests are processed, since this is a batch creation feature anyway

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ran into an issue where the account requests are not updated if the fetch is moved outside of the subscribe, I'm assuming because the API call is not instant - logging seemed to show that was happening.
What is the recommended way of waiting for the requests to finish before moving onto the next statement?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • Moved createAccountRequest() into a promise and push to an array of promises
  • Moved fetchAccountRequests() into an allSettled thenable.

assertTrue(successMessage.contains(
"Instructor \"AHPUiT Instrúctör WithPlusInEmail\" has been successfully created"));

String failureMessage = homePage.getMessageForInstructor(1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Try not to remove this negative test case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've added back an error toast for when a single line request has an invalid email under validateAndAddInstructorDetails, it works when I add a request manually but when running the e2e test, no toast is shown.
A toast made by the approve account button - under the account request table still works, any ideas why on this is happening?
https://github.com/user-attachments/assets/c985d4dd-5a51-4ca0-90e1-67ee7e48197a
I've tried rerunning the e2e tests after deleting all the postgres data and remaking all docker containers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The issue was user error, I forgot to build the front-end files after editing.
I've added back in the negative test case with a updated error message.

@Andy-W-Developer
Copy link
Contributor Author

@domoberzin Mostly ready for review.

I need help with the accountCreateRequest loop, I'm don't know how to call fetchAccountRequests and push to invalidLines only after all request have been processed.

I've tried looking into finalize but don't think it'll work unless createAccountRequest or an alternative supports a list of account requests.

A less than ideal way could be to move the account requests into a separate list and for loop then have an if statement inside createAccountRequests to check if the loop index is equal to the list length and run fetchAccountRequests there.

Let me know your thoughts, thanks.

@mingyuanc
Copy link
Contributor

@Andy-W-Developer could you look into why the SQL tests are failing first before we review?

@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

@Andy-W-Developer
Copy link
Contributor Author

Sorry for the late update.

The previously failing test in InstructorNotificationsPageE2ETest might be unrelated.

I rewrote validateAndAddInstructorDetails() to use promises so that fetchAccountRequests() is only called once.

The component tests are failing because changes to instructorDetails are made inside the subscribe, and createAccountRequest() isn't mocked yet.

I'm looking into why, after mocking the observables, the code inside the subscribe doesn't seem to run or only partially run.

@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 7 days). 🐌 😢
Hope someone can get it to move forward again soon...

@Andy-W-Developer
Copy link
Contributor Author

@mingyuanc Ready for review.
The failing test - UUID string too large under SearchAccountRequestsActionTest line 959 seems unrelated, the same tests fail under the current master branch.

@nusoss-bot
Copy link

Folks, This PR seems to be stalling (no activities for the past 9 days). 🐌 😢
Hope someone can get it to move forward again soon...

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.

Combine Admin Add Account Request Flow into Instructor Account Request Flow
5 participants