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
02af8756
Commit
02af8756
authored
7 years ago
by
Tom Robinson
Browse files
Options
Downloads
Patches
Plain Diff
fix qb_editor_bar.integ tests
parent
1642cc2e
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/test/query_builder/qb_editor_bar.integ.spec.js
+16
-55
16 additions, 55 deletions
frontend/test/query_builder/qb_editor_bar.integ.spec.js
with
16 additions
and
55 deletions
frontend/test/query_builder/qb_editor_bar.integ.spec.js
+
16
−
55
View file @
02af8756
...
...
@@ -6,9 +6,12 @@ import {
click
,
clickButton
,
setInputValue
}
from
"
__support__/enzyme_utils
"
import
{
delay
}
from
"
metabase/lib/promise
"
;
import
React
from
'
react
'
;
import
QueryBuilder
from
"
metabase/query_builder/containers/QueryBuilder
"
;
import
FieldValuesWidget
from
"
metabase/components/FieldValuesWidget
"
import
TokenField
from
"
metabase/components/TokenField
"
import
{
mount
}
from
"
enzyme
"
;
import
{
INITIALIZE_QB
,
...
...
@@ -20,6 +23,7 @@ import {
import
{
FETCH_TABLE_METADATA
,
FETCH_FIELD_VALUES
,
}
from
"
metabase/redux/metadata
"
;
import
FieldList
,
{
DimensionPicker
}
from
"
metabase/query_builder/components/FieldList
"
;
...
...
@@ -35,6 +39,7 @@ import BreakoutWidget from "metabase/query_builder/components/BreakoutWidget";
import
{
getQueryResults
}
from
"
metabase/query_builder/selectors
"
;
import
*
as
Urls
from
"
metabase/lib/urls
"
;
import
{
KEYCODE_COMMA
}
from
"
metabase/lib/keyboard
"
;
const
initQbWithDbAndTable
=
(
dbId
,
tableId
)
=>
{
return
async
()
=>
{
...
...
@@ -83,26 +88,26 @@ describe("QueryBuilder editor bar", () => {
click
(
ratingFieldButton
);
})
it
(
"
lets you see its field values in filter popover
"
,
()
=>
{
it
(
"
lets you see its field values in filter popover
"
,
async
()
=>
{
await
store
.
waitForActions
([
FETCH_FIELD_VALUES
]);
// FIXME: TokenField asynchronously updates displayed options :(
await
delay
(
10
);
// Same as before applies to FilterPopover too: individual list items could be in their own components
const
filterPopover
=
qb
.
find
(
FilterPopover
);
const
fieldItems
=
filterPopover
.
find
(
'
li
'
);
expect
(
fieldItems
.
length
).
toBe
(
5
);
expect
(
fieldItems
.
length
).
toBe
(
5
+
1
);
// NOTE: bleh, one for the input
// should be in alphabetical order
expect
(
fieldItems
.
firs
t
().
text
()).
toBe
(
"
1
"
)
expect
(
fieldItems
.
a
t
(
1
).
text
()).
toBe
(
"
1
"
)
expect
(
fieldItems
.
last
().
text
()).
toBe
(
"
5
"
)
})
it
(
"
lets you set 'Rating is 5' filter
"
,
async
()
=>
{
const
filterPopover
=
qb
.
find
(
FilterPopover
);
const
fieldItems
=
filterPopover
.
find
(
'
li
'
);
const
widgetFieldItem
=
fieldItems
.
last
();
const
widgetCheckbox
=
widgetFieldItem
.
find
(
CheckBox
);
expect
(
widgetCheckbox
.
props
().
checked
).
toBe
(
false
);
click
(
widgetFieldItem
.
children
().
first
());
expect
(
widgetCheckbox
.
props
().
checked
).
toBe
(
true
);
setInputValue
(
filterPopover
.
find
(
"
input
"
),
"
5
"
)
const
addFilterButton
=
filterPopover
.
find
(
'
button[children="Add filter"]
'
)
clickButton
(
addFilterButton
);
...
...
@@ -115,29 +120,6 @@ describe("QueryBuilder editor bar", () => {
expect
(
filterWidget
.
text
()).
toBe
(
"
Rating is equal to5
"
);
})
it
(
"
lets you set 'Rating is 5 or 4' filter
"
,
async
()
=>
{
// reopen the filter popover by clicking filter widget
const
filterWidget
=
qb
.
find
(
FilterWidget
);
click
(
filterWidget
.
find
(
FieldName
));
const
filterPopover
=
qb
.
find
(
FilterPopover
);
const
fieldItems
=
filterPopover
.
find
(
'
li
'
);
const
widgetFieldItem
=
fieldItems
.
at
(
3
);
const
gadgetCheckbox
=
widgetFieldItem
.
find
(
CheckBox
);
expect
(
gadgetCheckbox
.
props
().
checked
).
toBe
(
false
);
click
(
widgetFieldItem
.
children
().
first
());
expect
(
gadgetCheckbox
.
props
().
checked
).
toBe
(
true
);
const
addFilterButton
=
filterPopover
.
find
(
'
button[children="Update filter"]
'
)
clickButton
(
addFilterButton
);
await
store
.
waitForActions
([
SET_DATASET_QUERY
])
expect
(
qb
.
find
(
FilterPopover
).
length
).
toBe
(
0
);
expect
(
filterWidget
.
text
()).
toBe
(
"
Rating is equal to2 selections
"
);
})
it
(
"
lets you remove the added filter
"
,
async
()
=>
{
const
filterWidget
=
qb
.
find
(
FilterWidget
);
click
(
filterWidget
.
find
(
"
.Icon-close
"
))
...
...
@@ -178,7 +160,7 @@ describe("QueryBuilder editor bar", () => {
it
(
"
lets you set 'ID is 10' filter
"
,
async
()
=>
{
const
filterPopover
=
qb
.
find
(
FilterPopover
);
const
filterInput
=
filterPopover
.
find
(
"
textarea
"
);
const
filterInput
=
filterPopover
.
find
(
"
input
"
);
setInputValue
(
filterInput
,
"
10
"
)
const
addFilterButton
=
filterPopover
.
find
(
'
button[children="Add filter"]
'
)
...
...
@@ -192,25 +174,6 @@ describe("QueryBuilder editor bar", () => {
expect
(
filterWidget
.
text
()).
toBe
(
"
ID is equal to10
"
);
})
it
(
"
lets you update the filter to 'ID is 10 or 11'
"
,
async
()
=>
{
const
filterWidget
=
qb
.
find
(
FilterWidget
);
click
(
filterWidget
.
find
(
FieldName
))
const
filterPopover
=
qb
.
find
(
FilterPopover
);
const
filterInput
=
filterPopover
.
find
(
"
textarea
"
);
// Intentionally use a value with lots of extra spaces
setInputValue
(
filterInput
,
"
10, 11
"
)
const
addFilterButton
=
filterPopover
.
find
(
'
button[children="Update filter"]
'
)
clickButton
(
addFilterButton
);
await
store
.
waitForActions
([
SET_DATASET_QUERY
])
expect
(
qb
.
find
(
FilterPopover
).
length
).
toBe
(
0
);
expect
(
filterWidget
.
text
()).
toBe
(
"
ID is equal to2 selections
"
);
});
it
(
"
lets you update the filter to 'ID is between 1 or 100'
"
,
async
()
=>
{
const
filterWidget
=
qb
.
find
(
FilterWidget
);
click
(
filterWidget
.
find
(
FieldName
))
...
...
@@ -219,11 +182,9 @@ describe("QueryBuilder editor bar", () => {
const
operatorSelector
=
filterPopover
.
find
(
OperatorSelector
);
clickButton
(
operatorSelector
.
find
(
'
button[children="Between"]
'
));
const
betweenInputs
=
filterPopover
.
find
(
"
textarea
"
);
const
betweenInputs
=
filterPopover
.
find
(
"
input
"
);
expect
(
betweenInputs
.
length
).
toBe
(
2
);
expect
(
betweenInputs
.
at
(
0
).
props
().
value
).
toBe
(
"
10, 11
"
);
setInputValue
(
betweenInputs
.
at
(
1
),
"
asdasd
"
)
const
updateFilterButton
=
filterPopover
.
find
(
'
button[children="Update filter"]
'
)
expect
(
updateFilterButton
.
props
().
className
).
toMatch
(
/disabled/
);
...
...
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