Skip to content

Commit 4450dc7

Browse files
committed
fixup! fixup! fixup! Add a new test
Revert the shared helper
1 parent 75ef919 commit 4450dc7

File tree

2 files changed

+11
-20
lines changed

2 files changed

+11
-20
lines changed

configs/testing-library-compass/src/index.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -732,17 +732,6 @@ const testingLibrary = {
732732
renderHook,
733733
};
734734

735-
/**
736-
* Expects an element (queried test id) to visible or missing from the screen
737-
*/
738-
function expectElementByTestId(testId: string, state: 'visible' | 'missing') {
739-
if (state === 'visible') {
740-
expect(screen.queryByTestId(testId)).to.be.visible;
741-
} else if (state === 'missing') {
742-
expect(screen.queryByTestId(testId)).to.be.null;
743-
}
744-
}
745-
746735
export {
747736
// There is never a good reason not to have these wrapper providers when
748737
// rendering something in compass for testing. Using these render methods
@@ -767,5 +756,4 @@ export {
767756
within,
768757
fireEvent,
769758
testingLibrary,
770-
expectElementByTestId,
771759
};

packages/compass-sidebar/src/components/multiple-connections/sidebar.spec.tsx

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -361,28 +361,31 @@ describe('Multiple Connections Sidebar Component', function () {
361361
it('should render the only connected connections when toggled', async () => {
362362
await renderAndWaitForNavigationTree();
363363

364+
const favoriteConnectionId = savedFavoriteConnection.id;
365+
const recentConnectionId = savedRecentConnection.id;
366+
364367
const activeConnectionsToggleButton = screen.getByLabelText(
365368
'Showing all connections'
366369
);
367370

368-
expectElementByTestId(savedFavoriteConnection.id, 'visible');
369-
expectElementByTestId(savedRecentConnection.id, 'visible');
371+
expect(screen.queryByTestId(favoriteConnectionId)).to.be.visible;
372+
expect(screen.queryByTestId(recentConnectionId)).to.be.visible;
370373

371374
userEvent.click(activeConnectionsToggleButton);
372375
expect(activeConnectionsToggleButton.ariaLabel).equals(
373376
'Showing active connections'
374377
);
375378

376-
expectElementByTestId(savedFavoriteConnection.id, 'missing');
377-
expectElementByTestId(savedRecentConnection.id, 'missing');
379+
expect(screen.queryByTestId(favoriteConnectionId)).to.be.null;
380+
expect(screen.queryByTestId(recentConnectionId)).to.be.null;
378381

379382
await connectAndNotifyInstanceManager(savedFavoriteConnection);
380-
expectElementByTestId(savedFavoriteConnection.id, 'visible');
381-
expectElementByTestId(savedRecentConnection.id, 'missing');
383+
expect(screen.queryByTestId(favoriteConnectionId)).to.be.visible;
384+
expect(screen.queryByTestId(recentConnectionId)).to.be.null;
382385

383386
await connectAndNotifyInstanceManager(savedRecentConnection);
384-
expectElementByTestId(savedFavoriteConnection.id, 'visible');
385-
expectElementByTestId(savedRecentConnection.id, 'visible');
387+
expect(screen.queryByTestId(favoriteConnectionId)).to.be.visible;
388+
expect(screen.queryByTestId(recentConnectionId)).to.be.visible;
386389
});
387390

388391
context('and performing actions', function () {

0 commit comments

Comments
 (0)