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
9103ff5f
Commit
9103ff5f
authored
7 years ago
by
Atte Keinänen
Browse files
Options
Downloads
Patches
Plain Diff
Add test for location breakout with binning
parent
7ebe6dab
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/src/metabase/query_builder/containers/QueryBuilder.integ.spec.js
+77
-0
77 additions, 0 deletions
...abase/query_builder/containers/QueryBuilder.integ.spec.js
with
77 additions
and
0 deletions
frontend/src/metabase/query_builder/containers/QueryBuilder.integ.spec.js
+
77
−
0
View file @
9103ff5f
...
...
@@ -457,6 +457,7 @@ describe("QueryBuilder", () => {
// Get the binning
const
results
=
getQueryResults
(
store
.
getState
())[
0
]
const
breakoutBinningInfo
=
results
.
data
.
cols
[
0
].
binning_info
;
expect
(
breakoutBinningInfo
.
binning_strategy
).
toBe
(
"
num-bins
"
);
expect
(
breakoutBinningInfo
.
bin_width
).
toBe
(
20
);
expect
(
breakoutBinningInfo
.
num_bins
).
toBe
(
8
);
})
...
...
@@ -482,6 +483,7 @@ describe("QueryBuilder", () => {
expect
(
qb
.
find
(
"
.ShownRowCount
"
).
text
()).
toBe
(
"
Showing 95 rows
"
);
const
results
=
getQueryResults
(
store
.
getState
())[
0
]
const
breakoutBinningInfo
=
results
.
data
.
cols
[
0
].
binning_info
;
expect
(
breakoutBinningInfo
.
binning_strategy
).
toBe
(
"
num-bins
"
);
expect
(
breakoutBinningInfo
.
bin_width
).
toBe
(
1
);
expect
(
breakoutBinningInfo
.
num_bins
).
toBe
(
100
);
})
...
...
@@ -503,7 +505,82 @@ describe("QueryBuilder", () => {
// We just want to see that there are a lot more rows than there would be if a binning was active
expect
(
qb
.
find
(
"
.ShownRowCount
"
).
text
()).
toBe
(
"
Showing first 2,000 rows
"
);
const
results
=
getQueryResults
(
store
.
getState
())[
0
]
expect
(
results
.
data
.
cols
[
0
].
binning_info
).
toBe
(
undefined
);
});
})
describe
(
"
for grouping by Latitude location field through Users FK in Orders table
"
,
async
()
=>
{
let
store
=
null
;
let
qb
=
null
;
beforeAll
(
async
()
=>
{
({
store
,
qb
}
=
await
initQbWithOrdersTable
());
})
it
(
"
lets you group by Latitude with the default binning option
"
,
async
()
=>
{
const
breakoutSection
=
qb
.
find
(
'
.GuiBuilder-groupedBy
'
);
const
addBreakoutButton
=
breakoutSection
.
find
(
'
.AddButton
'
);
addBreakoutButton
.
simulate
(
"
click
"
);
const
breakoutPopover
=
breakoutSection
.
find
(
"
#BreakoutPopover
"
)
const
userSectionButton
=
breakoutPopover
.
find
(
FieldList
).
find
(
'
h3[children="User"]
'
)
expect
(
userSectionButton
.
length
).
toBe
(
1
);
userSectionButton
.
simulate
(
"
click
"
);
const
subtotalFieldButton
=
breakoutPopover
.
find
(
FieldList
).
find
(
'
h4[children="Latitude"]
'
)
expect
(
subtotalFieldButton
.
length
).
toBe
(
1
);
subtotalFieldButton
.
simulate
(
'
click
'
);
await
store
.
waitForActions
([
SET_DATASET_QUERY
])
const
breakoutWidget
=
qb
.
find
(
BreakoutWidget
).
first
();
expect
(
breakoutWidget
.
text
()).
toBe
(
"
Latitude: Auto binned
"
);
});
it
(
"
produces correct results for default binning option
"
,
async
()
=>
{
// Run the raw data query
qb
.
find
(
RunButton
).
simulate
(
"
click
"
);
await
store
.
waitForActions
([
QUERY_COMPLETED
]);
expect
(
qb
.
find
(
"
.ShownRowCount
"
).
text
()).
toBe
(
"
Showing 18 rows
"
);
const
results
=
getQueryResults
(
store
.
getState
())[
0
]
const
breakoutBinningInfo
=
results
.
data
.
cols
[
0
].
binning_info
;
expect
(
breakoutBinningInfo
.
binning_strategy
).
toBe
(
"
bin-width
"
);
expect
(
breakoutBinningInfo
.
bin_width
).
toBe
(
10
);
expect
(
breakoutBinningInfo
.
num_bins
).
toBe
(
18
);
})
it
(
"
lets you group by Latitude with the 'Bin every 1 degree'
"
,
async
()
=>
{
const
breakoutWidget
=
qb
.
find
(
BreakoutWidget
).
first
();
breakoutWidget
.
find
(
FieldName
).
children
().
first
().
simulate
(
"
click
"
)
const
breakoutPopover
=
qb
.
find
(
"
#BreakoutPopover
"
)
const
subtotalFieldButton
=
breakoutPopover
.
find
(
FieldList
).
find
(
'
.List-item--selected h4[children="Auto binned"]
'
)
expect
(
subtotalFieldButton
.
length
).
toBe
(
1
);
subtotalFieldButton
.
simulate
(
'
click
'
);
qb
.
find
(
DimensionPicker
).
find
(
'
a[children="Bin every 1 degree"]
'
).
simulate
(
"
click
"
);
await
store
.
waitForActions
([
SET_DATASET_QUERY
])
expect
(
breakoutWidget
.
text
()).
toBe
(
"
Latitude: 1°
"
);
});
it
(
"
produces correct results for 'Bin every 1 degree'
"
,
async
()
=>
{
// Run the raw data query
store
.
resetDispatchedActions
();
qb
.
find
(
RunButton
).
simulate
(
"
click
"
);
await
store
.
waitForActions
([
QUERY_COMPLETED
]);
expect
(
qb
.
find
(
"
.ShownRowCount
"
).
text
()).
toBe
(
"
Showing 180 rows
"
);
const
results
=
getQueryResults
(
store
.
getState
())[
0
]
const
breakoutBinningInfo
=
results
.
data
.
cols
[
0
].
binning_info
;
expect
(
breakoutBinningInfo
.
binning_strategy
).
toBe
(
"
bin-width
"
);
expect
(
breakoutBinningInfo
.
bin_width
).
toBe
(
1
);
expect
(
breakoutBinningInfo
.
num_bins
).
toBe
(
180
);
})
});
})
});
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