Keybinds: Add wait to e2e test to hopefully mitigate flakiness (#88854)

Revert "remove anti-patterns"

This reverts commit 55eb0fa32a.
This commit is contained in:
Josh Hunt 2024-06-06 15:55:15 +01:00 committed by GitHub
parent 62fc451f7a
commit be96971289
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,7 +1,11 @@
import { e2e } from '../utils'; import { e2e } from '../utils';
import { fromBaseUrl } from '../utils/support/url'; import { fromBaseUrl } from '../utils/support/url';
describe('Keyboard shortcuts', () => { const options = {
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'));
@ -22,7 +26,7 @@ describe('Keyboard shortcuts', () => {
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', () => { it('ctrl+z should zoom out the time range', options, () => {
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');
@ -33,13 +37,14 @@ describe('Keyboard shortcuts', () => {
zone: 'Browser', zone: 'Browser',
}); });
e2e.components.TimePicker.fromField().should('not.exist'); e2e.components.TimePicker.fromField().should('not.exist');
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');
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', () => { it('multiple time range shortcuts should work', options, () => {
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');
@ -50,6 +55,7 @@ describe('Keyboard shortcuts', () => {
zone: 'Browser', zone: 'Browser',
}); });
e2e.components.TimePicker.fromField().should('not.exist'); e2e.components.TimePicker.fromField().should('not.exist');
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}');