Chore: Remove hardcoded wait in keybinds e2e test (#88895)

* remove hardcoded wait in keybinds test

* review comments
This commit is contained in:
Ashley Harrison 2024-06-10 15:09:15 +01:00 committed by GitHub
parent 90418dc00b
commit f78fb4ff16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,11 +1,7 @@
import { e2e } from '../utils';
import { fromBaseUrl } from '../utils/support/url';
const options = {
defaultCommandTimeout: 5 * 1000,
};
describe('Keyboard shortcuts', options, () => {
describe('Keyboard shortcuts', () => {
beforeEach(() => {
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');
});
it('ctrl+z should zoom out the time range', options, () => {
it('ctrl+z should zoom out the time range', () => {
cy.get('body').type('ge');
e2e.pages.Explore.General.container().should('be.visible');
@ -36,15 +32,15 @@ describe('Keyboard shortcuts', options, () => {
to: '2024-06-05 10:06:00',
zone: 'Browser',
});
e2e.components.TimePicker.fromField().should('not.exist');
cy.wait(500); // waiting is anti-pattern, but it's inconsistent for me locally without this
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
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`;
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');
e2e.pages.Explore.General.container().should('be.visible');
@ -54,24 +50,29 @@ describe('Keyboard shortcuts', options, () => {
to: '2024-06-05 10:06:00',
zone: 'Browser',
});
e2e.components.TimePicker.fromField().should('not.exist');
cy.wait(500); // waiting is anti-pattern, but it's inconsistent for me locally without this
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
cy.log('Trying one shift-left');
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
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
cy.log('Trying two shift-lefts');
cy.get('body').type('t{leftarrow}');
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
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
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
cy.log('Trying two shift-lefts and a shift-right');
cy.get('body').type('t{leftarrow}');
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
cy.get('body').type('t{leftarrow}');
e2e.components.RefreshPicker.runButtonV2().should('have.text', 'Run query');
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)
e2e.components.TimePicker.openButton().should('have.attr', 'aria-label', expectedRange);
});