mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-22 16:06:19 -05:00
Fixing flaky domain search test.
This commit is contained in:
parent
345b69b7d7
commit
5497e1eb61
2 changed files with 13 additions and 8 deletions
|
|
@ -124,7 +124,12 @@ describe('Domains List Page', () => {
|
|||
});
|
||||
|
||||
it('filters domains with search', () => {
|
||||
cy.get('input[placeholder="Domain filter..."]').type('example');
|
||||
cy.get('input[placeholder="Domain filter..."]')
|
||||
.type('example')
|
||||
// Confirm the input itself stabilized before asserting downstream effects.
|
||||
.should('have.value', 'example');
|
||||
// The filter is driven by the URL query param; wait for the router to commit it.
|
||||
cy.url().should('include', 'domain=example');
|
||||
// Chain assertions so they retry together with the extended timeout
|
||||
cy.get('table:visible tbody tr', {timeout: 10000})
|
||||
.should('have.length', 1)
|
||||
|
|
|
|||
|
|
@ -435,14 +435,14 @@ const useClearableInput = (searchStr, onChange, onClear, onSubmit, size = 'small
|
|||
const [submitted, setSubmitted] = useState(false);
|
||||
|
||||
React.useEffect(() => {
|
||||
// Search was changed above.
|
||||
if (searchStr !== value) {
|
||||
setValue(searchStr);
|
||||
// `searchStr` is the source of truth from the parent (often an async URL query param).
|
||||
// Depend ONLY on `searchStr` -- never on `value` -- otherwise a transient render where the
|
||||
// local `value` has advanced (e.g. "ex") but `searchStr` still trails ("e") fires this
|
||||
// effect and reverts `value`, garbling fast typing (flaky filter test).
|
||||
if ((searchStr || '') !== value) {
|
||||
setValue(searchStr || '');
|
||||
}
|
||||
if (!searchStr) {
|
||||
setValue('');
|
||||
}
|
||||
}, [searchStr, value]);
|
||||
}, [searchStr]);
|
||||
|
||||
const handleChange = (e) => {
|
||||
if (e) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue