Skip to content

Commit

Permalink
Unmount ImportAnnotations, ExportAnnotations components at end of test
Browse files Browse the repository at this point in the history
This fixes an issue where `SelectNext`s rendered by these components could open
a popover, and then trigger an error by trying to close it, while unmounted, in
response to an action triggered by a later test.
  • Loading branch information
robertknight committed May 13, 2024
1 parent 4033b11 commit 97dd7e3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,28 @@ describe('ExportAnnotations', () => {
let fakeSuggestedFilename;
let fakeCopyPlainText;
let fakeCopyHTML;
let wrappers;

const fakePrivateGroup = {
type: 'private',
name: 'Test Private Group',
id: 'testprivate',
};

const createComponent = props =>
mount(
const createComponent = props => {
const wrapper = mount(
<ExportAnnotations
annotationsExporter={fakeAnnotationsExporter}
toastMessenger={fakeToastMessenger}
{...props}
/>,
);
wrappers.push(wrapper);
return wrapper;
};

beforeEach(() => {
wrappers = [];
fakeAnnotationsExporter = {
buildJSONExportContent: sinon.stub().returns({}),
buildTextExportContent: sinon.stub().returns(''),
Expand Down Expand Up @@ -90,6 +95,7 @@ describe('ExportAnnotations', () => {
});

afterEach(() => {
wrappers.forEach(w => w.unmount());
$imports.$restore();
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ describe('ImportAnnotations', () => {
let fakeImportAnnotationsService;
let fakeReadExportFile;
let fakeStore;
let wrappers;

beforeEach(() => {
wrappers = [];

fakeReadExportFile = sinon.stub().rejects(new Error('Failed to read file'));

fakeImportAnnotationsService = {
Expand All @@ -39,16 +42,19 @@ describe('ImportAnnotations', () => {
});

afterEach(() => {
wrappers.forEach(w => w.unmount());
$imports.$restore();
});

function createImportAnnotations() {
return mount(
const wrapper = mount(
<ImportAnnotations
store={fakeStore}
importAnnotationsService={fakeImportAnnotationsService}
/>,
);
wrappers.push(wrapper);
return wrapper;
}

function getImportButton(wrapper) {
Expand Down

0 comments on commit 97dd7e3

Please sign in to comment.