From 98948744ca13fad9ccd9ec6d58dac3b661b998ed Mon Sep 17 00:00:00 2001 From: Matiss Janis Aboltins <matiss@mja.lv> Date: Sat, 18 Mar 2023 12:44:55 +0000 Subject: [PATCH] :white_check_mark: change unit test usage of notes field (#780) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Added an extra `waitFor` after a flaky unit test step. I'm not really super happy with this workaround.. but it does make the test much more stable (re-ran 5x and no failures: https://github.com/actualbudget/actual/actions/runs/4455134799). I think there is some internal timeout happening somewhere which is causing this issue.. But not really sure where. And this will hopefully get auto-fixed once we migrate to a new table. 🤞 --- .../src/components/accounts/TransactionsTable.test.js | 5 ++++- upcoming-release-notes/780.md | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 upcoming-release-notes/780.md diff --git a/packages/desktop-client/src/components/accounts/TransactionsTable.test.js b/packages/desktop-client/src/components/accounts/TransactionsTable.test.js index 5aa96f904..671b3c555 100644 --- a/packages/desktop-client/src/components/accounts/TransactionsTable.test.js +++ b/packages/desktop-client/src/components/accounts/TransactionsTable.test.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; -import { render, screen, fireEvent } from '@testing-library/react'; +import { render, screen, fireEvent, waitFor } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import { format as formatDate, parse as parseDate } from 'date-fns'; @@ -359,6 +359,9 @@ describe('Transactions', () => { // When reaching the bottom it shouldn't error input = await editField(container, 'notes', 4); await userEvent.type(input, '[Enter]'); + await waitFor(() => { + expect(container.querySelector('input')).toBeNull(); + }); // When reaching the top it shouldn't error input = await editField(container, 'notes', 0); diff --git a/upcoming-release-notes/780.md b/upcoming-release-notes/780.md new file mode 100644 index 000000000..cbceb6a95 --- /dev/null +++ b/upcoming-release-notes/780.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MatissJanis] +--- + +Add `waitFor` to a flaky unit test to make it more stable -- GitLab