Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

4.1.3 - need to wait until modal overlay is opened (in test) #397

Open
Techn1x opened this issue Jan 8, 2024 · 1 comment
Open

4.1.3 - need to wait until modal overlay is opened (in test) #397

Techn1x opened this issue Jan 8, 2024 · 1 comment

Comments

@Techn1x
Copy link

Techn1x commented Jan 8, 2024

This is more an advisory to others in case it affects them.

I was confused why one of my tests was failing under 4.1.3 (it had no release notes to guide).

I have a test like this

test('it closes on click outside', async function (assert) {
  this.showModal = true
  this.close = sinon.stub().callsFake(() => set(this, 'showModal', false))

  await render(hbs`
    <LayoutBlocks::Modal
      data-test-my-modal
      @title="My Modal"
      @showModal={{this.showModal}}
      @close={{this.close}}
    >
      content here
    </LayoutBlocks::Modal>
  `)

  assert.dom('[data-test-my-modal]').exists()

  // simulate a click that occurs outside of the modal
  await click('.ember-modal-overlay')

  assert.calledOnce(this.close)
  assert.dom('[data-test-my-modal]').doesNotExist()
})

It took me a while to figure out, but I needed to add this line before the click
await waitFor('.ember-modal-overlay', { count: 1 })

(import waitFor from '@ember/test-helpers')

@Techn1x Techn1x changed the title 4.1.3 - need to wait until modal 4.1.3 - need to wait until modal overlay is opened (in test) Jan 8, 2024
@Techn1x
Copy link
Author

Techn1x commented Jan 8, 2024

Nothing to fix here, feel free to close when desired. I just figured this would help others in lieu of the release notes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant