mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 01:56:46 +00:00
refactor(editor): Enable collaboration features only in NodeView v2 (no-changelog) (#10756)
This commit is contained in:
committed by
GitHub
parent
ee5fbc543c
commit
a1e011dd2a
@@ -1,19 +1,20 @@
|
||||
import Container from 'typedi';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
import { CollaborationService } from '@/collaboration/collaboration.service';
|
||||
import { Push } from '@/push';
|
||||
import { CacheService } from '@/services/cache/cache.service';
|
||||
import { mock } from 'jest-mock-extended';
|
||||
import * as testDb from '../shared/test-db';
|
||||
import Container from 'typedi';
|
||||
import type { User } from '@/databases/entities/user';
|
||||
import { createMember, createOwner } from '@test-integration/db/users';
|
||||
import type {
|
||||
WorkflowClosedMessage,
|
||||
WorkflowOpenedMessage,
|
||||
} from '@/collaboration/collaboration.message';
|
||||
import { createWorkflow, shareWorkflowWithUsers } from '@test-integration/db/workflows';
|
||||
import type { WorkflowEntity } from '@/databases/entities/workflow-entity';
|
||||
|
||||
import { mockInstance } from '@test/mocking';
|
||||
import { UserService } from '@/services/user.service';
|
||||
import * as testDb from '@test-integration/test-db';
|
||||
import { createWorkflow, shareWorkflowWithUsers } from '@test-integration/db/workflows';
|
||||
import { createMember, createOwner } from '@test-integration/db/users';
|
||||
|
||||
describe('CollaborationService', () => {
|
||||
mockInstance(Push, new Push(mock()));
|
||||
@@ -23,7 +24,6 @@ describe('CollaborationService', () => {
|
||||
let memberWithoutAccess: User;
|
||||
let memberWithAccess: User;
|
||||
let workflow: WorkflowEntity;
|
||||
let userService: UserService;
|
||||
let cacheService: CacheService;
|
||||
|
||||
beforeAll(async () => {
|
||||
@@ -31,7 +31,6 @@ describe('CollaborationService', () => {
|
||||
|
||||
pushService = Container.get(Push);
|
||||
collaborationService = Container.get(CollaborationService);
|
||||
userService = Container.get(UserService);
|
||||
cacheService = Container.get(CacheService);
|
||||
|
||||
await cacheService.init();
|
||||
@@ -69,7 +68,7 @@ describe('CollaborationService', () => {
|
||||
};
|
||||
|
||||
describe('workflow opened message', () => {
|
||||
it('should emit activeWorkflowUsersChanged after workflowOpened', async () => {
|
||||
it('should emit collaboratorsChanged after workflowOpened', async () => {
|
||||
// Arrange
|
||||
const sendToUsersSpy = jest.spyOn(pushService, 'sendToUsers');
|
||||
|
||||
@@ -80,15 +79,12 @@ describe('CollaborationService', () => {
|
||||
// Assert
|
||||
expect(sendToUsersSpy).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
'activeWorkflowUsersChanged',
|
||||
'collaboratorsChanged',
|
||||
{
|
||||
activeUsers: [
|
||||
collaborators: [
|
||||
{
|
||||
lastSeen: expect.any(String),
|
||||
user: {
|
||||
...(await userService.toPublic(owner)),
|
||||
isPending: false,
|
||||
},
|
||||
user: owner.toIUser(),
|
||||
},
|
||||
],
|
||||
workflowId: workflow.id,
|
||||
@@ -97,9 +93,9 @@ describe('CollaborationService', () => {
|
||||
);
|
||||
expect(sendToUsersSpy).toHaveBeenNthCalledWith(
|
||||
2,
|
||||
'activeWorkflowUsersChanged',
|
||||
'collaboratorsChanged',
|
||||
{
|
||||
activeUsers: expect.arrayContaining([
|
||||
collaborators: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
lastSeen: expect.any(String),
|
||||
user: expect.objectContaining({
|
||||
@@ -119,7 +115,7 @@ describe('CollaborationService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should not emit activeWorkflowUsersChanged if user don't have access to the workflow", async () => {
|
||||
it("should not emit collaboratorsChanged if user don't have access to the workflow", async () => {
|
||||
const sendToUsersSpy = jest.spyOn(pushService, 'sendToUsers');
|
||||
|
||||
// Act
|
||||
@@ -131,7 +127,7 @@ describe('CollaborationService', () => {
|
||||
});
|
||||
|
||||
describe('workflow closed message', () => {
|
||||
it('should not emit activeWorkflowUsersChanged after workflowClosed when there are no active users', async () => {
|
||||
it('should not emit collaboratorsChanged after workflowClosed when there are no active users', async () => {
|
||||
// Arrange
|
||||
const sendToUsersSpy = jest.spyOn(pushService, 'sendToUsers');
|
||||
await sendWorkflowOpenedMessage(workflow.id, owner.id);
|
||||
@@ -144,7 +140,7 @@ describe('CollaborationService', () => {
|
||||
expect(sendToUsersSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should emit activeWorkflowUsersChanged after workflowClosed when there are active users', async () => {
|
||||
it('should emit collaboratorsChanged after workflowClosed when there are active users', async () => {
|
||||
// Arrange
|
||||
const sendToUsersSpy = jest.spyOn(pushService, 'sendToUsers');
|
||||
await sendWorkflowOpenedMessage(workflow.id, owner.id);
|
||||
@@ -156,9 +152,9 @@ describe('CollaborationService', () => {
|
||||
|
||||
// Assert
|
||||
expect(sendToUsersSpy).toHaveBeenCalledWith(
|
||||
'activeWorkflowUsersChanged',
|
||||
'collaboratorsChanged',
|
||||
{
|
||||
activeUsers: expect.arrayContaining([
|
||||
collaborators: expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
lastSeen: expect.any(String),
|
||||
user: expect.objectContaining({
|
||||
@@ -172,7 +168,7 @@ describe('CollaborationService', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("should not emit activeWorkflowUsersChanged if user don't have access to the workflow", async () => {
|
||||
it("should not emit collaboratorsChanged if user don't have access to the workflow", async () => {
|
||||
// Arrange
|
||||
const sendToUsersSpy = jest.spyOn(pushService, 'sendToUsers');
|
||||
await sendWorkflowOpenedMessage(workflow.id, owner.id);
|
||||
|
||||
Reference in New Issue
Block a user