Skip to content

Commit 014461b

Browse files
committed
Remove created datasource as tests' teardown
A new function is introduced in the 'helpers' module to remove the previously-created datasource. This is included in the teardown inside the tests' module.
1 parent d4e336e commit 014461b

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tests/cypress/e2e/helpers.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,20 @@ export function addCmkDatasource(
4646
cy.contains('Data source is working').should('be.visible');
4747
}
4848

49+
export function rmCmkDatasource() {
50+
// Remove the previously-created datasource as teardown process.
51+
// This makes sure the tests use the newly generated datasource in each execution.
52+
// Important especially when running the tests locally if docker images are up during multiple tests' executions.
53+
54+
cy.visit('/datasources/');
55+
56+
cy.get('[class="page-container page-body"]').contains('Checkmk').click();
57+
cy.contains('Delete').click();
58+
cy.get('button[aria-label="Confirm Modal Danger Button"]').click();
59+
60+
cy.contains('No data sources defined').should('be.visible');
61+
}
62+
4963
export function saveDashboard(dashboardID: string) {
5064
cy.get('button[title="Apply changes and save dashboard"]').contains('Save').click();
5165
cy.get('input[aria-label="Save dashboard title field"]').type(' ' + dashboardID);

tests/cypress/e2e/spec.cy.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
inputTemplateSelector,
2121
loginGrafana,
2222
panelContentSelector,
23+
rmCmkDatasource,
2324
saveDashboard,
2425
} from './helpers';
2526

@@ -174,6 +175,8 @@ describe('e2e tests', () => {
174175
});
175176

176177
after(function () {
178+
rmCmkDatasource();
179+
177180
deleteCmkHost(hostName0);
178181
deleteCmkHost(hostName1);
179182

0 commit comments

Comments
 (0)