Skip to content

Fixed failing frontend tests#3206

Closed
IshaanXCoder wants to merge 8 commits intointelowlproject:developfrom
IshaanXCoder:fix/test-failures
Closed

Fixed failing frontend tests#3206
IshaanXCoder wants to merge 8 commits intointelowlproject:developfrom
IshaanXCoder:fix/test-failures

Conversation

@IshaanXCoder
Copy link
Contributor

Closes #3190 - Frontend test failing

Description

When I cloned the develop branch, 42 testsuites were failing(tried cloning multiple times, still the same).

CHANGES MADE :-

Fixed Dependency Conflict

  • File: package.json - "@testing-library/[email protected]" was added to devDependencies
  • Resolved 38 failing test suites

Fixed Chart Test Timezone Issues

Added Test Timeout

  • tests/components/scan/ScanForm/ScanForm.toastRedirect.test.jsx(even this didn't fail on the github check, failed locally due to the jest timeout issue.)

Fixed TimePicker Test (the key issue on the github job)

  • tests/components/common/TimePicker.test.jsx
  • Modified datetime value assertions to accept both formats: "2026-01-15T23:48:15" OR "2026-01-15T23:48:15.000"
    So I used toContain() matcher to handle browser inconsistencies with milliseconds

PTAL if charts.test.jsx and ScanForm.toastRedirect.test.jsx have to be changed or not as they were not a part of the original issue and passed on the gihtub job.

Before the changes -
Screenshot 2026-01-16 at 6 08 25 PM

After -
Screenshot 2026-01-16 at 11 24 41 PM

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue).

Checklist

  • I have read and understood the rules about how to Contribute to this project
  • The pull request is for the branch develop
  • If external libraries/packages with restrictive licenses were added, they were added in the Legal Notice section.
  • [N/A] Linters (Black, Flake, Isort) gave 0 errors. If you have correctly installed pre-commit, it does these checks and adjustments on your behalf.
  • I have added tests for the feature/bug I solved (see tests folder). All the tests (new and old ones) gave 0 errors.

Copilot AI review requested due to automatic review settings January 16, 2026 19:16
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses failing frontend tests by fixing dependency conflicts and handling browser inconsistencies in test environments. The changes resolve 42 failing test suites that occurred when cloning the develop branch.

Changes:

  • Fixed dependency conflict by pinning @testing-library/dom to version 10.4.1
  • Updated TimePicker test to handle browser inconsistencies with datetime milliseconds
  • Removed timezone-dependent date label checks in chart tests to prevent test flakiness
  • Added test timeout configuration for async ScanForm tests

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
frontend/package.json Added @testing-library/[email protected] to devDependencies and moved http-proxy-middleware to dependencies
frontend/package-lock.json Updated lockfile with dependency version resolutions
frontend/tests/components/common/TimePicker.test.jsx Fixed datetime value assertions to accept both formats with and without milliseconds
frontend/tests/components/dashboard/charts.test.jsx Removed timezone-specific date label assertions that caused test flakiness
frontend/tests/components/scan/ScanForm/ScanForm.toastRedirect.test.jsx Added 30-second timeout for async tests
Files not reviewed (1)
  • frontend/package-lock.json: Language not supported
Comments suppressed due to low confidence (1)

frontend/package.json:17

  • Moving http-proxy-middleware from devDependencies to dependencies changes it from a development-time tool to a production dependency. Verify this is intentional - if this package is only used during development (e.g., for the dev server proxy), it should remain in devDependencies.
    "http-proxy-middleware": "^2.0.6",

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 47 to 48
expect(firstDateInput.value).toMatch(new RegExp(`^${expectedFrom}(\\.000)?$`));
expect(secondDateInput.value).toMatch(new RegExp(`^${expectedTo}(\\.000)?$`));
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

The regex patterns constructed from expectedFrom and expectedTo do not escape special regex characters. If the date format contains characters like ., +, or *, they will be interpreted as regex metacharacters rather than literal characters. Use a regex escape function or escape the variables before interpolation.

Copilot uses AI. Check for mistakes.
@IshaanXCoder
Copy link
Contributor Author

Hey @mlodic PTAL at the description and let me know if any further modifications are needed.

@mlodic
Copy link
Member

mlodic commented Jan 17, 2026

Copilot asked about http-proxy-middleware changes, why there's this change?
Also, there are other weird changes in the package.json, the "peer" key is removed and "devOptional" is moved to "dev", why?

@drosetti also please check

@mlodic mlodic requested a review from drosetti January 17, 2026 06:50
@IshaanXCoder
Copy link
Contributor Author

IshaanXCoder commented Jan 17, 2026

@mlodic

Copilot asked about http-proxy-middleware changes, why there's this change?

When I added testing-library/[email protected] to package.json and ran npm install, this reresolved the entire dependency tree

Also, there are other weird changes in the package.json, the "peer" key is removed and "devOptional" is moved to "dev", why?

Changes were made in the lock file when i ran npm install, this is due to the npm versions, modern npm automatically installs peer dependencies. Similarly, devoptional -> dev is because of the newer version of npm.

@drosetti drosetti added the frontend Frontend related issues label Jan 17, 2026
@drosetti
Copy link
Contributor

I'm quite sure the reason behind you problem is a wrong configuration of your environment: in the first screenshot fails every test, we will noticed it because it would have the same behavior in the CI.

I need more information: in your screenshot you show the test fails but not the error message that explain why, also you changed the tests removing some checks

R1sh0bh-1 and others added 5 commits January 19, 2026 11:42
…ntelowlproject#3192) (intelowlproject#3195)

* fix:threatminer analyzer to handle 500 server errors and timeouts

* fix:linter errors

* fix(threatminer): handle 500 errors and timeouts gracefully with self.report.error
…oject#3163)

* fix: update YARAify URL in FREE_TO_USE_ANALYZERS playbook. Fixes intelowlproject#3140

Signed-off-by: YadavAkhileshh <[email protected]>

* fix: update YARAify URL in FREE_TO_USE_ANALYZERS playbook

Signed-off-by: YadavAkhileshh <[email protected]>

---------

Signed-off-by: YadavAkhileshh <[email protected]>
* udated to v2

* updated get request to post

* updated test file
Copilot AI review requested due to automatic review settings January 19, 2026 06:15
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@IshaanXCoder
Copy link
Contributor Author

Hey @drosetti @mlodic

I'm quite sure the reason behind you problem is a wrong configuration of your environment: in the first screenshot fails every test, we will noticed it because it would have the same behavior in the CI.

Yes i cloned the repo again,did a setup from scratch, noticed a few things which i was supposed to do earlier :

  • Github CI/CD uses node version 18 but i was locally using 24.2.0 because of which most of the tests failed.
  • CI/CD used UTC timezone while my system worked on IST timezone because of wihch charts.test.jsx was failing (added UTC by default in package.json)
  • timepicker.test.jsx is same as changed in 0969cb3

@mlodic
Copy link
Member

mlodic commented Jan 19, 2026

please open a new PR and reference this one there, the commi history here is corrupted

@mlodic mlodic closed this Jan 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

frontend Frontend related issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants