From fcb9178c2e575b1e488ce19919aaf282cc8998f8 Mon Sep 17 00:00:00 2001 From: AtofStryker Date: Sun, 3 Nov 2024 19:39:22 -0500 Subject: [PATCH] change clickCommandLog to actually pass the LONG_RUNNING_THRESHOLD to make for a more accurate test [run ci] --- packages/driver/cypress/support/utils.ts | 43 ++++++++---------------- 1 file changed, 14 insertions(+), 29 deletions(-) diff --git a/packages/driver/cypress/support/utils.ts b/packages/driver/cypress/support/utils.ts index 3c0106ff465a..28e677155c17 100644 --- a/packages/driver/cypress/support/utils.ts +++ b/packages/driver/cypress/support/utils.ts @@ -22,45 +22,30 @@ export const findReactInstance = function (dom) { } export const clickCommandLog = (sel, type) => { - return cy.wait(10) + // trigger the LONG_RUNNING_THRESHOLD to display the command line + // this adds time to test but makes a more accurate test as React 18+ does not rerender when setting internals + return cy.wait(2000) .then(() => { - return withMutableReporterState(() => { - const commandLogEl = getCommandLogWithText(sel, type) + const commandLogEl = getCommandLogWithText(sel, type) - const reactCommandInstance = findReactInstance(commandLogEl[0]) + const reactCommandInstance = findReactInstance(commandLogEl[0]) - if (!reactCommandInstance) { - assert(false, 'failed to get command log React instance') - } + if (!reactCommandInstance) { + assert(false, 'failed to get command log React instance') + } - reactCommandInstance.props.appState.isRunning = false - const inner = $(commandLogEl).find('.command-wrapper-text') + reactCommandInstance.props.appState.isRunning = false + const inner = $(commandLogEl).find('.command-wrapper-text') - inner.get(0).click() + inner.get(0).click() - cy.wait(10).then(() => { - // make sure command was pinned, otherwise throw a better error message - expect(cy.$$('.runnable-active .command-pin', top?.document).length, 'command should be pinned').ok - }) + cy.wait(10).then(() => { + // make sure command was pinned, otherwise throw a better error message + expect(cy.$$('.runnable-active .command-pin', top?.document).length, 'command should be pinned').ok }) }) } -export const withMutableReporterState = (fn) => { - // @ts-ignore - top?.UnifiedRunner.MobX.configure({ enforceActions: 'never' }) - - const currentTestLog = findReactInstance(cy.$$('.runnable-active', top?.document)[0]) - - currentTestLog.props.model._isOpen = true - - return Promise.try(fn) - .then(() => { - // @ts-ignore - top?.UnifiedRunner.MobX.configure({ enforceActions: 'always' }) - }) -} - const wrapped = (obj) => cy.wrap(obj, { log: false }) export const shouldBeCalled = (stub) => wrapped(stub).should('be.called')