Commit 6735c99d authored by Vitaly Slobodin's avatar Vitaly Slobodin

Merge branch 'ag/fix-number-of-users' into 'master'

Update condition for submit button on 'just me' cases

See merge request gitlab-org/gitlab!76542
parents f0654595 26df1614
......@@ -72,16 +72,31 @@ export default {
selectedPlanTextLine() {
return sprintf(this.$options.i18n.selectedPlan, { selectedPlanText: this.selectedPlanText });
},
isValid() {
hasAtLeastOneUser() {
return this.numberOfUsers > 0;
},
hasSelectedPlan() {
return !isEmpty(this.selectedPlan);
},
hasOrganizationName() {
return !isEmpty(this.organizationName);
},
hasRequisitesForCompany() {
if (this.isSetupForCompany) {
return this.hasOrganizationName || this.isGroupSelected;
}
return true;
},
isSelectedUsersEqualOrGreaterThanGroupUsers() {
return this.numberOfUsers >= this.selectedGroupUsers;
},
isValid() {
return (
!isEmpty(this.selectedPlan) &&
(!isEmpty(this.organizationName) || this.isGroupSelected) &&
this.numberOfUsers > 0 &&
this.numberOfUsers >= this.selectedGroupUsers
this.hasSelectedPlan &&
this.hasAtLeastOneUser &&
this.isSelectedUsersEqualOrGreaterThanGroupUsers &&
this.hasRequisitesForCompany
);
}
return !isEmpty(this.selectedPlan) && this.numberOfUsers === 1;
},
isShowingGroupSelector() {
return !this.isNewUser && this.groupData.length;
......
......@@ -345,18 +345,19 @@ describe('Subscription Details', () => {
const isStepValid = () => wrapper.findComponent(Step).props('isValid');
let store;
describe('when setting up for a company', () => {
beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS);
store = createStore(createDefaultInitialStoreData());
store = createStore(
createDefaultInitialStoreData({
namespaceId: 483,
newUser: 'true',
setupForCompany: 'true',
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store });
});
describe('when setting up for a company', () => {
beforeEach(() => {
store.commit(types.UPDATE_IS_SETUP_FOR_COMPANY, true);
store.commit(types.UPDATE_SELECTED_PLAN, 'firstPlanId');
store.commit(types.UPDATE_ORGANIZATION_NAME, 'Organization name');
store.commit(types.UPDATE_SELECTED_GROUP, 483);
store.commit(types.UPDATE_NUMBER_OF_USERS, 14);
});
......@@ -398,10 +399,41 @@ describe('Subscription Details', () => {
});
});
describe('when not setting up for a company', () => {
describe('when not setting up for a company and a new user', () => {
beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS);
store = createStore(
createDefaultInitialStoreData({
namespaceId: 111,
newUser: 'true',
setupForCompany: 'false',
groupData: JSON.stringify([{ id: 111, name: 'Just me group', users: 1 }]),
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store });
});
it('should disable the number of users input field', () => {
expect(numberOfUsersInput().attributes('disabled')).toBeDefined();
});
it('should be valid', () => {
expect(isStepValid()).toBe(true);
});
});
describe('when not setting up for a company and not a new user', () => {
beforeEach(() => {
store.commit(types.UPDATE_IS_SETUP_FOR_COMPANY, false);
store.commit(types.UPDATE_NUMBER_OF_USERS, 1);
const mockApollo = createMockApolloProvider(STEPS);
store = createStore(
createDefaultInitialStoreData({
namespaceId: 132,
newUser: 'false',
setupForCompany: 'false',
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store });
store.commit(types.UPDATE_NUMBER_OF_USERS, 3);
});
it('should be valid', () => {
......@@ -416,7 +448,7 @@ describe('Subscription Details', () => {
});
});
it('should be invalid when no number of users is 0', () => {
it('should be invalid when number users is 0', () => {
store.commit(types.UPDATE_NUMBER_OF_USERS, 0);
return localVue.nextTick().then(() => {
......@@ -424,7 +456,15 @@ describe('Subscription Details', () => {
});
});
it('should be invalid when no number of users is greater than 1', () => {
it('should be valid when number of users is greater than group users', () => {
store.commit(types.UPDATE_NUMBER_OF_USERS, 4);
return localVue.nextTick().then(() => {
expect(isStepValid()).toBe(true);
});
});
it('should not be valid when number of users is less than group users', () => {
store.commit(types.UPDATE_NUMBER_OF_USERS, 2);
return localVue.nextTick().then(() => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment