mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Chore: Remove hardcoded wait in keybinds e2e test (#88895)
* remove hardcoded wait in keybinds test * review comments
This commit is contained in:
@@ -1,11 +1,7 @@
|
|||||||
import { e2e } from '../utils';
|
import { e2e } from '../utils';
|
||||||
import { fromBaseUrl } from '../utils/support/url';
|
import { fromBaseUrl } from '../utils/support/url';
|
||||||
|
|
||||||
const options = {
|
describe('Keyboard shortcuts', () => {
|
||||||
defaultCommandTimeout: 5 * 1000,
|
|
||||||
};
|
|
||||||
|
|
||||||
describe('Keyboard shortcuts', options, () => {
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
|
e2e.flows.login(Cypress.env('USERNAME'), Cypress.env('PASSWORD'));
|
||||||
|
|
||||||
@@ -26,7 +22,7 @@ describe('Keyboard shortcuts', options, () => {
|
|||||||
e2e.components.Panels.Panel.title('Latest from the blog').should('be.visible');
|
e2e.components.Panels.Panel.title('Latest from the blog').should('be.visible');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('ctrl+z should zoom out the time range', options, () => {
|
it('ctrl+z should zoom out the time range', () => {
|
||||||
cy.get('body').type('ge');
|
cy.get('body').type('ge');
|
||||||
e2e.pages.Explore.General.container().should('be.visible');
|
e2e.pages.Explore.General.container().should('be.visible');
|
||||||
|
|
||||||
@@ -36,15 +32,15 @@ describe('Keyboard shortcuts', options, () => {
|
|||||||
to: '2024-06-05 10:06:00',
|
to: '2024-06-05 10:06:00',
|
||||||
zone: 'Browser',
|
zone: 'Browser',
|
||||||
});
|
});
|
||||||
e2e.components.TimePicker.fromField().should('not.exist');
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
cy.wait(500); // waiting is anti-pattern, but it's inconsistent for me locally without this
|
|
||||||
|
|
||||||
cy.get('body').type('{ctrl}z');
|
cy.get('body').type('{ctrl}z');
|
||||||
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
let expectedRange = `Time range selected: 2024-06-05 10:03:30 to 2024-06-05 10:07:30`;
|
let expectedRange = `Time range selected: 2024-06-05 10:03:30 to 2024-06-05 10:07:30`;
|
||||||
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('multiple time range shortcuts should work', options, () => {
|
it('multiple time range shortcuts should work', () => {
|
||||||
cy.get('body').type('ge');
|
cy.get('body').type('ge');
|
||||||
e2e.pages.Explore.General.container().should('be.visible');
|
e2e.pages.Explore.General.container().should('be.visible');
|
||||||
|
|
||||||
@@ -54,24 +50,29 @@ describe('Keyboard shortcuts', options, () => {
|
|||||||
to: '2024-06-05 10:06:00',
|
to: '2024-06-05 10:06:00',
|
||||||
zone: 'Browser',
|
zone: 'Browser',
|
||||||
});
|
});
|
||||||
e2e.components.TimePicker.fromField().should('not.exist');
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
cy.wait(500); // waiting is anti-pattern, but it's inconsistent for me locally without this
|
|
||||||
|
|
||||||
cy.log('Trying one shift-left');
|
cy.log('Trying one shift-left');
|
||||||
cy.get('body').type('t{leftarrow}');
|
cy.get('body').type('t{leftarrow}');
|
||||||
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
let expectedRange = `Time range selected: 2024-06-05 10:04:00 to 2024-06-05 10:05:00`; // 1 min back
|
let expectedRange = `Time range selected: 2024-06-05 10:04:00 to 2024-06-05 10:05:00`; // 1 min back
|
||||||
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
||||||
|
|
||||||
cy.log('Trying two shift-lefts');
|
cy.log('Trying two shift-lefts');
|
||||||
cy.get('body').type('t{leftarrow}');
|
cy.get('body').type('t{leftarrow}');
|
||||||
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
cy.get('body').type('t{leftarrow}');
|
cy.get('body').type('t{leftarrow}');
|
||||||
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
expectedRange = `Time range selected: 2024-06-05 10:02:00 to 2024-06-05 10:03:00`; // 2 mins back
|
expectedRange = `Time range selected: 2024-06-05 10:02:00 to 2024-06-05 10:03:00`; // 2 mins back
|
||||||
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
||||||
|
|
||||||
cy.log('Trying two shift-lefts and a shift-right');
|
cy.log('Trying two shift-lefts and a shift-right');
|
||||||
cy.get('body').type('t{leftarrow}');
|
cy.get('body').type('t{leftarrow}');
|
||||||
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
cy.get('body').type('t{leftarrow}');
|
cy.get('body').type('t{leftarrow}');
|
||||||
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
cy.get('body').type('t{rightarrow}');
|
cy.get('body').type('t{rightarrow}');
|
||||||
|
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
|
||||||
expectedRange = `Time range selected: 2024-06-05 10:01:00 to 2024-06-05 10:02:00`; // 2 mins back, 1 min forward (1 min back total)
|
expectedRange = `Time range selected: 2024-06-05 10:01:00 to 2024-06-05 10:02:00`; // 2 mins back, 1 min forward (1 min back total)
|
||||||
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user