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
813bb1f5
Unverified
Commit
813bb1f5
authored
3 years ago
by
Nemanja Glumac
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Add initial set of tests around SQL dashboard ID filters (#17607)
parent
e913ee90
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/test/metabase/scenarios/dashboard-filters/dashboard-filters-sql-id.cy.spec.js
+127
-0
127 additions, 0 deletions
...ios/dashboard-filters/dashboard-filters-sql-id.cy.spec.js
with
127 additions
and
0 deletions
frontend/test/metabase/scenarios/dashboard-filters/dashboard-filters-sql-id.cy.spec.js
0 → 100644
+
127
−
0
View file @
813bb1f5
import
{
restore
,
popover
,
mockSessionProperty
,
filterWidget
,
editDashboard
,
saveDashboard
,
setFilter
,
}
from
"
__support__/e2e/cypress
"
;
import
{
SAMPLE_DATASET
}
from
"
__support__/e2e/cypress_sample_dataset
"
;
import
{
addWidgetStringFilter
}
from
"
../native-filters/helpers/e2e-field-filter-helpers
"
;
const
{
ORDERS
}
=
SAMPLE_DATASET
;
describe
(
"
scenarios > dashboard > filters > SQL > ID
"
,
()
=>
{
beforeEach
(()
=>
{
restore
();
cy
.
signInAsAdmin
();
mockSessionProperty
(
"
field-filter-operators-enabled?
"
,
true
);
});
describe
(
"
should work for the primary key
"
,
()
=>
{
beforeEach
(()
=>
{
prepareDashboardWithFilterConnectedTo
(
ORDERS
.
ID
);
});
it
(
"
when set through the filter widget
"
,
()
=>
{
saveDashboard
();
filterWidget
().
click
();
addWidgetStringFilter
(
"
15
"
);
cy
.
get
(
"
.Card
"
).
within
(()
=>
{
cy
.
findByText
(
"
114.42
"
);
});
});
it
(
"
when set as the default filter
"
,
()
=>
{
cy
.
findByText
(
"
Default value
"
)
.
next
()
.
click
();
addWidgetStringFilter
(
"
15
"
);
saveDashboard
();
cy
.
get
(
"
.Card
"
).
within
(()
=>
{
cy
.
findByText
(
"
114.42
"
);
});
});
});
describe
(
"
should work for the foreign key
"
,
()
=>
{
beforeEach
(()
=>
{
prepareDashboardWithFilterConnectedTo
(
ORDERS
.
USER_ID
);
});
it
(
"
when set through the filter widget
"
,
()
=>
{
saveDashboard
();
filterWidget
().
click
();
addWidgetStringFilter
(
"
4
"
);
cy
.
get
(
"
.Card
"
).
within
(()
=>
{
cy
.
findByText
(
"
47.68
"
);
});
});
it
(
"
when set as the default filter
"
,
()
=>
{
cy
.
findByText
(
"
Default value
"
)
.
next
()
.
click
();
addWidgetStringFilter
(
"
4
"
);
saveDashboard
();
cy
.
get
(
"
.Card
"
).
within
(()
=>
{
cy
.
findByText
(
"
47.68
"
);
});
});
});
});
function
prepareDashboardWithFilterConnectedTo
(
rowId
)
{
const
questionDetails
=
{
name
:
"
SQL with ID filter
"
,
native
:
{
query
:
"
select * from ORDERS where {{filter}}
"
,
"
template-tags
"
:
{
filter
:
{
id
:
"
3ff86eea-2559-5ab7-af10-e532a54661c5
"
,
name
:
"
filter
"
,
"
display-name
"
:
"
Filter
"
,
type
:
"
dimension
"
,
dimension
:
[
"
field
"
,
rowId
,
null
],
"
widget-type
"
:
"
id
"
,
default
:
null
,
},
},
},
};
cy
.
createNativeQuestionAndDashboard
({
questionDetails
}).
then
(
({
body
:
{
id
,
card_id
,
dashboard_id
}
})
=>
{
cy
.
intercept
(
"
POST
"
,
`/api/card/
${
card_id
}
/query`
).
as
(
"
cardQuery
"
);
cy
.
visit
(
`/question/
${
card_id
}
`
);
// Wait for `result_metadata` to load
cy
.
wait
(
"
@cardQuery
"
);
cy
.
visit
(
`/dashboard/
${
dashboard_id
}
`
);
},
);
editDashboard
();
setFilter
(
"
ID
"
);
cy
.
findByText
(
"
Column to filter on
"
)
.
next
(
"
a
"
)
.
click
();
popover
()
.
contains
(
"
Filter
"
)
.
click
();
}
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