mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
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/list
This commit is contained in:
86
e2e/various-suite/return-to-previous.spec.ts
Normal file
86
e2e/various-suite/return-to-previous.spec.ts
Normal file
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user