Skip to content

Commit

Permalink
change clickCommandLog to actually pass the LONG_RUNNING_THRESHOLD to…
Browse files Browse the repository at this point in the history
… make for

 a more accurate test [run ci]
  • Loading branch information
AtofStryker committed Nov 4, 2024
1 parent a8a3c07 commit fcb9178
Showing 1 changed file with 14 additions and 29 deletions.
43 changes: 14 additions & 29 deletions packages/driver/cypress/support/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit fcb9178

Please sign in to comment.