-
Notifications
You must be signed in to change notification settings - Fork 235
feat(compass-query-history): Add interactive popover, open query history as popover in new query-bar COMPASS-5678 #3321
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Anemy
merged 5 commits into
main
from
COMPASS-5678-query-history-popover-in-feature-flag
Aug 15, 2022
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0aa8a39
Add interactive popover, open query history as popover in new feature…
Anemy fc74b71
backgorund white for editor
Anemy f7fee36
add tests
Anemy a05cff2
feature flag the collection store setup to keep namespaces seperate
Anemy d948118
merge main
Anemy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
102 changes: 102 additions & 0 deletions
102
packages/compass-components/src/components/interactive-popover.spec.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import React from 'react'; | ||
import { render, screen, cleanup } from '@testing-library/react'; | ||
import { expect } from 'chai'; | ||
import sinon from 'sinon'; | ||
|
||
import { InteractivePopover } from './interactive-popover'; | ||
|
||
const innerContentTestId = 'testing-inner-content'; | ||
|
||
function renderPopover( | ||
props?: Partial<React.ComponentProps<typeof InteractivePopover>> | ||
) { | ||
const openSpy = sinon.spy(); | ||
|
||
const popoverContent = ({ onClose }) => ( | ||
<> | ||
<button onClick={() => {}} data-testid={innerContentTestId}> | ||
Action Button | ||
</button> | ||
<div>inner content</div> | ||
<button onClick={onClose}>Close Button</button> | ||
</> | ||
); | ||
|
||
return render( | ||
<InteractivePopover | ||
className="" | ||
open={false} | ||
setOpen={openSpy} | ||
trigger={({ onClick, ref, children }) => ( | ||
<> | ||
<button onClick={onClick} ref={ref}> | ||
Trigger Button Text | ||
</button> | ||
{children} | ||
</> | ||
)} | ||
{...props} | ||
> | ||
{popoverContent} | ||
</InteractivePopover> | ||
); | ||
} | ||
|
||
describe('InteractivePopover Component', function () { | ||
afterEach(function () { | ||
cleanup(); | ||
}); | ||
|
||
it('when open it should show the popover content', function () { | ||
renderPopover({ | ||
open: true, | ||
}); | ||
expect(screen.getByTestId(innerContentTestId)).to.be.visible; | ||
}); | ||
|
||
it('when closed it should not show the popover content', function () { | ||
renderPopover({ | ||
open: false, | ||
}); | ||
expect(screen.queryByTestId(innerContentTestId)).to.not.exist; | ||
}); | ||
|
||
it('should render the trigger', function () { | ||
renderPopover({ | ||
open: false, | ||
}); | ||
const button = screen.getByRole('button'); | ||
expect(button).to.be.visible; | ||
expect(screen.getByText('Trigger Button Text')).to.be.visible; | ||
}); | ||
|
||
it('when closed and the trigger is clicked it should call to open', function () { | ||
const openSpy = sinon.fake(); | ||
|
||
renderPopover({ | ||
open: false, | ||
setOpen: openSpy, | ||
}); | ||
expect(openSpy.calledOnce).to.be.false; | ||
|
||
const button = screen.getByText('Trigger Button Text'); | ||
button.click(); | ||
expect(openSpy.calledOnce).to.be.true; | ||
expect(openSpy.firstCall.firstArg).to.equal(true); | ||
}); | ||
|
||
it('when open and the trigger is clicked it should call to close', function () { | ||
const openSpy = sinon.fake(); | ||
|
||
renderPopover({ | ||
open: true, | ||
setOpen: openSpy, | ||
}); | ||
expect(openSpy.calledOnce).to.be.false; | ||
|
||
const button = screen.getByText('Trigger Button Text'); | ||
button.click(); | ||
expect(openSpy.calledOnce).to.be.true; | ||
expect(openSpy.firstCall.firstArg).to.equal(false); | ||
}); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.