|
@@ -3,6 +3,7 @@ import {mountGlobalModal} from 'sentry-test/modal';
|
|
|
import {selectByValue} from 'sentry-test/select-new';
|
|
|
|
|
|
import {Client} from 'app/api';
|
|
|
+import ModalStore from 'app/stores/modalStore';
|
|
|
import IntegrationCodeMappings from 'app/views/organizationIntegrations/integrationCodeMappings';
|
|
|
|
|
|
const mockResponse = mocks => {
|
|
@@ -26,6 +27,10 @@ describe('IntegrationCodeMappings', function () {
|
|
|
const org = TestStubs.Organization({
|
|
|
projects,
|
|
|
});
|
|
|
+ const invalidOrg = TestStubs.Organization({
|
|
|
+ projects,
|
|
|
+ access: [],
|
|
|
+ });
|
|
|
const integration = TestStubs.GitHubIntegration();
|
|
|
const repos = [
|
|
|
TestStubs.Repository({
|
|
@@ -75,6 +80,11 @@ describe('IntegrationCodeMappings', function () {
|
|
|
);
|
|
|
});
|
|
|
|
|
|
+ afterEach(() => {
|
|
|
+ // Clear the fields from the GlobalModal after every test
|
|
|
+ ModalStore.reset();
|
|
|
+ });
|
|
|
+
|
|
|
it('shows the paths', async () => {
|
|
|
expect(wrapper.find('RepoName').length).toEqual(2);
|
|
|
expect(wrapper.find('RepoName').at(0).text()).toEqual(repos[0].name);
|
|
@@ -85,7 +95,7 @@ describe('IntegrationCodeMappings', function () {
|
|
|
const modal = await mountGlobalModal();
|
|
|
|
|
|
expect(modal.find('input[name="stackRoot"]')).toHaveLength(0);
|
|
|
- wrapper.find('button[aria-label="Add Mapping"]').first().simulate('click');
|
|
|
+ wrapper.find('button[data-test-id="add-mapping-button"]').first().simulate('click');
|
|
|
|
|
|
await tick();
|
|
|
modal.update();
|
|
@@ -93,6 +103,28 @@ describe('IntegrationCodeMappings', function () {
|
|
|
expect(modal.find('input[name="stackRoot"]')).toHaveLength(1);
|
|
|
});
|
|
|
|
|
|
+ it('requires permissions to click', async () => {
|
|
|
+ const invalidContext = TestStubs.routerContext([{organization: invalidOrg}]);
|
|
|
+ wrapper = mountWithTheme(
|
|
|
+ <IntegrationCodeMappings organization={invalidOrg} integration={integration} />,
|
|
|
+ invalidContext
|
|
|
+ );
|
|
|
+ const modal = await mountGlobalModal(invalidContext);
|
|
|
+
|
|
|
+ expect(modal.find('input[name="stackRoot"]')).toHaveLength(0);
|
|
|
+
|
|
|
+ const addMappingButton = wrapper
|
|
|
+ .find('Button[data-test-id="add-mapping-button"]')
|
|
|
+ .first();
|
|
|
+ expect(addMappingButton.prop('disabled')).toBe(true);
|
|
|
+ addMappingButton.simulate('click');
|
|
|
+
|
|
|
+ await tick();
|
|
|
+ modal.update();
|
|
|
+
|
|
|
+ expect(modal.find('input[name="stackRoot"]')).toHaveLength(0);
|
|
|
+ });
|
|
|
+
|
|
|
it('create new config', async () => {
|
|
|
const stackRoot = 'my/root';
|
|
|
const sourceRoot = 'hey/dude';
|
|
@@ -107,7 +139,7 @@ describe('IntegrationCodeMappings', function () {
|
|
|
defaultBranch,
|
|
|
}),
|
|
|
});
|
|
|
- wrapper.find('button[aria-label="Add Mapping"]').first().simulate('click');
|
|
|
+ wrapper.find('button[data-test-id="add-mapping-button"]').first().simulate('click');
|
|
|
|
|
|
const modal = await mountGlobalModal();
|
|
|
|