Commit 14ab76f9 authored by Jacques Erasmus's avatar Jacques Erasmus

Merge branch 'ag/346969-just-me-purchase' into 'master'

Update conditions for disabling user numbers input

See merge request gitlab-org/gitlab!76112
parents c7d10cb5 24a6cb8e
...@@ -107,6 +107,9 @@ export default { ...@@ -107,6 +107,9 @@ export default {
? this.$options.i18n.createNewGroupDescription ? this.$options.i18n.createNewGroupDescription
: this.$options.i18n.selectedGroupDescription; : this.$options.i18n.selectedGroupDescription;
}, },
shouldDisableNumberOfUsers() {
return this.isNewUser && !this.isSetupForCompany;
},
}, },
methods: { methods: {
...mapActions([ ...mapActions([
...@@ -182,12 +185,12 @@ export default { ...@@ -182,12 +185,12 @@ export default {
v-model.number="numberOfUsersModel" v-model.number="numberOfUsersModel"
type="number" type="number"
:min="selectedGroupUsers" :min="selectedGroupUsers"
:disabled="!isSetupForCompany" :disabled="shouldDisableNumberOfUsers"
data-qa-selector="number_of_users" data-qa-selector="number_of_users"
/> />
</gl-form-group> </gl-form-group>
<gl-form-group <gl-form-group
v-if="!isSetupForCompany" v-if="shouldDisableNumberOfUsers"
ref="company-link" ref="company-link"
class="label ml-3 align-self-end" class="label ml-3 align-self-end"
> >
......
...@@ -19,14 +19,14 @@ const groupData = [ ...@@ -19,14 +19,14 @@ const groupData = [
{ id: 483, name: 'My second group', users: 12 }, { id: 483, name: 'My second group', users: 12 },
]; ];
const defaultInitialStoreData = { const createDefaultInitialStoreData = (initialData) => ({
availablePlans: JSON.stringify(availablePlans), availablePlans: JSON.stringify(availablePlans),
groupData: JSON.stringify(groupData), groupData: JSON.stringify(groupData),
planId: 'secondPlanId', planId: 'secondPlanId',
namespaceId: null, namespaceId: null,
setupForCompany: 'true',
fullName: 'Full Name', fullName: 'Full Name',
}; ...initialData,
});
describe('Subscription Details', () => { describe('Subscription Details', () => {
const localVue = createLocalVue(); const localVue = createLocalVue();
...@@ -56,12 +56,42 @@ describe('Subscription Details', () => { ...@@ -56,12 +56,42 @@ describe('Subscription Details', () => {
wrapper.destroy(); wrapper.destroy();
}); });
describe('A new user for which we do not have setupForCompany info', () => {
beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS);
const store = createStore(
createDefaultInitialStoreData({ newUser: 'true', setupForCompany: '' }),
);
wrapper = createComponent({ apolloProvider: mockApollo, store });
});
it('should not display an input field for the company or group name', () => {
expect(organizationNameInput().exists()).toBe(false);
});
it('should not display the group select', () => {
expect(groupSelect().exists()).toBe(false);
});
it('should disable the number of users input field', () => {
expect(numberOfUsersInput().attributes('disabled')).toBeDefined();
});
it('should set the min number of users to 1', () => {
expect(numberOfUsersInput().attributes('min')).toBe('1');
});
it('should show a link to change to setting up for a company', () => {
expect(companyLink().exists()).toBe(true);
});
});
describe('A new user setting up for personal use', () => { describe('A new user setting up for personal use', () => {
beforeEach(() => { beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS); const mockApollo = createMockApolloProvider(STEPS);
const store = createStore(defaultInitialStoreData); const store = createStore(
store.state.isNewUser = true; createDefaultInitialStoreData({ newUser: 'true', setupForCompany: 'false' }),
store.state.isSetupForCompany = false; );
wrapper = createComponent({ apolloProvider: mockApollo, store }); wrapper = createComponent({ apolloProvider: mockApollo, store });
}); });
...@@ -89,9 +119,13 @@ describe('Subscription Details', () => { ...@@ -89,9 +119,13 @@ describe('Subscription Details', () => {
describe('A new user setting up for a company or group', () => { describe('A new user setting up for a company or group', () => {
beforeEach(() => { beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS); const mockApollo = createMockApolloProvider(STEPS);
const store = createStore(defaultInitialStoreData); const store = createStore(
store.state.isNewUser = true; createDefaultInitialStoreData({
store.state.groupData = []; newUser: 'true',
groupData: '[]',
setupForCompany: 'true',
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store }); wrapper = createComponent({ apolloProvider: mockApollo, store });
}); });
...@@ -119,9 +153,13 @@ describe('Subscription Details', () => { ...@@ -119,9 +153,13 @@ describe('Subscription Details', () => {
describe('An existing user without any groups', () => { describe('An existing user without any groups', () => {
beforeEach(() => { beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS); const mockApollo = createMockApolloProvider(STEPS);
const store = createStore(defaultInitialStoreData); const store = createStore(
store.state.isNewUser = false; createDefaultInitialStoreData({
store.state.groupData = []; newUser: 'false',
groupData: '[]',
setupForCompany: 'true',
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store }); wrapper = createComponent({ apolloProvider: mockApollo, store });
}); });
...@@ -151,8 +189,12 @@ describe('Subscription Details', () => { ...@@ -151,8 +189,12 @@ describe('Subscription Details', () => {
beforeEach(() => { beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS); const mockApollo = createMockApolloProvider(STEPS);
store = createStore(defaultInitialStoreData); store = createStore(
store.state.isNewUser = false; createDefaultInitialStoreData({
newUser: 'false',
setupForCompany: 'true',
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store }); wrapper = createComponent({ apolloProvider: mockApollo, store });
}); });
...@@ -209,13 +251,18 @@ describe('Subscription Details', () => { ...@@ -209,13 +251,18 @@ describe('Subscription Details', () => {
}); });
}); });
describe('An existing user coming from group billing page', () => { describe('An existing user for which we do not have setupForCompany info coming from group billing page', () => {
let store; let store;
beforeEach(() => { beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS); const mockApollo = createMockApolloProvider(STEPS);
store = createStore({ ...defaultInitialStoreData, namespaceId: '132' }); store = createStore(
store.state.isNewUser = false; createDefaultInitialStoreData({
isNewUser: 'false',
namespaceId: '132',
setupForCompany: '',
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store }); wrapper = createComponent({ apolloProvider: mockApollo, store });
}); });
...@@ -262,13 +309,45 @@ describe('Subscription Details', () => { ...@@ -262,13 +309,45 @@ describe('Subscription Details', () => {
}); });
}); });
describe('An existing user coming from group billing page', () => {
let store;
beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS);
store = createStore(
createDefaultInitialStoreData({
isNewUser: 'false',
namespaceId: '132',
setupForCompany: 'false',
}),
);
wrapper = createComponent({ apolloProvider: mockApollo, store });
});
it('should not display an input field for the company or group name', () => {
expect(organizationNameInput().exists()).toBe(false);
});
it('should display the group select', () => {
expect(groupSelect().exists()).toBe(true);
});
it('should enable the number of users input field', () => {
expect(numberOfUsersInput().attributes('disabled')).toBeUndefined();
});
it('should not show a link to change to setting up for a company', () => {
expect(companyLink().exists()).toBe(false);
});
});
describe('validations', () => { describe('validations', () => {
const isStepValid = () => wrapper.findComponent(Step).props('isValid'); const isStepValid = () => wrapper.findComponent(Step).props('isValid');
let store; let store;
beforeEach(() => { beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS); const mockApollo = createMockApolloProvider(STEPS);
store = createStore(defaultInitialStoreData); store = createStore(createDefaultInitialStoreData());
wrapper = createComponent({ apolloProvider: mockApollo, store }); wrapper = createComponent({ apolloProvider: mockApollo, store });
}); });
...@@ -360,7 +439,7 @@ describe('Subscription Details', () => { ...@@ -360,7 +439,7 @@ describe('Subscription Details', () => {
beforeEach(() => { beforeEach(() => {
const mockApollo = createMockApolloProvider(STEPS, 1); const mockApollo = createMockApolloProvider(STEPS, 1);
store = createStore(defaultInitialStoreData); store = createStore(createDefaultInitialStoreData());
store.commit(types.UPDATE_IS_SETUP_FOR_COMPANY, true); store.commit(types.UPDATE_IS_SETUP_FOR_COMPANY, true);
store.commit(types.UPDATE_SELECTED_PLAN, 'firstPlanId'); store.commit(types.UPDATE_SELECTED_PLAN, 'firstPlanId');
store.commit(types.UPDATE_ORGANIZATION_NAME, 'My Organization'); store.commit(types.UPDATE_ORGANIZATION_NAME, 'My Organization');
......
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