From b47b3da86b6597a138e190173c2c05bc021bf56d Mon Sep 17 00:00:00 2001 From: joshhunt Date: Wed, 5 Jun 2024 11:18:49 +0100 Subject: [PATCH] polish e2e tests, remove console.log --- e2e/various-suite/keybinds.spec.ts | 43 +++---------------- .../app/core/services/mousetrap/Mousetrap.ts | 1 - 2 files changed, 5 insertions(+), 39 deletions(-) diff --git a/e2e/various-suite/keybinds.spec.ts b/e2e/various-suite/keybinds.spec.ts index 2a01c4ded58..ebcdbf41bd5 100644 --- a/e2e/various-suite/keybinds.spec.ts +++ b/e2e/various-suite/keybinds.spec.ts @@ -26,7 +26,7 @@ describe('Keyboard shortcuts', options, () => { e2e.components.Panels.Panel.title('Latest from the blog').should('be.visible'); }); - it.only('a single time range shortcut should work', () => { + it('multiple time range shortcuts should work', options, () => { cy.get('body').type('ge'); e2e.pages.Explore.General.container().should('be.visible'); @@ -36,58 +36,25 @@ describe('Keyboard shortcuts', options, () => { to: '2024-06-05 10:06:00', zone: 'Browser', }); - - e2e.components.TimePicker.fromField() - .should('not.exist') - .then(() => { - console.log('asserted closed'); - }); + 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.get('body').type('t{leftarrow}'); - cy.wait(500); - 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); - }); - - it.skip('multiple time range shortcuts should work', options, async () => { - cy.get('body').type('ge'); - e2e.pages.Explore.General.container().should('be.visible'); - - // Time range is 1 minute, so each shortcut press should jump back or forward by 1 minute - e2e.flows.setTimeRange({ - from: '2024-06-05 10:05:00', - to: '2024-06-05 10:06:00', - zone: 'Browser', - }); - e2e.components.TimePicker.fromField() - .should('not.exist') - .then(() => { - console.log('asserted closed'); - }); - - cy.log('Trying one shift-left'); - cy.get('body').type('t{leftarrow}'); - cy.wait(500); 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}'); - cy.wait(500); cy.get('body').type('t{leftarrow}'); - cy.wait(500); 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 three shift-lefts'); + cy.log('Trying two shift-lefts and a shift-right'); cy.get('body').type('t{leftarrow}'); - cy.wait(500); cy.get('body').type('t{leftarrow}'); - cy.wait(500); cy.get('body').type('t{rightarrow}'); - cy.wait(500); - expectedRange = `Time range selected: 2024-06-05 10:01:00 to 2024-06-05 10:02:00`; // 1 min back in 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); }); }); diff --git a/public/app/core/services/mousetrap/Mousetrap.ts b/public/app/core/services/mousetrap/Mousetrap.ts index 3aef93b5921..3f7d1503135 100644 --- a/public/app/core/services/mousetrap/Mousetrap.ts +++ b/public/app/core/services/mousetrap/Mousetrap.ts @@ -588,7 +588,6 @@ export class Mousetrap { * handles a character key event */ private _handleKey = (character: string, modifiers: string[], e: KeyboardEvent) => { - console.log('_handleKey', e.type, character); let callbacks = this._getMatches(character, modifiers, e); let i; let doNotReset: Record = {};