Revert "Restore Dashboards: Add e2e tests (again) (#93214)" (#94003)

This commit is contained in:
Joao Silva 2024-09-30 14:26:16 +01:00 committed by GitHub
parent 6f92fd64ce
commit a45662bf2d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 4 additions and 331 deletions

View File

@ -49,12 +49,4 @@ describe.skip('Dashboard browse', () => {
e2e.flows.confirmDelete();
e2e.pages.BrowseDashboards.table.row('E2E Test - Import Dashboard').should('not.exist');
});
afterEach(() => {
// Permanently delete dashboard
e2e.pages.RecentlyDeleted.visit();
e2e.pages.Search.table.row('E2E Test - Import Dashboard').find('[type="checkbox"]').click({ force: true });
cy.contains('button', 'Delete permanently').click();
e2e.flows.confirmDelete();
});
});

View File

@ -1,82 +0,0 @@
import testDashboard from '../dashboards/TestRestoreDashboard.json';
import { e2e } from '../utils';
describe('Dashboard restore', () => {
beforeEach(() => {
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
});
it('Should delete, restore and permanently delete from the Dashboards page', () => {
e2e.flows.importDashboard(testDashboard, 1000, true);
e2e.pages.Dashboards.visit();
// Delete dashboard
e2e.pages.BrowseDashboards.table
.row('E2E Test - Restore Dashboard')
.find('[type="checkbox"]')
.click({ force: true });
deleteDashboard('Delete');
// Dashboard should appear in Recently Deleted
e2e.pages.RecentlyDeleted.visit();
e2e.pages.Search.table.row('E2E Test - Restore Dashboard').should('exist');
// Restore dashboard
e2e.pages.Search.table.row('E2E Test - Restore Dashboard').find('[type="checkbox"]').click({ force: true });
cy.contains('button', 'Restore').click();
cy.contains('p', 'This action will restore 1 dashboard.').should('be.visible');
e2e.pages.ConfirmModal.delete().click();
e2e.components.Alert.alertV2('success').contains('Dashboard E2E Test - Restore Dashboard restored').should('exist');
// Dashboard should appear in Browse
e2e.pages.Dashboards.visit();
e2e.pages.BrowseDashboards.table.row('E2E Test - Restore Dashboard').should('exist');
// Delete dashboard
e2e.pages.BrowseDashboards.table
.row('E2E Test - Restore Dashboard')
.find('[type="checkbox"]')
.click({ force: true });
deleteDashboard('Delete');
// Permanently delete dashboard
permanentlyDeleteDashboard();
});
it('Should delete, restore and permanently delete from the Dashboard settings', () => {
e2e.flows.importDashboard(testDashboard, 1000, true);
e2e.flows.openDashboard({ uid: '355ac6c2-8a12-4469-8b99-4750eb8d0966' });
e2e.pages.Dashboard.DashNav.settingsButton().click();
deleteDashboard('Delete dashboard');
// Permanently delete dashboard
permanentlyDeleteDashboard();
});
});
const deleteDashboard = (buttonName: string) => {
cy.contains('button', buttonName).click();
e2e.flows.confirmDelete();
e2e.components.Alert.alertV2('success')
.contains('Dashboard E2E Test - Restore Dashboard moved to Recently deleted')
.should('exist');
e2e.pages.BrowseDashboards.table.row('E2E Test - Restore Dashboard').should('not.exist');
};
const permanentlyDeleteDashboard = () => {
// Permanently delete dashboard
e2e.pages.RecentlyDeleted.visit();
e2e.pages.Search.table.row('E2E Test - Restore Dashboard').find('[type="checkbox"]').click({ force: true });
cy.contains('button', 'Delete permanently').click();
cy.contains('p', 'This action will delete 1 dashboard.').should('be.visible');
e2e.flows.confirmDelete();
e2e.components.Alert.alertV2('success').contains('Dashboard E2E Test - Restore Dashboard deleted').should('exist');
// Dashboard should not appear in Recently Deleted or Browse
e2e.pages.Search.table.row('E2E Test - Restore Dashboard').should('not.exist');
e2e.pages.Dashboards.visit();
e2e.pages.BrowseDashboards.table.row('E2E Test - Restore Dashboard').should('not.exist');
};

View File

@ -1,209 +0,0 @@
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"target": {
"limit": 100,
"matchAny": false,
"tags": [],
"type": "dashboard"
},
"type": "dashboard"
}
]
},
"editable": true,
"gnetId": null,
"graphTooltip": 0,
"id": 322,
"links": [],
"liveNow": false,
"panels": [
{
"datasource": null,
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 0
},
"id": 6,
"options": {
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"showThresholdLabels": false,
"showThresholdMarkers": true,
"text": {}
},
"pluginVersion": "8.3.0-pre",
"title": "Gauge Example",
"type": "gauge"
},
{
"datasource": null,
"fieldConfig": {
"defaults": {
"color": {
"mode": "thresholds"
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 8,
"w": 12,
"x": 0,
"y": 8
},
"id": 4,
"options": {
"colorMode": "value",
"graphMode": "area",
"justifyMode": "auto",
"orientation": "auto",
"reduceOptions": {
"calcs": ["lastNotNull"],
"fields": "",
"values": false
},
"text": {},
"textMode": "auto"
},
"pluginVersion": "8.3.0-pre",
"title": "Stat",
"type": "stat"
},
{
"datasource": null,
"fieldConfig": {
"defaults": {
"color": {
"mode": "palette-classic"
},
"custom": {
"axisLabel": "",
"axisPlacement": "auto",
"barAlignment": 0,
"drawStyle": "line",
"fillOpacity": 0,
"gradientMode": "none",
"hideFrom": {
"legend": false,
"tooltip": false,
"viz": false
},
"lineInterpolation": "linear",
"lineWidth": 1,
"pointSize": 5,
"scaleDistribution": {
"type": "linear"
},
"showPoints": "auto",
"spanNulls": false,
"stacking": {
"group": "A",
"mode": "none"
},
"thresholdsStyle": {
"mode": "off"
}
},
"mappings": [],
"thresholds": {
"mode": "absolute",
"steps": [
{
"color": "green",
"value": null
},
{
"color": "red",
"value": 80
}
]
}
},
"overrides": []
},
"gridPos": {
"h": 9,
"w": 12,
"x": 0,
"y": 16
},
"id": 2,
"options": {
"legend": {
"calcs": [],
"displayMode": "list",
"placement": "bottom"
},
"tooltip": {
"mode": "single"
}
},
"title": "Time series example",
"type": "timeseries"
}
],
"refresh": false,
"schemaVersion": 31,
"tags": [],
"templating": {
"list": []
},
"time": {
"from": "2021-09-01T04:00:00.000Z",
"to": "2021-09-15T04:00:00.000Z"
},
"timepicker": {},
"timezone": "",
"title": "E2E Test - Restore Dashboard",
"uid": "355ac6c2-8a12-4469-8b99-4750eb8d0966",
"version": 4
}

