Repository navigation
Improve login/logout behavior for testing - #1752
Conversation
I did see an error once of: I don't think it is related to your work. I also don't know if it is the only error that happens. Thus, I think it should be a new issue if it continues and other fixes don't resolve it. I would also like to be able to more clearly give information about the issue if possible. For now, it is resolved for the PR. Thanks for looking into it. |
huss
left a comment
There was a problem hiding this comment.
@Nespina24 Thank you for another contribution. Review found it looked good. I also retested every test changed and it works as desired. Congratulations on another accepted contribution to OED.
Description
This PR changes the login/logout behavior in test cases to only login/logout for the current test's role. Previously, each test would login for each role and logout for all roles even though only one role was being tested, which created unnecessary login/logout behavior. This was fixed by adding a describe block to restrict the login/logout to only the current loop's role.
Logging in and logging out for all roles (Previous):

Logging in and logging out for the current test's role (After PR):

Fixes #1750
Type of change
Checklist
Limitations
This PR did not touch on the sporadic test failures that were referenced in issue #1750, which I was unable reproduce on my local machine. A comment that explains the bug could be included for now.
AI Disclosure
List all AI tools used including version(s). You can submit without the versions but OED may request further information before accepting the PR.
GPT 5.6-Luna
If used, describe how each AI tool was used including giving the prompts used. You can submit without the prompts but OED may request further information before accepting the PR.
I asked AI to further explain a comment from a previous PR (#1691 (comment)) to better understand the problem being described.
I found that since Mocha builds the entire test suite first, and only then starts running the tests, Mocha's before/beforeEach and after/afterEach hooks were not tied to the loop pertaining for a specific role. Because of this, the hooks wouldn't use the same role that the for loop is currently on, and therefore they wouldn't create separate test suites for each role.
List of GitHub IDs for anyone working on or contributing to this PR that you cannot certify has followed this policy. Any conttributors not listed are being certified by you to have complied with the terms of the OED AI policy shown below.
None.
OED AI policy
Given the expanding usage of AI and review of submissions to OED, OED is developing an AI policy. OED is working on a more general solution but for now OED has this AI policy and each submission is required to:
If more than one person is involved in a request, then each person on the team needs to certify and provide the information above. If you don't list anyone else in the section above on unknown compliance with this policy then you must have personal knowledge that the other team members provided you with the necessary information and you are faithfully providing or indicate the answers only apply for yourself or a given list of authors (by GitHub ID).
Other items may be added in the future. It is also open to change given input, new information or changes in the AI sphere and you can make comments/suggestions to the OED project.