Skip to content

Commit 3f5ae14

Browse files
committed
fix(test): wait for checkboxes to render after mode switch
The checkbox enable/disable test was flaky because _getCheckboxes() ran before the DOM re-rendered after mode switch. Add awaitsFor to wait for checkboxes to appear before asserting.
1 parent 80964c7 commit 3f5ae14

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

test/spec/md-editor-edit-integ-test.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ define(function (require, exports, module) {
210210

211211
// In reader mode: checkboxes should be disabled
212212
await _enterReaderMode();
213+
await awaitsFor(() => _getCheckboxes().length > 0,
214+
"checkboxes to appear in reader mode");
213215
let checkboxes = _getCheckboxes();
214216
expect(checkboxes.length).toBeGreaterThan(0);
215217
for (const cb of checkboxes) {
@@ -218,6 +220,8 @@ define(function (require, exports, module) {
218220

219221
// In edit mode: checkboxes should be enabled
220222
await _enterEditMode();
223+
await awaitsFor(() => _getCheckboxes().length > 0,
224+
"checkboxes to appear in edit mode");
221225
checkboxes = _getCheckboxes();
222226
expect(checkboxes.length).toBeGreaterThan(0);
223227
for (const cb of checkboxes) {

0 commit comments

Comments
 (0)