View File

@ -29,14 +29,6 @@ export const deleteDashboard = ({ quick = false, title, uid }: DeleteDashboardCo
const quickDelete = (uid: string) => {
cy.request('DELETE', fromBaseUrl(`/api/dashboards/uid/${uid}`));
cy.window().then((win: Cypress.AUTWindow) => {
if (
win.grafanaBootData.settings.featureToggles.dashboardRestore &&
win.grafanaBootData.settings.featureToggles.dashboardRestoreUI
) {
cy.request('DELETE', fromBaseUrl(`/api/dashboards/uid/${uid}/trash`));
}
});
};
const uiDelete = (uid: string, title: string) => {

View File

@ -57,7 +57,6 @@ export const Pages = {
navV2: 'data-testid Dashboard navigation',
publicDashboardTag: 'data-testid public dashboard tag',
shareButton: 'data-testid share-button',
settingsButton: 'data-testid settings-button',
scrollContainer: 'data-testid Dashboard canvas scroll container',
newShareButton: {
container: 'data-testid new share button',
@ -240,9 +239,6 @@ export const Pages = {
*/
dashboards: (title: string) => `Dashboard search item ${title}`,
},
RecentlyDeleted: {
url: '/dashboard/recently-deleted',
},
SaveDashboardAsModal: {
newName: 'Save dashboard title field',
save: 'Save dashboard button',
@ -407,10 +403,6 @@ export const Pages = {
FolderView: {
url: '/?search=open&layout=folders',
},
table: {
body: 'data-testid search-table',
row: (name: string) => `data-testid search row ${name}`,
},
},
PublicDashboards: {
ListItem: {

View File

@ -326,7 +326,6 @@ export const DashNav = memo<Props>((props) => {
<ToolbarButton
tooltip={t('dashboard.toolbar.settings', 'Dashboard settings')}
icon="cog"
data-testid={e2eSelectors.pages.Dashboard.DashNav.settingsButton}
onClick={onOpenSettings}
key="button-settings"
/>

View File

@ -7,7 +7,6 @@ import InfiniteLoader from 'react-window-infinite-loader';
import { Observable } from 'rxjs';
import { Field, GrafanaTheme2 } from '@grafana/data';
import { selectors } from '@grafana/e2e-selectors';
import { TableCellHeight } from '@grafana/schema';
import { useStyles2, useTheme2 } from '@grafana/ui';
import { TableCell } from '@grafana/ui/src/components/Table/TableCell';
@ -138,13 +137,9 @@ export const SearchResultsTable = React.memo(
className += ' ' + styles.selectedRow;
}
const { key, ...rowProps } = row.getRowProps({ style });
return (
<div
key={key}
{...rowProps}
className={className}
data-testid={selectors.pages.Search.table.row(response.view.fields.name.values[rowIndex])}
>
<div key={key} {...rowProps} className={className}>
{row.cells.map((cell: Cell, index: number) => {
return (
<TableCell
@ -165,7 +160,6 @@ export const SearchResultsTable = React.memo(
rows,
prepareRow,
response.view.fields.url?.values,
response.view.fields.name?.values,
highlightIndex,
styles,
tableStyles,
@ -179,12 +173,7 @@ export const SearchResultsTable = React.memo(
}
return (
<div
{...getTableProps()}
aria-label="Search results table"
role="table"
data-testid={selectors.pages.Search.table.body}
>
<div {...getTableProps()} aria-label="Search results table" role="table">
{headerGroups.map((headerGroup) => {
const { key, ...headerGroupProps } = headerGroup.getHeaderGroupProps({
style: { width },

View File

@ -4,7 +4,7 @@ content_security_policy = true
content_security_policy_template = """require-trusted-types-for 'script'; script-src 'self' 'unsafe-eval' 'unsafe-inline' 'strict-dynamic' $NONCE;object-src 'none';font-src 'self';style-src 'self' 'unsafe-inline' blob:;img-src * data:;base-uri 'self';connect-src 'self' grafana.com ws://$ROOT_PATH wss://$ROOT_PATH;manifest-src 'self';media-src 'none';form-action 'self';"""
[feature_toggles]
enable = publicDashboards, dashboardRestore, dashboardRestoreUI
enable = publicDashboards
[plugins]
allow_loading_unsigned_plugins=grafana-extensionstest-app,grafana-extensionexample1-app,grafana-extensionexample2-app,