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
df2b2589
Unverified
Commit
df2b2589
authored
2 years ago
by
Alexander Polyankin
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Refactor pinned items e2e tests (#23462)
parent
d284f41e
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
frontend/test/metabase/scenarios/collections/collection-pinned-overview.cy.spec.js
+95
-96
95 additions, 96 deletions
...enarios/collections/collection-pinned-overview.cy.spec.js
with
95 additions
and
96 deletions
frontend/test/metabase/scenarios/collections/collection-pinned-overview.cy.spec.js
+
95
−
96
View file @
df2b2589
import
{
popover
,
restore
}
from
"
__support__/e2e/cypress
"
;
const
DASHBOARD_
ITEM_
NAME
=
"
Orders in a dashboard
"
;
const
CARD_ITEM
_NAME
=
"
Orders, Count
"
;
const
MODE
_ITEM
_NAME
=
"
Orders
"
;
const
DASHBOARD_NAME
=
"
Orders in a dashboard
"
;
const
QUESTION
_NAME
=
"
Orders, Count
"
;
const
MODE
L
_NAME
=
"
Orders
"
;
describe
(
"
scenarios > collection pinned items overview
"
,
()
=>
{
beforeEach
(()
=>
{
restore
();
cy
.
signInAsAdmin
();
cy
.
intercept
(
"
POST
"
,
`/api/card/*/query`
).
as
(
"
cardQuery
"
);
cy
.
intercept
(
"
GET
"
,
"
/api/collection/root/items?pinned_state=is_pinned*
"
,
).
as
(
"
pinnedItemsGET
"
);
cy
.
intercept
(
"
POST
"
,
`/api/card/*/query`
).
as
(
"
getCardQuery
"
);
cy
.
intercept
(
"
GET
"
,
"
/api/collection/*/items?pinned_state=is_pinned*
"
).
as
(
"
getPinnedItems
"
,
);
});
it
(
"
should let the user pin items
"
,
()
=>
{
// Turn question 1 into a model
cy
.
request
(
"
PUT
"
,
"
/api/card/1
"
,
{
dataset
:
true
});
cy
.
visit
(
"
/collection/root
"
);
cy
.
wait
(
"
@pinnedItemsGET
"
);
it
(
"
should be able to pin a dashboard
"
,
()
=>
{
openRootCollection
();
openUnpinnedItemMenu
(
DASHBOARD_NAME
);
popover
().
within
(()
=>
cy
.
findByText
(
"
Pin this
"
).
click
());
cy
.
wait
(
"
@getPinnedItems
"
);
// pin a dashboard
pinItem
(
DASHBOARD_ITEM_NAME
);
cy
.
wait
(
"
@pinnedItemsGET
"
);
// ensure the dashboard card is showing in the pinned section
cy
.
findByTestId
(
"
pinned-items
"
).
within
(()
=>
{
cy
.
icon
(
"
dashboard
"
);
cy
.
findByText
(
"
A dashboard
"
);
// click on the card to navigate to the dashboard
cy
.
findByText
(
DASHBOARD_ITEM_NAME
).
click
();
getPinnedSection
().
within
(()
=>
{
cy
.
icon
(
"
dashboard
"
).
should
(
"
be.visible
"
);
cy
.
findByText
(
"
A dashboard
"
).
should
(
"
be.visible
"
);
cy
.
findByText
(
DASHBOARD_NAME
).
click
();
cy
.
url
().
should
(
"
include
"
,
"
/dashboard/1
"
);
});
});
cy
.
visit
(
"
/collection/root
"
);
cy
.
wait
(
"
@pinnedItemsGET
"
);
// pin a card
pinItem
(
CARD_ITEM_NAME
);
cy
.
wait
([
"
@pinnedItemsGET
"
,
"
@cardQuery
"
]);
it
(
"
should be able to pin a question
"
,
()
=>
{
openRootCollection
();
openUnpinnedItemMenu
(
QUESTION_NAME
);
popover
().
within
(()
=>
cy
.
findByText
(
"
Pin this
"
).
click
());
cy
.
wait
([
"
@getPinnedItems
"
,
"
@getCardQuery
"
]);
// ensure the card visualization is showing in the pinned section
cy
.
findByTestId
(
"
pinned-items
"
).
within
(()
=>
{
cy
.
findByText
(
"
18,760
"
);
cy
.
findByText
(
CARD_ITEM_NAME
).
click
();
getPinnedSection
().
within
(()
=>
{
cy
.
findByText
(
"
18,760
"
).
should
(
"
be.visible
"
);
cy
.
findByText
(
QUESTION_NAME
).
click
();
cy
.
url
().
should
(
"
include
"
,
"
/question/2
"
);
});
});
it
(
"
should be able to pin a model
"
,
()
=>
{
cy
.
request
(
"
PUT
"
,
"
/api/card/1
"
,
{
dataset
:
true
});
cy
.
visit
(
"
/collection/root
"
);
cy
.
wait
([
"
@pinnedItemsGET
"
,
"
@cardQuery
"
]);
openRootCollection
();
openUnpinnedItemMenu
(
MODEL_NAME
);
popover
().
within
(()
=>
cy
.
findByText
(
"
Pin this
"
).
click
());
cy
.
wait
(
"
@getPinnedItems
"
);
// pin a model
pinItem
(
MODE_ITEM_NAME
);
cy
.
wait
(
"
@pinnedItemsGET
"
);
// ensure the model card is showing in the pinned section
cy
.
findByTestId
(
"
pinned-items
"
).
within
(()
=>
{
cy
.
findByText
(
MODE_ITEM_NAME
);
cy
.
icon
(
"
model
"
);
getPinnedSection
().
within
(()
=>
{
cy
.
icon
(
"
model
"
).
should
(
"
be.visible
"
);
cy
.
findByText
(
MODEL_NAME
).
should
(
"
be.visible
"
);
cy
.
findByText
(
"
A model
"
).
click
();
cy
.
url
().
should
(
"
include
"
,
"
/model/1
"
);
});
});
describe
(
"
pinned item actions
"
,
()
=>
{
beforeEach
(()
=>
{
// pin a dashboard using the API
cy
.
request
(
"
PUT
"
,
"
/api/dashboard/1
"
,
{
collection_position
:
1
,
});
cy
.
visit
(
"
/collection/root
"
);
cy
.
wait
(
"
@pinnedItemsGET
"
);
// open the action menu
cy
.
findByTestId
(
"
pinned-items
"
).
within
(()
=>
{
cy
.
icon
(
"
dashboard
"
);
// the menu icon is hidden until the user hovers their mouse over the card
cy
.
icon
(
"
ellipsis
"
).
click
({
force
:
true
});
});
});
it
(
"
should be able to unpin a pinned dashboard
"
,
()
=>
{
cy
.
request
(
"
PUT
"
,
"
/api/dashboard/1
"
,
{
collection_position
:
1
});
it
(
"
should be able to unpin a pinned item
"
,
()
=>
{
popover
().
within
(()
=>
{
cy
.
findByText
(
"
Unpin
"
).
click
();
}
);
openRootCollection
();
openPinnedItemMenu
(
DASHBOARD_NAME
);
popover
().
within
(()
=>
cy
.
findByText
(
"
Unpin
"
).
click
()
)
;
cy
.
wait
(
"
@getPinnedItems
"
);
// verify that the item is no longer in the pinned section
cy
.
wait
(
"
@pinnedItemsGET
"
);
cy
.
findByTestId
(
"
pinned-items
"
).
should
(
"
not.exist
"
);
});
getPinnedSection
().
should
(
"
not.exist
"
);
});
it
(
"
should be able to move a pinned item
"
,
()
=>
{
popover
().
within
(()
=>
{
cy
.
findByText
(
"
Move
"
).
click
();
});
it
(
"
should be able to move a pinned dashboard
"
,
()
=>
{
cy
.
request
(
"
PUT
"
,
"
/api/dashboard/1
"
,
{
collection_position
:
1
});
// verify that the move modal is showing
cy
.
findByText
(
`Move "
${
DASHBOARD_ITEM_NAME
}
"?`
);
}
);
openRootCollection
();
openPinnedItemMenu
(
DASHBOARD_NAME
);
popover
().
within
(()
=>
cy
.
findByText
(
"
Move
"
).
click
()
);
it
(
"
should be able to duplicate a pinned item
"
,
()
=>
{
popover
().
within
(()
=>
{
cy
.
findByText
(
"
Duplicate
"
).
click
();
});
cy
.
findByText
(
`Move "
${
DASHBOARD_NAME
}
"?`
).
should
(
"
be.visible
"
);
});
// verify that the duplicate modal is showing
cy
.
findByText
(
`Duplicate "
${
DASHBOARD_ITEM_NAME
}
"`
);
});
it
(
"
should be able to duplicate a pinned dashboard
"
,
()
=>
{
cy
.
request
(
"
PUT
"
,
"
/api/dashboard/1
"
,
{
collection_position
:
1
});
it
(
"
should be able to archive a pinned item
"
,
()
=>
{
popover
().
within
(()
=>
{
cy
.
findByText
(
"
Archive
"
).
click
();
});
openRootCollection
();
openPinnedItemMenu
(
DASHBOARD_NAME
);
popover
().
within
(()
=>
cy
.
findByText
(
"
Duplicate
"
).
click
());
// verify that the item is no longer on the page
cy
.
wait
(
"
@pinnedItemsGET
"
);
cy
.
findByTestId
(
"
pinned-items
"
).
should
(
"
not.exist
"
);
cy
.
findByText
(
DASHBOARD_ITEM_NAME
).
should
(
"
not.exist
"
);
});
cy
.
findByText
(
`Duplicate "
${
DASHBOARD_NAME
}
"`
).
should
(
"
be.visible
"
);
});
it
(
"
should be able to archive a pinned dashboard
"
,
()
=>
{
cy
.
request
(
"
PUT
"
,
"
/api/dashboard/1
"
,
{
collection_position
:
1
});
openRootCollection
();
openPinnedItemMenu
(
DASHBOARD_NAME
);
popover
().
within
(()
=>
cy
.
findByText
(
"
Archive
"
).
click
());
cy
.
wait
(
"
@getPinnedItems
"
);
getPinnedSection
().
should
(
"
not.exist
"
);
cy
.
findByText
(
DASHBOARD_NAME
).
should
(
"
not.exist
"
);
});
});
const
pinItem
=
name
=>
{
cy
.
findByText
(
name
)
.
closest
(
"
tr
"
)
.
within
(()
=>
cy
.
icon
(
"
ellipsis
"
).
click
());
const
getPinnedSection
=
()
=>
{
return
cy
.
findByTestId
(
"
pinned-items
"
);
};
const
getUnpinnedSection
=
()
=>
{
return
cy
.
findByRole
(
"
table
"
);
};
const
openRootCollection
=
()
=>
{
cy
.
visit
(
"
/collection/root
"
);
cy
.
wait
(
"
@getPinnedItems
"
);
};
popover
().
within
(()
=>
cy
.
icon
(
"
pin
"
).
click
());
const
openPinnedItemMenu
=
name
=>
{
getPinnedSection
().
within
(()
=>
{
cy
.
findByText
(
name
)
.
closest
(
"
a
"
)
.
within
(()
=>
cy
.
icon
(
"
ellipsis
"
).
click
({
force
:
true
}));
});
};
const
openUnpinnedItemMenu
=
name
=>
{
getUnpinnedSection
().
within
(()
=>
{
cy
.
findByText
(
name
)
.
closest
(
"
tr
"
)
.
within
(()
=>
cy
.
icon
(
"
ellipsis
"
).
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