Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
Metabase
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Engineering Digital Service
Metabase
Commits
9423ca83
Unverified
Commit
9423ca83
authored
1 year ago
by
Ryan Laurie
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
fix timing test flake (#40786)
parent
7f147bdf
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/src/metabase/parameters/components/ParameterValuePicker/ListPicker/ListPicker.unit.spec.tsx
+17
-7
17 additions, 7 deletions
.../ParameterValuePicker/ListPicker/ListPicker.unit.spec.tsx
with
17 additions
and
7 deletions
frontend/src/metabase/parameters/components/ParameterValuePicker/ListPicker/ListPicker.unit.spec.tsx
+
17
−
7
View file @
9423ca83
...
...
@@ -21,6 +21,10 @@ const VALUES = [
"
1-799 Smith Road
"
,
];
const
userEvent2
=
userEvent
.
setup
({
advanceTimers
:
jest
.
advanceTimersByTime
,
});
function
setup
(
value
:
string
,
values
:
string
[],
searchDebounceMs
?:
number
)
{
const
onChangeMock
=
jest
.
fn
();
const
onClearMock
=
jest
.
fn
();
...
...
@@ -51,6 +55,9 @@ function setup(value: string, values: string[], searchDebounceMs?: number) {
}
describe
(
"
ListPicker
"
,
()
=>
{
afterEach
(()
=>
{
jest
.
useRealTimers
();
});
it
(
"
onSearchChange fires only once per input char
"
,
async
()
=>
{
const
{
onSearchChange
}
=
setup
(
""
,
VALUES
.
slice
());
...
...
@@ -69,17 +76,20 @@ describe("ListPicker", () => {
});
it
(
"
onSearchChange debounced works
"
,
async
()
=>
{
jest
.
useFakeTimers
({
advanceTimers
:
false
});
const
{
onSearchChange
}
=
setup
(
""
,
VALUES
.
slice
(),
100
);
const
select
=
screen
.
getByPlaceholderText
(
"
Pick values
"
);
await
userEvent
.
click
(
select
);
await
userEvent
.
type
(
select
,
"
H
"
);
await
userEvent
.
type
(
select
,
"
e
"
);
await
userEvent
.
type
(
select
,
"
l
"
);
await
userEvent
.
type
(
select
,
"
l
"
);
await
userEvent
.
type
(
select
,
"
o
"
);
await
userEvent
2
.
click
(
select
);
await
userEvent
2
.
type
(
select
,
"
H
"
);
await
userEvent
2
.
type
(
select
,
"
e
"
);
await
userEvent
2
.
type
(
select
,
"
l
"
);
await
userEvent
2
.
type
(
select
,
"
l
"
);
await
userEvent
2
.
type
(
select
,
"
o
"
);
await
waitFor
(()
=>
expect
(
onSearchChange
).
toHaveBeenCalledTimes
(
1
));
expect
(
onSearchChange
).
toHaveBeenCalledTimes
(
0
);
jest
.
advanceTimersByTime
(
101
);
expect
(
onSearchChange
).
toHaveBeenCalledTimes
(
1
);
expect
(
onSearchChange
).
toHaveBeenCalledWith
(
"
Hello
"
);
});
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment