mirror of https://github.com/grafana/grafana
ReturnToPrevious: Add e2e test (#83115)
* feat: add incomplete unit test * refactor: add idea for unit test * feat: create new e2e test * feat: add some steps * feat: add comment * feat: complete prep work * feat: complete clean up * rebase * feat: add more steps to test flow * refactor: remove unit test * refactor: clean up * refactor: create a provisioned alert rule * refactor: change location and content * refactor: e2e test * refactor: betterer * refactor: move provisioned alert rule * refactor: make provisioning file available remote * refactor: clean up test * refactor: move provisioned alert rule * refactor: remove wait() * feat: restructure first test and add more tests * feat: add another provisioned alert rule * feat: add a new test * feat: complete new test * refactor: replace data-testid in alert rules * refactor: replace data-testid * refactor: fix tests for drone * refactor: fix third test after review * refactor: fix last test * temp * refactor: improve some things * refactor: adjust unit tests * refactor: remove assertions for alert rule details view * refactor: remove assertions * refactor: add check for button text * refactor: remove session storage * refactor: apply changes from code review * refactor: add codeowner * refactor * refactor * refactor: clean up * refactor: clean up * refactor: clean up * refactor: increase pa11y threshold for /alerting/listpull/84849/head
parent
9298a5fcb5
commit
d8a116e696
@ -0,0 +1,158 @@ |
|||||||
|
apiVersion: 1 |
||||||
|
groups: |
||||||
|
- orgId: 1 |
||||||
|
name: testEvaluationGroup |
||||||
|
folder: gdev dashboards |
||||||
|
interval: 5m |
||||||
|
rules: |
||||||
|
- uid: bddn0v6f1kgzkc |
||||||
|
title: e2e-ReturnToPrevious-test |
||||||
|
condition: C |
||||||
|
data: |
||||||
|
- refId: A |
||||||
|
relativeTimeRange: |
||||||
|
from: 600 |
||||||
|
to: 0 |
||||||
|
datasourceUid: PD8C576611E62080A |
||||||
|
model: |
||||||
|
intervalMs: 1000 |
||||||
|
maxDataPoints: 43200 |
||||||
|
refId: A |
||||||
|
- refId: B |
||||||
|
datasourceUid: __expr__ |
||||||
|
model: |
||||||
|
conditions: |
||||||
|
- evaluator: |
||||||
|
params: [] |
||||||
|
type: gt |
||||||
|
operator: |
||||||
|
type: and |
||||||
|
query: |
||||||
|
params: |
||||||
|
- B |
||||||
|
reducer: |
||||||
|
params: [] |
||||||
|
type: last |
||||||
|
type: query |
||||||
|
datasource: |
||||||
|
type: __expr__ |
||||||
|
uid: __expr__ |
||||||
|
expression: A |
||||||
|
intervalMs: 1000 |
||||||
|
maxDataPoints: 43200 |
||||||
|
reducer: last |
||||||
|
refId: B |
||||||
|
type: reduce |
||||||
|
- refId: C |
||||||
|
datasourceUid: __expr__ |
||||||
|
model: |
||||||
|
conditions: |
||||||
|
- evaluator: |
||||||
|
params: |
||||||
|
- 0 |
||||||
|
type: gt |
||||||
|
operator: |
||||||
|
type: and |
||||||
|
query: |
||||||
|
params: |
||||||
|
- C |
||||||
|
reducer: |
||||||
|
params: [] |
||||||
|
type: last |
||||||
|
type: query |
||||||
|
datasource: |
||||||
|
type: __expr__ |
||||||
|
uid: __expr__ |
||||||
|
expression: B |
||||||
|
intervalMs: 1000 |
||||||
|
maxDataPoints: 43200 |
||||||
|
refId: C |
||||||
|
type: threshold |
||||||
|
dashboardUid: j6T00KRZz |
||||||
|
panelId: 7 |
||||||
|
noDataState: NoData |
||||||
|
execErrState: Error |
||||||
|
for: 5m |
||||||
|
annotations: |
||||||
|
__dashboardUid__: j6T00KRZz |
||||||
|
__panelId__: "7" |
||||||
|
labels: {} |
||||||
|
isPaused: false |
||||||
|
- orgId: 1 |
||||||
|
name: testEvaluationGroup2 |
||||||
|
folder: gdev dashboards |
||||||
|
interval: 10m |
||||||
|
rules: |
||||||
|
- uid: dddyksihq7h1ca |
||||||
|
title: e2e-ReturnToPrevious-test-2 |
||||||
|
condition: C |
||||||
|
data: |
||||||
|
- refId: A |
||||||
|
relativeTimeRange: |
||||||
|
from: 600 |
||||||
|
to: 0 |
||||||
|
datasourceUid: PD8C576611E62080A |
||||||
|
model: |
||||||
|
intervalMs: 1000 |
||||||
|
maxDataPoints: 43200 |
||||||
|
refId: A |
||||||
|
- refId: B |
||||||
|
datasourceUid: __expr__ |
||||||
|
model: |
||||||
|
conditions: |
||||||
|
- evaluator: |
||||||
|
params: [] |
||||||
|
type: gt |
||||||
|
operator: |
||||||
|
type: and |
||||||
|
query: |
||||||
|
params: |
||||||
|
- B |
||||||
|
reducer: |
||||||
|
params: [] |
||||||
|
type: last |
||||||
|
type: query |
||||||
|
datasource: |
||||||
|
type: __expr__ |
||||||
|
uid: __expr__ |
||||||
|
expression: A |
||||||
|
intervalMs: 1000 |
||||||
|
maxDataPoints: 43200 |
||||||
|
reducer: last |
||||||
|
refId: B |
||||||
|
type: reduce |
||||||
|
- refId: C |
||||||
|
datasourceUid: __expr__ |
||||||
|
model: |
||||||
|
conditions: |
||||||
|
- evaluator: |
||||||
|
params: |
||||||
|
- 0 |
||||||
|
type: gt |
||||||
|
operator: |
||||||
|
type: and |
||||||
|
query: |
||||||
|
params: |
||||||
|
- C |
||||||
|
reducer: |
||||||
|
params: [] |
||||||
|
type: last |
||||||
|
type: query |
||||||
|
datasource: |
||||||
|
type: __expr__ |
||||||
|
uid: __expr__ |
||||||
|
expression: B |
||||||
|
intervalMs: 1000 |
||||||
|
maxDataPoints: 43200 |
||||||
|
refId: C |
||||||
|
type: threshold |
||||||
|
dashboardUid: j6T00KRZz |
||||||
|
panelId: 3 |
||||||
|
noDataState: NoData |
||||||
|
execErrState: Error |
||||||
|
for: 10m |
||||||
|
annotations: |
||||||
|
__dashboardUid__: j6T00KRZz |
||||||
|
__panelId__: "3" |
||||||
|
labels: {} |
||||||
|
isPaused: false |
@ -0,0 +1,86 @@ |
|||||||
|
import { e2e } from '../utils'; |
||||||
|
|
||||||
|
describe('ReturnToPrevious button', () => { |
||||||
|
beforeEach(() => { |
||||||
|
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD')); |
||||||
|
cy.window().then((win) => { |
||||||
|
win.localStorage.setItem('grafana.featureToggles', 'returnToPrevious=1'); |
||||||
|
}); |
||||||
|
|
||||||
|
cy.visit('/alerting/list'); |
||||||
|
e2e.components.AlertRules.groupToggle().first().click(); |
||||||
|
e2e.components.AlertRules.toggle().click(); |
||||||
|
cy.get('a[title="View"]').click(); |
||||||
|
cy.url().as('alertRuleUrl'); |
||||||
|
cy.get('a').contains('View panel').click(); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should appear when changing context and go back to alert rule when clicking "Back"', () => { |
||||||
|
// make sure the dashboard finished loading
|
||||||
|
cy.get('button[aria-label*="BarChart - Label Rotation & Skipping"]').should('be.visible'); |
||||||
|
|
||||||
|
// check whether all elements of RTP are available
|
||||||
|
e2e.components.ReturnToPrevious.buttonGroup().should('be.visible'); |
||||||
|
e2e.components.ReturnToPrevious.dismissButton().should('be.visible'); |
||||||
|
e2e.components.ReturnToPrevious.backButton() |
||||||
|
.find('span') |
||||||
|
.contains('Back to e2e-ReturnToPrevious-test') |
||||||
|
.should('be.visible') |
||||||
|
.click(); |
||||||
|
|
||||||
|
// check whether the RTP button leads back to alert rule
|
||||||
|
cy.get('@alertRuleUrl').then((alertRuleUrl) => { |
||||||
|
cy.url().should('eq', alertRuleUrl); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should disappear when clicking "Dismiss"', () => { |
||||||
|
e2e.components.ReturnToPrevious.dismissButton().should('be.visible').click(); |
||||||
|
e2e.components.ReturnToPrevious.buttonGroup().should('not.exist'); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should not persist when going back to the alert rule details view', () => { |
||||||
|
e2e.components.ReturnToPrevious.buttonGroup().should('be.visible'); |
||||||
|
|
||||||
|
// make sure the dashboard finished loading
|
||||||
|
cy.get('button[aria-label*="BarChart - Label Rotation & Skipping"]').should('be.visible'); |
||||||
|
|
||||||
|
cy.visit('/alerting/list'); |
||||||
|
e2e.components.AlertRules.groupToggle().first().click(); |
||||||
|
cy.get('a[title="View"]').click(); |
||||||
|
e2e.components.ReturnToPrevious.buttonGroup().should('not.exist'); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should override the button label and change the href when user changes alert rules', () => { |
||||||
|
// make sure the dashboard finished loading
|
||||||
|
cy.get('button[aria-label*="BarChart - Label Rotation & Skipping"]').should('be.visible'); |
||||||
|
|
||||||
|
e2e.components.ReturnToPrevious.backButton() |
||||||
|
.find('span') |
||||||
|
.contains('Back to e2e-ReturnToPrevious-test') |
||||||
|
.should('be.visible'); |
||||||
|
|
||||||
|
cy.visit('/alerting/list'); |
||||||
|
|
||||||
|
e2e.components.AlertRules.groupToggle().last().click(); |
||||||
|
cy.get('a[title="View"]').click(); |
||||||
|
cy.url().as('alertRule2Url'); |
||||||
|
cy.get('a').contains('View panel').click(); |
||||||
|
|
||||||
|
// make sure the dashboard finished loading
|
||||||
|
cy.get('button[aria-label*="BarChart - Label Rotation & Skipping"]').should('be.visible'); |
||||||
|
|
||||||
|
e2e.components.ReturnToPrevious.backButton() |
||||||
|
.find('span') |
||||||
|
.contains('Back to e2e-ReturnToPrevious-test-2') |
||||||
|
.should('be.visible') |
||||||
|
.click(); |
||||||
|
|
||||||
|
e2e.components.ReturnToPrevious.buttonGroup().should('not.exist'); |
||||||
|
|
||||||
|
// check whether the RTP button leads back to alert rule
|
||||||
|
cy.get('@alertRule2Url').then((alertRule2Url) => { |
||||||
|
cy.url().should('eq', alertRule2Url); |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
Loading…
Reference in new issue