mirror of
https://github.com/n8n-io/n8n.git
synced 2025-03-05 20:50:17 -08:00
fix(editor): Fix community check (#11979)
This commit is contained in:
parent
40a41dd192
commit
af0398a5e3
|
@ -57,7 +57,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
|
|
||||||
const personalProjectId = 'personal-project';
|
const personalProjectId = 'personal-project';
|
||||||
projectsStore.canCreateProjects = false;
|
projectsStore.isTeamProjectFeatureEnabled = false;
|
||||||
projectsStore.personalProject = { id: personalProjectId } as Project;
|
projectsStore.personalProject = { id: personalProjectId } as Project;
|
||||||
const { menu } = useGlobalEntityCreation();
|
const { menu } = useGlobalEntityCreation();
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
it('should use currentProject', () => {
|
it('should use currentProject', () => {
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
|
|
||||||
projectsStore.canCreateProjects = true;
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
projectsStore.currentProject = { id: currentProjectId } as Project;
|
projectsStore.currentProject = { id: currentProjectId } as Project;
|
||||||
|
|
||||||
const { menu } = useGlobalEntityCreation(false);
|
const { menu } = useGlobalEntityCreation(false);
|
||||||
|
@ -107,7 +107,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
it('should be disabled in readOnly', () => {
|
it('should be disabled in readOnly', () => {
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
|
|
||||||
projectsStore.canCreateProjects = true;
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
projectsStore.currentProject = { id: currentProjectId } as Project;
|
projectsStore.currentProject = { id: currentProjectId } as Project;
|
||||||
|
|
||||||
const sourceControl = mockedStore(useSourceControlStore);
|
const sourceControl = mockedStore(useSourceControlStore);
|
||||||
|
@ -131,7 +131,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
it('should be disabled based in scopes', () => {
|
it('should be disabled based in scopes', () => {
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
|
|
||||||
projectsStore.canCreateProjects = true;
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
projectsStore.currentProject = { id: currentProjectId, scopes: [] } as unknown as Project;
|
projectsStore.currentProject = { id: currentProjectId, scopes: [] } as unknown as Project;
|
||||||
|
|
||||||
const { menu } = useGlobalEntityCreation(false);
|
const { menu } = useGlobalEntityCreation(false);
|
||||||
|
@ -155,7 +155,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
|
|
||||||
const personalProjectId = 'personal-project';
|
const personalProjectId = 'personal-project';
|
||||||
projectsStore.canCreateProjects = true;
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
projectsStore.personalProject = { id: personalProjectId } as Project;
|
projectsStore.personalProject = { id: personalProjectId } as Project;
|
||||||
projectsStore.myProjects = [
|
projectsStore.myProjects = [
|
||||||
{ id: '1', name: '1', type: 'team' },
|
{ id: '1', name: '1', type: 'team' },
|
||||||
|
@ -173,7 +173,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
describe('handleSelect()', () => {
|
describe('handleSelect()', () => {
|
||||||
it('should only handle create-project', () => {
|
it('should only handle create-project', () => {
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
projectsStore.canCreateProjects = true;
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
const { handleSelect } = useGlobalEntityCreation(true);
|
const { handleSelect } = useGlobalEntityCreation(true);
|
||||||
handleSelect('dummy');
|
handleSelect('dummy');
|
||||||
expect(projectsStore.createProject).not.toHaveBeenCalled();
|
expect(projectsStore.createProject).not.toHaveBeenCalled();
|
||||||
|
@ -182,6 +182,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
it('creates a new project', async () => {
|
it('creates a new project', async () => {
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
projectsStore.canCreateProjects = true;
|
projectsStore.canCreateProjects = true;
|
||||||
projectsStore.createProject.mockResolvedValueOnce({ name: 'test', id: '1' } as Project);
|
projectsStore.createProject.mockResolvedValueOnce({ name: 'test', id: '1' } as Project);
|
||||||
|
|
||||||
|
@ -198,6 +199,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
it('handles create project error', async () => {
|
it('handles create project error', async () => {
|
||||||
const toast = useToast();
|
const toast = useToast();
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
projectsStore.canCreateProjects = true;
|
projectsStore.canCreateProjects = true;
|
||||||
projectsStore.createProject.mockRejectedValueOnce(new Error('error'));
|
projectsStore.createProject.mockRejectedValueOnce(new Error('error'));
|
||||||
|
|
||||||
|
@ -211,6 +213,7 @@ describe('useGlobalEntityCreation', () => {
|
||||||
it('redirects when project limit has been reached', () => {
|
it('redirects when project limit has been reached', () => {
|
||||||
const projectsStore = mockedStore(useProjectsStore);
|
const projectsStore = mockedStore(useProjectsStore);
|
||||||
projectsStore.canCreateProjects = false;
|
projectsStore.canCreateProjects = false;
|
||||||
|
projectsStore.isTeamProjectFeatureEnabled = true;
|
||||||
const redirect = usePageRedirectionHelper();
|
const redirect = usePageRedirectionHelper();
|
||||||
|
|
||||||
const { handleSelect } = useGlobalEntityCreation(true);
|
const { handleSelect } = useGlobalEntityCreation(true);
|
||||||
|
|
|
@ -50,7 +50,7 @@ export const useGlobalEntityCreation = (
|
||||||
|
|
||||||
const menu = computed<Item[]>(() => {
|
const menu = computed<Item[]>(() => {
|
||||||
// Community
|
// Community
|
||||||
if (!projectsStore.canCreateProjects) {
|
if (!projectsStore.isTeamProjectFeatureEnabled) {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
id: 'workflow',
|
id: 'workflow',
|
||||||
|
|
Loading…
Reference in a new issue