mirror of
https://github.com/Graylog2/graylog2-server.git
synced 2026-03-13 09:32:21 +08:00
* Fix no-restricted-imports: replace lodash with native alternatives and fix import paths
Replace lodash/get with optional chaining, lodash/defaultTo with nullish
coalescing (??), lodash/max with Math.max, and swap react-router-dom Link
imports to use the project's router wrapper. Add eslint-disable for files
that are the wrapper implementations themselves.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix jsx-a11y/control-has-associated-label: add aria-label to controls
Add descriptive aria-label attributes to buttons, table cells, and other
interactive controls that were missing accessible labels.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix react/jsx-key: add missing key props to elements in iterators
Add stable key props to JSX elements inside .map() callbacks using
item IDs and unique property names as keys.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix no-param-reassign: avoid mutating function parameters
Replace reduce accumulator mutations with Object.fromEntries or spread
syntax. Use eslint-disable for browser API patterns (beforeunload).
Create new objects instead of mutating request/response parameters.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix misc TypeScript/ESLint rules: require-imports, unsafe Function type, nested ternaries, triple-slash refs, unused props/vars
- Add eslint-disable for require() in .d.ts and jest.isolateModules
- Add eslint-disable for Function type in reflux .d.ts, remove redundant
Function annotations in tests
- Refactor nested ternaries in SortUtils to if/else
- Convert triple-slash references to side-effect imports
- Fix unused prop type declarations in Timestamp and Section
- Rename catch variable e to _error in useIsLocalNode
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix testing-library/no-node-access: replace DOM traversal with TL queries
Replace .querySelector(), .firstChild, and .getElementsByClassName() with
Testing Library queries (getByRole, getByText, findByTitle, within) in
test files. Add eslint-disable where DOM access is unavoidable (Leaflet
map containers, custom text matchers).
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix no-restricted-properties and prefer-user-event in tests
Replace fireEvent.submit with userEvent.click on submit buttons and
fireEvent.change with userEvent.selectOptions in ContentPackEditParameter
tests. Add submit button to ContentPackEditParameter component to enable
the userEvent.click pattern. Use eslint-disable for fireEvent.change in
InputSetupWizard test where userEvent.type causes waitFor timeouts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix jest/expect-expect and jest/no-done-callback in tests
Add eslint-disable for it.each tests where assertions are in callback
functions that ESLint cannot statically detect. Add explicit assertion
to PivotHandler type-check test. Convert GlobalThroughputStore tests
from done-callback pattern to async/await with Promises.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix Link import path after router.tsx was removed in d4b1262
Update Button.tsx and MenuItem.tsx to import Link from
components/common/Link (the new dedicated wrapper) instead of the
deleted components/common/router.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Type reflux StoreDefinition generically and remove eslint-disable for Function type
Make StoreDefinition<T> generic so init is typed as () => void and
getInitialState as () => T. Make fields optional in 4 store state types
(ContentPacksStore, IndicesConfigurationStore, InputTypesStore,
CollectorsStore) whose getInitialState returns a subset of the full state.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Revert ContentPackEditParameter component changes and fix ESLint hints in test only
Replace fireEvent.change with userEvent.selectOptions and extract a
submitForm helper with a single eslint-disable to avoid duplicating
the disable comment across all fireEvent.submit call sites. The
component has no submit button and jsdom doesn't support implicit
form submission, so fireEvent.submit remains necessary.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Use part string as React key instead of array index in RuleBlockDisplay
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Running `prettier`.
* Address PR #25171 review feedback
- Revert aria-label additions on td/th elements; increase
jsx-a11y/control-has-associated-label depth to 3 instead
- Use screen.findByRole in Autocomplete test instead of waitFor+getByRole
- Add default value for optional field prop in Timestamp component
- Rename test helpers to expectIsDeepEqual/expectIsNumericString to
satisfy jest/expect-expect without eslint-disable
- Replace require() with jest.isolateModulesAsync + dynamic import()
in DocsHelper tests
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Remove unused findValidationState from TabKeywordTimeRange test
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Fix control-has-associated-label lint errors and SelectedGrantee test
Ignore td/th elements in control-has-associated-label rule (false
positives), add aria-label to backlog checkbox, and rename
checkCurrentState to expectCurrentState to remove eslint-disable.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
* Replace type casts with proper types in UseCreateViewForEvent
Type function parameters for getSummaryAggregation and WidgetsGenerator
so reduce() accepts generic type parameters, removing all `as` casts.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
62 lines
2.2 KiB
TypeScript
62 lines
2.2 KiB
TypeScript
/*
|
|
* Copyright (C) 2020 Graylog, Inc.
|
|
*
|
|
* This program is free software: you can redistribute it and/or modify
|
|
* it under the terms of the Server Side Public License, version 1,
|
|
* as published by MongoDB, Inc.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* Server Side Public License for more details.
|
|
*
|
|
* You should have received a copy of the Server Side Public License
|
|
* along with this program. If not, see
|
|
* <http://www.mongodb.com/licensing/server-side-public-license>.
|
|
*/
|
|
import * as React from 'react';
|
|
import { render, screen } from 'wrappedTestingLibrary';
|
|
|
|
import CustomMenuList from './CustomMenuList';
|
|
|
|
const getChildrenList = (n: number): React.ReactElement[] => {
|
|
const list = Array(n).fill(null);
|
|
|
|
return list.map(() => <div key={Math.random()}>{Math.random()}</div>);
|
|
};
|
|
|
|
describe('CustomMenuList', () => {
|
|
const originalOffsetHeight = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetHeight');
|
|
const originalOffsetWidth = Object.getOwnPropertyDescriptor(HTMLElement.prototype, 'offsetWidth');
|
|
|
|
beforeAll(() => {
|
|
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', { configurable: true, value: 50 });
|
|
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', { configurable: true, value: 50 });
|
|
});
|
|
|
|
afterAll(() => {
|
|
Object.defineProperty(HTMLElement.prototype, 'offsetHeight', originalOffsetHeight);
|
|
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', originalOffsetWidth);
|
|
});
|
|
|
|
it('Check if List component rendered for number of items more than 1000', () => {
|
|
render(<CustomMenuList>{getChildrenList(1001)}</CustomMenuList>);
|
|
|
|
const list = screen.getAllByTestId('react-window-list-item');
|
|
|
|
expect(list.length).toBeGreaterThan(0);
|
|
});
|
|
|
|
it('Check if List component rendered for number of items less than 1000', () => {
|
|
render(
|
|
<CustomMenuList getStyles={() => ({})} getClassNames={() => ''} cx={() => ''}>
|
|
{getChildrenList(999)}
|
|
</CustomMenuList>,
|
|
);
|
|
|
|
const list = screen.getByTestId('react-select-list');
|
|
|
|
expect(list).toBeInTheDocument();
|
|
});
|
|
});
|