1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- import selectEvent from 'react-select-event';
- import pick from 'lodash/pick';
- import {initializeOrg} from 'sentry-test/initializeOrg';
- import {render, screen} from 'sentry-test/reactTestingLibrary';
- import IntegrationOrganizationLink from 'sentry/views/integrationOrganizationLink';
- describe('IntegrationOrganizationLink', () => {
- it('selecting org from dropdown loads the org through the API', async () => {
- const {routerProps} = initializeOrg();
- const org1 = TestStubs.Organization({
- slug: 'org1',
- name: 'Organization 1',
- });
- const org2 = TestStubs.Organization({
- slug: 'org2',
- name: 'Organization 2',
- });
- const org1Lite = pick(org1, ['slug', 'name', 'id']);
- const org2Lite = pick(org2, ['slug', 'name', 'id']);
- const getOrgsMock = MockApiClient.addMockResponse({
- url: '/organizations/',
- body: [org1Lite, org2Lite],
- });
- const getOrgMock = MockApiClient.addMockResponse({
- url: `/organizations/${org2.slug}/`,
- body: org2,
- });
- const getProviderMock = MockApiClient.addMockResponse({
- url: `/organizations/${org2.slug}/config/integrations/?provider_key=vercel`,
- body: {providers: [TestStubs.VercelProvider()]},
- });
- render(
- <IntegrationOrganizationLink
- {...routerProps}
- params={{integrationSlug: 'vercel'}}
- />
- );
- expect(getOrgsMock).toHaveBeenCalled();
- expect(getOrgMock).not.toHaveBeenCalled();
- // Select organization
- await selectEvent.select(screen.getByRole('textbox'), org2.name);
- expect(screen.getByRole('button', {name: 'Install Vercel'})).toBeEnabled();
- expect(getProviderMock).toHaveBeenCalled();
- expect(getOrgMock).toHaveBeenCalled();
- });
- });
|