Skip to content

Improve login/logout behavior for testing - #1752

Merged
huss merged 2 commits into
OpenEnergyDashboard:developmentfrom
Nespina24:issue1750_loginTest
Nov 10, 2026
Merged

huss merged 2 commits into
OpenEnergyDashboard:developmentfrom
Nespina24:issue1750_loginTest

Conversation

@Nespina24

Copy link
Copy Markdown
Contributor

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):
Screenshot 2026-10-31 122409

Logging in and logging out for the current test's role (After PR):
Screenshot 2026-10-31 122905

Fixes #1750

Type of change

  • Note merging this changes the database configuration.
  • This change requires a documentation update

Checklist

  • I have followed the OED pull request ideas
  • I have removed text in ( ) from the issue request
  • You acknowledge that every person contributing to this work has signed the OED Contributing License Agreement and each author is listed in the Description section. This checkbox is required.
  • By submitting this PR I agree to the OED AI policy specified below and acknowledge that I followed its terms in this submission. This checkbox is required.

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:

  • Disclose of all AI tools used including version.
  • Disclose how each AI tool was used including giving the prompts used.
  • By checking the AI policy checkbox above, you certify that you have the copyright to the submitted work. Given recent court cases, this will require that less than 50% of the code and documentation came from AI. Less is even better. Every AI system you use must be checked that they provide you with copyright to this work that is compatible with the OED project MPL license.
  • By checking the AI policy checkbox above, you certify that you have personally reviewed all code and properly tested it. Thus, you are taking personal responsibility for the quality of the submission by guaranteeing you carefully reviewed every aspect in detail.
    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.

@github-project-automation github-project-automation Bot moved this to PR Submitted in OED PR status Nov 7, 2026
@huss huss moved this from PR Submitted to Ready for review in OED PR status Nov 8, 2026
@huss

huss commented Nov 10, 2026

Copy link
Copy Markdown
Member

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.

I did see an error once of:

1) CSV Parameter Validation
       File Upload Security
         should handle multiple file upload attempts:
     Error: write EPIPE
      at afterWriteDispatched (node:internal/stream_base_commons:160:15)
      at writevGeneric (node:internal/stream_base_commons:143:3)
      at Socket._writeGeneric (node:net:929:11)
      at Socket._writev (node:net:938:8)
      at doWrite (node:internal/streams/writable:409:12)
      at clearBuffer (node:internal/streams/writable:564:5)
      at Writable.uncork (node:internal/streams/writable:351:7)
      at connectionCorkNT (node:_http_outgoing:951:8)
      at process.processTicksAndRejections (node:internal/process/task_queues:81:21)

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 huss left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@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.

@huss
huss merged commit 59bca07 into OpenEnergyDashboard:development Nov 10, 2026
3 checks passed
@github-project-automation github-project-automation Bot moved this from Ready for review to Complete in OED PR status Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Complete

Development

Successfully merging this pull request may close these issues.

Mocha before/after behavior with login/out in tests

2 participants