|
@@ -13,6 +13,17 @@ describe('RepositoryRow', function () {
|
|
|
const pendingRepo = TestStubs.Repository({
|
|
|
status: 'pending_deletion',
|
|
|
});
|
|
|
+ const customRepo = TestStubs.Repository({
|
|
|
+ provider: {
|
|
|
+ id: 'integrations:custom_scm',
|
|
|
+ },
|
|
|
+ });
|
|
|
+ const customPendingRepo = TestStubs.Repository({
|
|
|
+ provider: {
|
|
|
+ id: 'integrations:custom_scm',
|
|
|
+ },
|
|
|
+ status: 'pending_deletion',
|
|
|
+ });
|
|
|
const api = new Client();
|
|
|
|
|
|
describe('rendering with access', function () {
|
|
@@ -23,7 +34,12 @@ describe('RepositoryRow', function () {
|
|
|
|
|
|
it('displays provider information', function () {
|
|
|
const wrapper = mountWithTheme(
|
|
|
- <RepositoryRow repository={repository} api={api} orgId={organization.slug} />,
|
|
|
+ <RepositoryRow
|
|
|
+ repository={repository}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
routerContext
|
|
|
);
|
|
|
expect(wrapper.find('strong').text()).toEqual(repository.name);
|
|
@@ -38,7 +54,12 @@ describe('RepositoryRow', function () {
|
|
|
|
|
|
it('displays cancel pending button', function () {
|
|
|
const wrapper = mountWithTheme(
|
|
|
- <RepositoryRow repository={pendingRepo} api={api} orgId={organization.slug} />,
|
|
|
+ <RepositoryRow
|
|
|
+ repository={pendingRepo}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
routerContext
|
|
|
);
|
|
|
|
|
@@ -61,7 +82,12 @@ describe('RepositoryRow', function () {
|
|
|
|
|
|
it('displays disabled trash', function () {
|
|
|
const wrapper = mountWithTheme(
|
|
|
- <RepositoryRow repository={repository} api={api} orgId={organization.slug} />,
|
|
|
+ <RepositoryRow
|
|
|
+ repository={repository}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
routerContext
|
|
|
);
|
|
|
|
|
@@ -72,7 +98,12 @@ describe('RepositoryRow', function () {
|
|
|
|
|
|
it('displays disabled cancel', function () {
|
|
|
const wrapper = mountWithTheme(
|
|
|
- <RepositoryRow repository={pendingRepo} api={api} orgId={organization.slug} />,
|
|
|
+ <RepositoryRow
|
|
|
+ repository={pendingRepo}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
routerContext
|
|
|
);
|
|
|
|
|
@@ -98,7 +129,12 @@ describe('RepositoryRow', function () {
|
|
|
});
|
|
|
|
|
|
const wrapper = mountWithTheme(
|
|
|
- <RepositoryRow repository={repository} api={api} orgId={organization.slug} />,
|
|
|
+ <RepositoryRow
|
|
|
+ repository={repository}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
routerContext
|
|
|
);
|
|
|
wrapper.find('Button[label="delete"]').simulate('click');
|
|
@@ -127,7 +163,12 @@ describe('RepositoryRow', function () {
|
|
|
});
|
|
|
|
|
|
const wrapper = mountWithTheme(
|
|
|
- <RepositoryRow repository={pendingRepo} api={api} orgId={organization.slug} />,
|
|
|
+ <RepositoryRow
|
|
|
+ repository={pendingRepo}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
routerContext
|
|
|
);
|
|
|
wrapper.find('Button[data-test-id="repo-cancel"]').simulate('click');
|
|
@@ -136,4 +177,56 @@ describe('RepositoryRow', function () {
|
|
|
expect(cancel).toHaveBeenCalled();
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ describe('renders custom_scm repo', function () {
|
|
|
+ const organization = TestStubs.Organization({
|
|
|
+ access: ['org:integrations'],
|
|
|
+ features: ['integrations-custom-scm'],
|
|
|
+ });
|
|
|
+ const routerContext = TestStubs.routerContext([{organization}]);
|
|
|
+
|
|
|
+ it('displays edit button', function () {
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ <RepositoryRow
|
|
|
+ repository={customRepo}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
+ routerContext
|
|
|
+ );
|
|
|
+
|
|
|
+ // Trash button should display enabled
|
|
|
+ expect(wrapper.find('Confirm').props().disabled).toEqual(false);
|
|
|
+ // No cancel button
|
|
|
+ expect(wrapper.find('Button[data-test-id="repo-cancel"]')).toHaveLength(0);
|
|
|
+
|
|
|
+ // Edit button should display enabled
|
|
|
+ expect(wrapper.find('Button[label="edit"]').props().disabled).toEqual(false);
|
|
|
+ });
|
|
|
+
|
|
|
+ it('disables edit button when cancel pending', function () {
|
|
|
+ const wrapper = mountWithTheme(
|
|
|
+ <RepositoryRow
|
|
|
+ repository={customPendingRepo}
|
|
|
+ api={api}
|
|
|
+ orgId={organization.slug}
|
|
|
+ organization={organization}
|
|
|
+ />,
|
|
|
+ routerContext
|
|
|
+ );
|
|
|
+
|
|
|
+ // Trash button should be disabled
|
|
|
+ expect(wrapper.find('Confirm').props().disabled).toEqual(true);
|
|
|
+ expect(wrapper.find('Button[label="delete"]').props().disabled).toEqual(true);
|
|
|
+
|
|
|
+ // Edit button should be disabled
|
|
|
+ expect(wrapper.find('Button[label="edit"]').props().disabled).toEqual(true);
|
|
|
+
|
|
|
+ // Cancel button active
|
|
|
+ const cancel = wrapper.find('Button[data-test-id="repo-cancel"]');
|
|
|
+ expect(cancel).toHaveLength(1);
|
|
|
+ expect(cancel.props().disabled).toEqual(false);
|
|
|
+ });
|
|
|
+ });
|
|
|
});
|