mirror of https://github.com/grafana/grafana
Restore Dashboards: Add e2e tests (#92514)
parent
1d5dffc51d
commit
b20017cf8c
@ -0,0 +1,82 @@ |
|||||||
|
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'); |
||||||
|
}; |
@ -0,0 +1,209 @@ |
|||||||
|
{ |
||||||
|
"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 |
||||||
|
} |
Loading…
Reference in new issue