diff --git a/test-e2e/select-test-suit.ts b/test-e2e/select-test-suit.ts index 537359ca..acaad83d 100644 --- a/test-e2e/select-test-suit.ts +++ b/test-e2e/select-test-suit.ts @@ -19,27 +19,6 @@ export class SelectTestSuit extends TestSuit { this.itemsWithPlaceholder = this.itemList.locator('.choices__item'); } - async start(textInput?: string): Promise { - await this.page.route('**/data.json', async (route) => { - await new Promise((f) => { - setTimeout(f, 250); - }); - - const fakeData = [...new Array(10)].map((_, index) => ({ - label: `Label ${index + 1}`, - value: `Value ${index + 1}`, - })); - - await route.fulfill({ - status: 200, - contentType: 'application/json', - body: JSON.stringify(fakeData), - }); - }); - - await super.start(textInput); - } - async startWithClick(): Promise { await this.start(); await this.selectByClick(); diff --git a/test-e2e/tests/select-one.spec.ts b/test-e2e/tests/select-one.spec.ts index 86009dc5..f6691a51 100644 --- a/test-e2e/tests/select-one.spec.ts +++ b/test-e2e/tests/select-one.spec.ts @@ -402,11 +402,32 @@ describe(`Choices - select one`, () => { test('checking placeholder values', async ({ page, bundle }) => { const jsonLoad = page.waitForResponse('**/data.json'); + let stopJsonWaiting = () => {}; + const jsonWaiting = new Promise((f) => { + stopJsonWaiting = f; + }); + + await page.route('**/data.json', async (route) => { + await jsonWaiting; + + const fakeData = [...new Array(10)].map((_, index) => ({ + label: `Label ${index + 1}`, + value: `Value ${index + 1}`, + })); + + await route.fulfill({ + status: 200, + contentType: 'application/json', + body: JSON.stringify(fakeData), + }); + }); + const suite = new SelectTestSuit(page, bundle, testUrl, testId); await suite.start(); await expect(suite.itemList.first()).toHaveText('Loading...'); + stopJsonWaiting(); await jsonLoad; await suite.selectByClick();