web/satellite: project creation tests extended
Change-Id: Ib73b2d556952a6690d3e783e0f15dc16aa51caf7
This commit is contained in:
parent
8e274a5ce4
commit
7f0a6c9eef
@ -44,7 +44,7 @@ export default class NewProjectArea extends Vue {
|
||||
* Life cycle hook after initial render.
|
||||
* Toggles new project button visibility depending on user having his own project or payment method.
|
||||
*/
|
||||
public mounted(): void {
|
||||
public beforeMount(): void {
|
||||
if (ProjectOwning.userHasOwnProject() || !this.$store.getters.isBonusCouponApplied) {
|
||||
this.$store.dispatch(APP_STATE_ACTIONS.HIDE_CREATE_PROJECT_BUTTON);
|
||||
|
||||
|
@ -7,10 +7,11 @@ import NewProjectArea from '@/components/header/NewProjectArea.vue';
|
||||
|
||||
import { appStateModule } from '@/store/modules/appState';
|
||||
import { makePaymentsModule, PAYMENTS_MUTATIONS } from '@/store/modules/payments';
|
||||
import { makeProjectsModule } from '@/store/modules/projects';
|
||||
import { makeUsersModule } from '@/store/modules/users';
|
||||
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
|
||||
import { makeUsersModule, USER_MUTATIONS } from '@/store/modules/users';
|
||||
import { APP_STATE_MUTATIONS } from '@/store/mutationConstants';
|
||||
import { CreditCard } from '@/types/payments';
|
||||
import { BillingHistoryItem, BillingHistoryItemStatus, BillingHistoryItemType, CreditCard } from '@/types/payments';
|
||||
import { Project } from '@/types/projects';
|
||||
import { User } from '@/types/users';
|
||||
import { createLocalVue, mount } from '@vue/test-utils';
|
||||
|
||||
@ -21,9 +22,7 @@ import { UsersApiMock } from '../../mock/api/users';
|
||||
const localVue = createLocalVue();
|
||||
localVue.use(Vuex);
|
||||
|
||||
const user = new User('ownerId');
|
||||
const usersApi = new UsersApiMock();
|
||||
usersApi.setMockUser(user);
|
||||
const usersModule = makeUsersModule(usersApi);
|
||||
const projectsApi = new ProjectsApiMock();
|
||||
const projectsModule = makeProjectsModule(projectsApi);
|
||||
@ -40,6 +39,7 @@ describe('NewProjectArea', () => {
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.findAll('.new-project-button-container').length).toBe(0);
|
||||
});
|
||||
|
||||
it('renders correctly without projects and without payment methods with info tooltip', async () => {
|
||||
@ -53,10 +53,10 @@ describe('NewProjectArea', () => {
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders correctly without projects and with payment method', async () => {
|
||||
it('renders correctly without projects and with credit card', async () => {
|
||||
const creditCard = new CreditCard('id', 1, 2000, 'test', '0000', true);
|
||||
store.commit(PAYMENTS_MUTATIONS.SET_CREDIT_CARDS, [creditCard]);
|
||||
store.commit(APP_STATE_MUTATIONS.SHOW_CREATE_PROJECT_BUTTON);
|
||||
|
||||
await store.commit(PAYMENTS_MUTATIONS.SET_CREDIT_CARDS, [creditCard]);
|
||||
|
||||
const wrapper = mount(NewProjectArea, {
|
||||
store,
|
||||
@ -64,14 +64,34 @@ describe('NewProjectArea', () => {
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.findAll('.new-project-button-container').length).toBe(1);
|
||||
|
||||
await wrapper.find('.new-project-button-container').trigger('click');
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it('renders correctly with projects and with payment method', () => {
|
||||
it('renders correctly without projects and with completed 50$ transaction', () => {
|
||||
const billingTransactionItem = new BillingHistoryItem('itemId', 'test', 50, 50,
|
||||
BillingHistoryItemStatus.Completed, 'test', new Date(), new Date(), BillingHistoryItemType.Transaction);
|
||||
store.commit(PAYMENTS_MUTATIONS.CLEAR);
|
||||
store.commit(PAYMENTS_MUTATIONS.SET_BILLING_HISTORY, [billingTransactionItem]);
|
||||
|
||||
const wrapper = mount(NewProjectArea, {
|
||||
store,
|
||||
localVue,
|
||||
});
|
||||
|
||||
expect(wrapper.findAll('.new-project-button-container').length).toBe(1);
|
||||
});
|
||||
|
||||
it('user is unable to create project with his project and with payment method', () => {
|
||||
const user = new User('ownerId', 'test', 'test', 'test@test.test', 'test', 'test');
|
||||
const project = new Project('id', 'test', 'test', 'test', 'ownerId', true);
|
||||
store.commit(APP_STATE_MUTATIONS.TOGGLE_NEW_PROJECT_POPUP);
|
||||
store.commit(PAYMENTS_MUTATIONS.SET_BILLING_HISTORY, []);
|
||||
store.commit(USER_MUTATIONS.SET_USER, user);
|
||||
store.commit(PROJECTS_MUTATIONS.SET_PROJECTS, [project]);
|
||||
store.commit(APP_STATE_MUTATIONS.HIDE_CREATE_PROJECT_BUTTON);
|
||||
|
||||
const wrapper = mount(NewProjectArea, {
|
||||
@ -79,6 +99,6 @@ describe('NewProjectArea', () => {
|
||||
localVue,
|
||||
});
|
||||
|
||||
expect(wrapper).toMatchSnapshot();
|
||||
expect(wrapper.findAll('.new-project-button-container').length).toBe(0);
|
||||
});
|
||||
});
|
||||
|
@ -1,14 +1,6 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`NewProjectArea renders correctly with projects and with payment method 1`] = `
|
||||
<div class="new-project-container">
|
||||
<!---->
|
||||
<!---->
|
||||
<!---->
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`NewProjectArea renders correctly without projects and with payment method 1`] = `
|
||||
exports[`NewProjectArea renders correctly without projects and with credit card 1`] = `
|
||||
<div class="new-project-container">
|
||||
<!---->
|
||||
<div id="newProjectButton" class="new-project-button-container">
|
||||
@ -18,7 +10,7 @@ exports[`NewProjectArea renders correctly without projects and with payment meth
|
||||
</div>
|
||||
`;
|
||||
|
||||
exports[`NewProjectArea renders correctly without projects and with payment method 2`] = `
|
||||
exports[`NewProjectArea renders correctly without projects and with credit card 2`] = `
|
||||
<div class="new-project-container">
|
||||
<!---->
|
||||
<div id="newProjectButton" class="new-project-button-container">
|
||||
|
Loading…
Reference in New Issue
Block a user