Skip to content

Commit

Permalink
Fix flaky unit test (#26433)
Browse files Browse the repository at this point in the history
* Fix flaky unit test

* Fix flaky unit test attemp #2
  • Loading branch information
Mottie authored Oct 30, 2023
1 parent 76c29aa commit 089b965
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ describe('<EvidenceVaRecords>', () => {
});

describe('partial/invalid data navigation', () => {
const testAndCloseModal = async (container, total, event) => {
expect(getErrorElements(container).length).to.eq(total);
const testAndCloseModal = async (container, event) => {
// modal visible
await waitFor(() => {
expect($('va-modal[visible="true"]', container)).to.exist;
Expand Down Expand Up @@ -376,7 +375,13 @@ describe('<EvidenceVaRecords>', () => {

// back
clickBack(container);
await testAndCloseModal(container, 3, 'secondaryButtonClick');

// This check is super-flaky in CI
await waitFor(() => {
expect(getErrorElements(container).length).to.eq(3);
});

await testAndCloseModal(container, 'secondaryButtonClick');

await waitFor(() => {
expect(setDataSpy.called).to.be.true;
Expand Down Expand Up @@ -404,8 +409,14 @@ describe('<EvidenceVaRecords>', () => {

// back
clickBack(container);

// This check is super-flaky in CI
await waitFor(() => {
expect(getErrorElements(container).length).to.eq(3);
});

// keep partial entry
await testAndCloseModal(container, 3, 'primaryButtonClick');
await testAndCloseModal(container, 'primaryButtonClick');

await waitFor(() => {
expect(setDataSpy.called).to.be.false; // no data change
Expand Down

0 comments on commit 089b965

Please sign in to comment.