test for jest conversion#767
Conversation
|
|
||
| test('Publish button is enabled', () => { | ||
| // Check initially that Publish button is disabled. | ||
| expect(await page.evaluate(() => document.querySelector('.ple-textarea').disabled).toBe(true); |
There was a problem hiding this comment.
What's odd is that I thought we use the /Bootstrap class/ disabled to set the disabled state on this. I don't know how that interacts with the HTML attribute -- the difference is:
<i class="disabled"></i> (Bootstrap CSS)
<i disabled></i> (HTML)
So we may need to disambiguate how this is working, possibly by manually testing the jquery $('.ple-publish').prop('disabled') vs. just el.disabled.
|
OK - so i think that's right: We should try this: oh wait. First we should be checking |
|
That worked! @NARUDESIGNS 🎉 So, maybe what we should do is to look closely at the old test vs. this new one. And to come up with a little bit of helpful documentation (even just a short checklist) for how to do this kind of test conversion successfully. It looks like a combination of:
Does that sound right? |
|
Would you like to try that for an additional test file now? I'll merge this. I hope this'll get us moving now! Thanks Paul, for your patience!!! |
|
Ah, and we should add to the checklist - removing the tests from the Jasmine files. So when we finish all conversions, we'll have no more Jasmine tests! |
|
Wow awesome! |
| // Check final state of Publish button. | ||
| expect(await page.evaluate(() => document.querySelector('.ple-textarea').disabled)).toBe(false); | ||
| expect(await page.evaluate(() => document.querySelector('.ple-publish').disabled)).toBe(false); | ||
| }); |
There was a problem hiding this comment.
Hi @jywarren I noticed you didn't add the timeout variable here. Is this part of the new change or is it something you missed out?
There was a problem hiding this comment.
I think I was able to set it globally on the first few lines and so didn't need to set it per-test.
There was a problem hiding this comment.
Ah, interesting, actually on checking, I am not setting the timeout. I think that means we could remove that line, actually.
For reference, I'm stuck on a related issue (going past the timeout limit in this case) in this test publiclab/image-sequencer#2026
That actually is globally setting timeout. But here I think i just removed it and for the purposes of our test it wasn't needed. I think the default timeout is 5 or 10 seconds? So i guess that's enough for this.
Working from these for triggering the event without jQuery:
Sourcing syntax from this: https://github.com/publiclab/PublicLab.Editor/blob/main/test/ui-testing/bold.test.js
Trying to convert this Jasmine test:
PublicLab.Editor/spec/javascripts/button_spec.js
Lines 13 to 21 in f8e1edb