Skip to content

Commit

Permalink
tests: rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
crssnd committed Sep 15, 2023
1 parent aef1310 commit c5f0ac8
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 122 deletions.
121 changes: 0 additions & 121 deletions tests/common/cypress/support/lib.js

This file was deleted.

45 changes: 45 additions & 0 deletions tests/cypress.support.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,3 +127,48 @@ Cypress.Commands.add("dexStaticLogin", function() {
cy.contains("Login")
.click()
})

// Available as cy.staticLogin("username", "password expression", "url for login", "path to test after login", "session cookie name")
Cypress.Commands.add('staticLogin', (username, passwordExpression, loginUrl, landingPath, cookieName) => {
cy.session([username, passwordExpression, loginUrl, landingPath, cookieName], () => {
cy.visit(loginUrl)
// ToDo the username label should be configurable
cy.get('input[name=user]').type(username)

cy.yqSecrets(passwordExpression)
.then(password => {
// {enter} causes the form to submit
// ToDo the password label should be configurable
cy.get('input[name=password]').type(`${password}{enter}`, { log: false })
})
// we get some network errors at this step, let's see if wait fixes that
cy.wait(5000)
cy.url().should('include', landingPath)
},
{
validate() {
cy.getCookie(cookieName).should('exist')
},
cacheAcrossSpecs: true,
}
)
})

// Available as cy.testGrafanaDashboard("baseUrl", "the names of the Grafana dashboard", "the no of completed api req to wait")
Cypress.Commands.add('testGrafanaDashboard', (baseUrl, dashboardName, requestsToWait) => {
cy.intercept("/api/**").as("api")

cy.visit(baseUrl + '/dashboards')
// used to view and load as much of the dashboard as possible
cy.viewport(2560, 2160)

cy.get('[data-testid="data-testid Folder header General"]').click()
cy.get(`[data-testid="data-testid Dashboard search item ${dashboardName}"]`).click()
// ToDo: expand all rows
cy.wait(Array(requestsToWait).fill('@api'))
// not really best practices to target objects by id
cy.get('[id="var-datasource"]').should('exist').and('contain', 'default')
cy.get('[id="var-cluster"]').should('exist')
// some dashboards will contain "No data" because an overwrite for NaN or Null doesn't exist
cy.contains('No data').should('not.exist')
})
1 change: 0 additions & 1 deletion tests/end-to-end/grafana-dashboards.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
describe("grafana-admin dashboards e2e", function() {
before(function() {
cy.yq("sc", "\"https://\" + .grafana.ops.subdomain + \".\" + .global.opsDomain")
.its("stdout")
.should("not.contain", "null")
.as('baseUrl')
})
Expand Down

0 comments on commit c5f0ac8

Please sign in to comment.