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
9fda6671
Unverified
Commit
9fda6671
authored
2 years ago
by
Nemanja Glumac
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Repro #21581: Normal users can't create first snippet in Enterprise version (#21617)
parent
5d6a58d0
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/test/metabase/scenarios/native/snippets/snippet-permissions.cy.spec.js
+24
-87
24 additions, 87 deletions
.../scenarios/native/snippets/snippet-permissions.cy.spec.js
with
24 additions
and
87 deletions
frontend/test/metabase/scenarios/native/snippets/snippet-permissions.cy.spec.js
+
24
−
87
View file @
9fda6671
...
...
@@ -9,106 +9,41 @@ import {
describeEE
(
"
scenarios > question > snippets
"
,
()
=>
{
beforeEach
(()
=>
{
restore
();
cy
.
signInAsAdmin
();
});
it
(
"
can create a snippet
"
,
()
=>
{
openNativeEditor
();
cy
.
icon
(
"
snippet
"
).
click
();
cy
.
contains
(
"
Create a snippet
"
).
click
();
modal
().
within
(()
=>
{
cy
.
findByLabelText
(
"
Enter some SQL here so you can reuse it later
"
).
type
(
"
SELECT 'a snippet darkly'
"
,
);
cy
.
findByLabelText
(
"
Give your snippet a name
"
).
type
(
"
night snippet
"
);
cy
.
contains
(
"
Save
"
).
click
();
});
cy
.
icon
(
"
play
"
)
.
first
()
.
click
();
cy
.
get
(
"
.ScalarValue
"
).
contains
(
"
a snippet darkly
"
);
});
// Please uncomment "normal" user when #21581 gets fixed
[
"
admin
"
/*"normal"*/
].
forEach
(
user
=>
{
it
(
`
${
user
}
user can create a snippet (metabase#21581)`
,
()
=>
{
cy
.
intercept
(
"
POST
"
,
"
/api/native-query-snippet
"
).
as
(
"
snippetCreated
"
);
it
(
"
can not create a snippet as a user by default
"
,
()
=>
{
// Note that this is expected behavior, but a little weird because
// users have to be granted explicit access.
// See metabase-enterprise#543 for more details
cy
.
signInAsNormalUser
();
cy
.
request
({
method
:
"
POST
"
,
url
:
"
/api/native-query-snippet
"
,
body
:
{
content
:
"
SELECT 'a snippet in light'
"
,
name
:
"
light snippet
"
,
collection_id
:
null
,
},
failOnStatusCode
:
false
,
}).
then
(
resp
=>
{
expect
(
resp
.
status
).
to
.
equal
(
403
);
});
});
cy
.
signIn
(
user
);
// [quarantine] because the popover click action is very flaky.
it
.
skip
(
"
can create a snippet once the admin has granted access
"
,
()
=>
{
// See metabase-enterprise#543 for more details
// This is kind of a UX issue where the admin has to:
// - First create a snippet
// - Then grant All Users access to snippets
openNativeEditor
();
cy
.
icon
(
"
snippet
"
).
click
();
cy
.
contains
(
"
Create a snippet
"
).
click
();
// create snippet via API
cy
.
request
(
"
POST
"
,
"
/api/native-query-snippet
"
,
{
content
:
"
SELECT 'a snippet darkly'
"
,
name
:
"
543 - admin snippet
"
,
collection_id
:
null
,
});
modal
().
within
(()
=>
{
cy
.
findByLabelText
(
"
Enter some SQL here so you can reuse it later
"
,
).
type
(
"
SELECT 1
"
,
{
delay
:
0
});
cy
.
findByLabelText
(
"
Give your snippet a name
"
).
type
(
"
one
"
,
{
delay
:
0
,
});
cy
.
button
(
"
Save
"
).
click
();
});
// Grant access
openNativeEditor
();
cy
.
icon
(
"
snippet
"
).
click
();
cy
.
wait
(
"
@snippetCreated
"
);
cy
.
findByText
(
"
{{snippet: one}}
"
);
cy
.
findByTestId
(
"
sidebar-right
"
)
.
find
(
"
.Icon-ellipsis
"
)
.
click
({
force
:
true
});
popover
().
within
(()
=>
cy
.
findByText
(
"
Change permissions
"
).
click
());
modal
().
within
(()
=>
{
cy
.
findByText
(
"
Permissions for Top folder
"
);
cy
.
contains
(
"
All Users
"
);
cy
.
get
(
"
.ReactVirtualized__Grid .Icon-close
"
)
cy
.
icon
(
"
play
"
)
.
first
()
.
click
();
cy
.
get
(
"
.ScalarValue
"
).
contains
(
1
);
});
// The click action is very flaky, sometimes it doesn't click the right thing
popover
()
.
contains
(
"
Grant Edit access
"
)
.
click
();
modal
()
.
contains
(
"
Save
"
)
.
click
();
// Now the user should be able to create a snippet
cy
.
signInAsNormalUser
();
cy
.
request
({
method
:
"
POST
"
,
url
:
"
/api/native-query-snippet
"
,
body
:
{
content
:
"
SELECT 'a snippet in light'
"
,
name
:
"
543 - user snippet
"
,
collection_id
:
null
,
},
failOnStatusCode
:
false
,
}).
then
(
resp
=>
{
expect
(
resp
.
status
).
to
.
equal
(
200
);
});
cy
.
reload
();
cy
.
icon
(
"
snippet
"
).
click
();
cy
.
contains
(
"
543 - admin snippet
"
);
cy
.
contains
(
"
543 - user snippet
"
);
});
it
(
"
should let you create a snippet folder and move a snippet into it
"
,
()
=>
{
cy
.
signInAsAdmin
();
// create snippet via API
cy
.
request
(
"
POST
"
,
"
/api/native-query-snippet
"
,
{
content
:
"
snippet 1
"
,
...
...
@@ -160,6 +95,8 @@ describeEE("scenarios > question > snippets", () => {
beforeEach
(()
=>
{
cy
.
intercept
(
"
GET
"
,
"
/api/collection/root
"
).
as
(
"
collections
"
);
cy
.
signInAsAdmin
();
cy
.
request
(
"
POST
"
,
"
/api/collection
"
,
{
name
:
"
Snippet Folder
"
,
description
:
null
,
...
...
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