Fix flaky test
All checks were successful
CI / Lint (pull_request) Successful in 32s
CI / Test (pull_request) Successful in 55s

Wait for specific actions/elements
This commit is contained in:
2026-06-05 18:37:40 +04:00
parent d266bb92bd
commit 2c2a3e2a4c

View File

@@ -1,6 +1,6 @@
import { module, test } from 'qunit'; import { module, test } from 'qunit';
import { setupRenderingTest } from 'marco/tests/helpers'; import { setupRenderingTest } from 'marco/tests/helpers';
import { render, fillIn, click, waitFor } from '@ember/test-helpers'; import { render, fillIn, click, waitFor, focus } from '@ember/test-helpers';
import SearchBox from 'marco/components/search-box'; import SearchBox from 'marco/components/search-box';
import Service from '@ember/service'; import Service from '@ember/service';
@@ -208,18 +208,22 @@ module('Integration | Component | search-box', function (hooks) {
); );
// Type "Resta" to trigger "Restaurants" category match // Type "Resta" to trigger "Restaurants" category match
await focus('.search-input');
await fillIn('.search-input', 'Resta'); await fillIn('.search-input', 'Resta');
// Wait for debounce (300ms) + execution await waitFor('.search-result-item');
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
await delay(400);
// The first result should be the category match const resultItems = Array.from(
assert.dom('.search-result-item').exists({ count: 1 }); this.element.querySelectorAll('.search-result-item')
assert.dom('.result-title').hasText('Restaurants'); );
const categoryResult = resultItems.find((item) =>
item.textContent.includes('Restaurants')
);
assert.ok(categoryResult, 'Restaurants category result is shown');
// Click the result // Click the result
await click('.search-result-item'); await click(categoryResult);
// Assert transition with lat/lon from map center // Assert transition with lat/lon from map center
assert.verifySteps([ assert.verifySteps([