-
Notifications
You must be signed in to change notification settings - Fork 190
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(compass-global-writes): sharding in progress state COMPASS-8277 (#…
- Loading branch information
1 parent
11209f0
commit eab7899
Showing
8 changed files
with
604 additions
and
86 deletions.
There are no files selected for viewing
This file contains 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
38 changes: 36 additions & 2 deletions
38
packages/compass-global-writes/src/components/states/sharding.spec.tsx
This file contains 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 |
---|---|---|
@@ -1,18 +1,52 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { screen } from '@mongodb-js/testing-library-compass'; | ||
import { screen, userEvent } from '@mongodb-js/testing-library-compass'; | ||
import { ShardingState } from './sharding'; | ||
import { renderWithStore } from '../../../tests/create-store'; | ||
import Sinon from 'sinon'; | ||
|
||
function renderWithProps( | ||
props?: Partial<React.ComponentProps<typeof ShardingState>> | ||
) { | ||
return renderWithStore(<ShardingState {...props} />); | ||
return renderWithStore( | ||
<ShardingState | ||
onCancelSharding={() => {}} | ||
isCancellingSharding={false} | ||
{...props} | ||
/> | ||
); | ||
} | ||
|
||
describe('Sharding', function () { | ||
it('renders the info banner', async function () { | ||
await renderWithProps(); | ||
expect(screen.getByRole('alert')).to.exist; | ||
}); | ||
|
||
it('sharding request can be cancelled', async function () { | ||
const onCancelSharding = Sinon.spy(); | ||
await renderWithProps({ | ||
onCancelSharding, | ||
}); | ||
const btn = screen.getByRole('button', { name: 'Cancel Request' }); | ||
expect(btn).to.be.visible; | ||
|
||
userEvent.click(btn); | ||
|
||
expect(onCancelSharding).to.have.been.calledOnce; | ||
}); | ||
|
||
it('when cancelling is in progress, it cannot be triggered again', async function () { | ||
const onCancelSharding = Sinon.spy(); | ||
await renderWithProps({ | ||
isCancellingSharding: true, | ||
onCancelSharding, | ||
}); | ||
const btn = screen.getByTestId('cancel-sharding-btn'); | ||
expect(btn.getAttribute('aria-disabled')).to.equal('true'); | ||
|
||
userEvent.click(btn); | ||
|
||
expect(onCancelSharding).not.to.have.been.calledOnce; | ||
}); | ||
}); |
This file contains 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 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,16 @@ | ||
import React from 'react'; | ||
import { expect } from 'chai'; | ||
import { PluginTitle } from './plugin-title'; | ||
import { render, screen } from '@mongodb-js/testing-library-compass'; | ||
|
||
describe('PluginTitle', function () { | ||
it('Renders a warning', function () { | ||
render(<PluginTitle showWarning={true} />); | ||
expect(screen.getByLabelText('warning')).to.be.visible; | ||
}); | ||
|
||
it('Does not render a warning', function () { | ||
render(<PluginTitle showWarning={false} />); | ||
expect(screen.queryByLabelText('warning')).not.to.exist; | ||
}); | ||
}); |
This file contains 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 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
Oops, something went wrong.