9ace375ee0
This change switches the backend logic to use the new DB column on the users table to restrict project creation. Furthermore it back fills the existing limits from registration tokens to the new column to ensure no users are reset to the new default. UI is updated to reflect ability to create several projects Change-Id: Ie29157430ae6b065411ca4c4557c9f1be69cdc4f
41 lines
1.3 KiB
TypeScript
41 lines
1.3 KiB
TypeScript
// Copyright (C) 2020 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
import Vuex from 'vuex';
|
|
|
|
import { makeProjectsModule, PROJECTS_MUTATIONS } from '@/store/modules/projects';
|
|
import { makeUsersModule, USER_MUTATIONS } from '@/store/modules/users';
|
|
import { Project } from '@/types/projects';
|
|
import { User } from '@/types/users';
|
|
import { ProjectOwning } from '@/utils/projectOwning';
|
|
import { createLocalVue } from '@vue/test-utils';
|
|
|
|
import { ProjectsApiMock } from '../mock/api/projects';
|
|
import { UsersApiMock } from '../mock/api/users';
|
|
|
|
const usersApi = new UsersApiMock();
|
|
const usersModule = makeUsersModule(usersApi);
|
|
const projectsApi = new ProjectsApiMock();
|
|
const projectsModule = makeProjectsModule(projectsApi);
|
|
|
|
const localVue = createLocalVue();
|
|
localVue.use(Vuex);
|
|
|
|
const store = new Vuex.Store({ modules: { usersModule, projectsModule }});
|
|
|
|
describe('projectOwning', () => {
|
|
it('user has no project', () => {
|
|
const user = new User('ownerId');
|
|
store.commit(USER_MUTATIONS.SET_USER, user);
|
|
|
|
expect(new ProjectOwning(store).usersProjectsCount()).toBe(0);
|
|
});
|
|
|
|
it('user has project', () => {
|
|
const project = new Project('id', 'test', 'test', 'test', 'ownerId', true);
|
|
store.commit(PROJECTS_MUTATIONS.ADD, project);
|
|
|
|
expect(new ProjectOwning(store).usersProjectsCount()).toBe(1);
|
|
});
|
|
});
|