Skip to content

Commit

Permalink
test: flakiness of unit test (FileInputComponent) (#1368)
Browse files Browse the repository at this point in the history
**Issue number**: *ADDON-72533*

## Summary

### Changes

> Fix flakiness of unit test (FileInputComponent)

### User experience

> fix the test case so don't affect the user experience

## Checklist

If your change doesn't seem to apply, please leave them unchecked.

* [x] I have performed a self-review of this change
* [x] Changes have been tested
* [ ] Changes are documented
* [x] PR title follows [conventional commit
semantics](https://www.conventionalcommits.org/en/v1.0.0/)
  • Loading branch information
rohanm-crest authored Oct 15, 2024
1 parent cf32661 commit bc5c8ce
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';

import { render, screen } from '@testing-library/react';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import FileInputComponent from './FileInputComponent';
import fileContants from '../../constants/fileInputConstant';
Expand Down Expand Up @@ -375,5 +375,6 @@ test('Check FileInputComponent encodes base64 correctly and passed it to handler
await userEvent.upload(fileInput, testfile);

// Check that handleChange is called with valid args.
expect(handleChange).toHaveBeenCalledWith(field, btoa(fileContent));
const fileContentInBase64 = btoa(fileContent);
await waitFor(() => expect(handleChange).toHaveBeenCalledWith(field, fileContentInBase64));
});

0 comments on commit bc5c8ce

Please sign in to comment.