chore: refactor tests to improve clarity and reliability
- Removed unnecessary test.skip() calls in various test files, replacing them with comments for clarity. - Enhanced retry logic in TestDataManager for API requests to handle rate limiting more gracefully. - Updated security helper functions to include retry mechanisms for fetching security status and setting module states. - Improved loading completion checks to handle page closure scenarios. - Adjusted WebKit-specific tests to run in all browsers, removing the previous skip logic. - General cleanup and refactoring across multiple test files to enhance readability and maintainability.
This commit is contained in:
@@ -96,6 +96,27 @@ if (!Element.prototype.scrollIntoView) {
|
||||
Element.prototype.scrollIntoView = function() {}
|
||||
}
|
||||
|
||||
// Prevent jsdom navigation errors for anchor clicks during tests
|
||||
const anchorPrototype = HTMLAnchorElement.prototype as unknown as {
|
||||
__testNoNavClick?: boolean
|
||||
__originalClick?: typeof HTMLAnchorElement.prototype.click
|
||||
}
|
||||
|
||||
if (!anchorPrototype.__testNoNavClick) {
|
||||
const originalClick = HTMLAnchorElement.prototype.click
|
||||
Object.defineProperty(HTMLAnchorElement.prototype, '__testNoNavClick', {
|
||||
value: true,
|
||||
configurable: false,
|
||||
writable: false,
|
||||
})
|
||||
HTMLAnchorElement.prototype.click = function() {
|
||||
const event = new MouseEvent('click', { bubbles: true, cancelable: true })
|
||||
this.dispatchEvent(event)
|
||||
return undefined
|
||||
}
|
||||
anchorPrototype.__originalClick = originalClick
|
||||
}
|
||||
|
||||
// Filter noisy React act environment warnings that can appear in some environments
|
||||
const _origConsoleError = console.error
|
||||
console.error = (...args: unknown[]) => {
|
||||
|
||||
Reference in New Issue
Block a user