Skip to content

Commit d3e7713

Browse files
authored
test: Split sharing tests into sharing/ directory (#22849)
1 parent e9c4c8d commit d3e7713

File tree

2 files changed

+176
-169
lines changed

2 files changed

+176
-169
lines changed
Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
import { test, expect } from '../../../fixtures/base';
2+
3+
const OWNER_EMAIL = '[email protected]';
4+
const ADMIN_EMAIL = '[email protected]';
5+
const MEMBER_0_EMAIL = '[email protected]'; // U2
6+
7+
test.describe('@isolated', () => {
8+
test.describe('Credential Usage in Cross Shared Workflows', () => {
9+
test.beforeEach(async ({ n8n, api }) => {
10+
await api.resetDatabase();
11+
await api.enableFeature('sharing');
12+
await api.enableFeature('advancedPermissions');
13+
await api.enableFeature('projectRole:admin');
14+
await api.enableFeature('projectRole:editor');
15+
await api.setMaxTeamProjectsQuota(-1);
16+
17+
await n8n.api.signin('owner');
18+
await n8n.navigate.toCredentials();
19+
});
20+
21+
test('should only show credentials from the same team project', async ({ n8n }) => {
22+
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
23+
24+
const devProject = await n8n.projectComposer.createProject('Development');
25+
await n8n.projectTabs.clickCredentialsTab();
26+
await n8n.credentialsComposer.createFromList(
27+
'Notion API',
28+
{ apiKey: 'test' },
29+
{ projectId: devProject.projectId },
30+
);
31+
32+
const testProject = await n8n.projectComposer.createProject('Test');
33+
await n8n.projectTabs.clickCredentialsTab();
34+
await n8n.credentialsComposer.createFromList(
35+
'Notion API',
36+
{ apiKey: 'test' },
37+
{ projectId: testProject.projectId },
38+
);
39+
40+
await n8n.projectTabs.clickWorkflowsTab();
41+
await n8n.workflows.clickNewWorkflowCard();
42+
43+
await n8n.canvas.addNode('Notion');
44+
await n8n.canvas.getFirstAction().click();
45+
46+
// Only Test project credential visible
47+
await n8n.ndv.getNodeCredentialsSelect().click();
48+
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(1);
49+
});
50+
51+
test('should only show credentials in their personal project for members', async ({ n8n }) => {
52+
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
53+
54+
await n8n.navigate.toCredentials();
55+
await n8n.credentials.addResource.credential();
56+
await n8n.credentials.selectCredentialType('Notion API');
57+
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
58+
await n8n.credentials.credentialModal.save();
59+
60+
await n8n.credentials.credentialModal.changeTab('Sharing');
61+
await n8n.credentials.credentialModal.addUserToSharing(MEMBER_0_EMAIL);
62+
await n8n.credentials.credentialModal.saveSharing();
63+
await n8n.credentials.credentialModal.close();
64+
65+
await n8n.api.signin('member', 0);
66+
await n8n.navigate.toCredentials();
67+
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
68+
69+
await n8n.navigate.toWorkflow('new');
70+
71+
await n8n.canvas.addNode('Notion');
72+
await n8n.canvas.getFirstAction().click();
73+
74+
// Own credential and shared credential visible
75+
await n8n.ndv.getNodeCredentialsSelect().click();
76+
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(2);
77+
});
78+
79+
test('should only show credentials in their personal project for members if the workflow was shared with them', async ({
80+
n8n,
81+
}) => {
82+
const workflowName = 'Test workflow';
83+
84+
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
85+
86+
await n8n.navigate.toWorkflow('new');
87+
await n8n.canvas.setWorkflowName(workflowName);
88+
await n8n.page.keyboard.press('Enter');
89+
await n8n.canvas.openShareModal();
90+
await n8n.workflowSharingModal.addUser(MEMBER_0_EMAIL);
91+
await n8n.workflowSharingModal.save();
92+
93+
await n8n.api.signin('member', 0);
94+
await n8n.navigate.toCredentials();
95+
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
96+
97+
await n8n.navigate.toWorkflows();
98+
await n8n.workflows.cards.getWorkflow(workflowName).click();
99+
100+
await n8n.canvas.addNode('Notion');
101+
await n8n.canvas.getFirstAction().click();
102+
103+
// Only own credential visible (not owner's)
104+
await n8n.ndv.getNodeCredentialsSelect().click();
105+
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(1);
106+
});
107+
108+
test("should show all credentials from all personal projects the workflow's been shared into for the global owner", async ({
109+
n8n,
110+
}) => {
111+
const workflowName = 'Test workflow';
112+
113+
await n8n.api.signin('member', 1);
114+
await n8n.navigate.toCredentials();
115+
await n8n.credentials.addResource.credential();
116+
await n8n.credentials.selectCredentialType('Notion API');
117+
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
118+
await n8n.credentials.credentialModal.save();
119+
await n8n.credentials.credentialModal.close();
120+
121+
await n8n.api.signin('admin');
122+
await n8n.navigate.toCredentials();
123+
await n8n.credentials.addResource.credential();
124+
await n8n.credentials.selectCredentialType('Notion API');
125+
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
126+
await n8n.credentials.credentialModal.save();
127+
await n8n.credentials.credentialModal.close();
128+
129+
await n8n.api.signin('member', 0);
130+
await n8n.navigate.toCredentials();
131+
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
132+
await n8n.navigate.toWorkflow('new');
133+
await n8n.canvas.setWorkflowName(workflowName);
134+
await n8n.page.keyboard.press('Enter');
135+
await n8n.canvas.openShareModal();
136+
await n8n.workflowSharingModal.addUser(OWNER_EMAIL);
137+
await n8n.workflowSharingModal.addUser(ADMIN_EMAIL);
138+
await n8n.workflowSharingModal.save();
139+
140+
await n8n.api.signin('owner');
141+
await n8n.navigate.toCredentials();
142+
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
143+
await n8n.navigate.toWorkflows();
144+
await n8n.workflows.cards.getWorkflow(workflowName).click();
145+
146+
await n8n.canvas.addNode('Notion');
147+
await n8n.canvas.getFirstAction().click();
148+
149+
// Owner sees 3 credentials: admin's, U2's, owner's
150+
await n8n.ndv.getNodeCredentialsSelect().click();
151+
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(3);
152+
});
153+
154+
test('should show all personal credentials if the global owner owns the workflow', async ({
155+
n8n,
156+
}) => {
157+
await n8n.api.signin('member', 0);
158+
await n8n.navigate.toCredentials();
159+
await n8n.credentials.addResource.credential();
160+
await n8n.credentials.selectCredentialType('Notion API');
161+
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
162+
await n8n.credentials.credentialModal.save();
163+
await n8n.credentials.credentialModal.close();
164+
165+
await n8n.api.signin('owner');
166+
await n8n.navigate.toWorkflow('new');
167+
await n8n.canvas.addNode('Notion');
168+
await n8n.canvas.getFirstAction().click();
169+
170+
// Owner sees member's credential (global owner privilege)
171+
await n8n.ndv.getNodeCredentialsSelect().click();
172+
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(1);
173+
});
174+
});
175+
});

packages/testing/playwright/tests/ui/17-sharing.spec.ts renamed to packages/testing/playwright/tests/ui/sharing/sharing.spec.ts

Lines changed: 1 addition & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { test, expect } from '../../fixtures/base';
1+
import { test, expect } from '../../../fixtures/base';
22

33
const OWNER_EMAIL = '[email protected]';
44
const ADMIN_EMAIL = '[email protected]';
@@ -302,172 +302,4 @@ test.describe('@isolated', () => {
302302
).toHaveCount(1);
303303
});
304304
});
305-
306-
test.describe('Credential Usage in Cross Shared Workflows', () => {
307-
test.beforeEach(async ({ n8n, api }) => {
308-
await api.resetDatabase();
309-
await api.enableFeature('sharing');
310-
await api.enableFeature('advancedPermissions');
311-
await api.enableFeature('projectRole:admin');
312-
await api.enableFeature('projectRole:editor');
313-
await api.setMaxTeamProjectsQuota(-1);
314-
315-
await n8n.api.signin('owner');
316-
await n8n.navigate.toCredentials();
317-
});
318-
319-
test('should only show credentials from the same team project', async ({ n8n }) => {
320-
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
321-
322-
const devProject = await n8n.projectComposer.createProject('Development');
323-
await n8n.projectTabs.clickCredentialsTab();
324-
await n8n.credentialsComposer.createFromList(
325-
'Notion API',
326-
{ apiKey: 'test' },
327-
{ projectId: devProject.projectId },
328-
);
329-
330-
const testProject = await n8n.projectComposer.createProject('Test');
331-
await n8n.projectTabs.clickCredentialsTab();
332-
await n8n.credentialsComposer.createFromList(
333-
'Notion API',
334-
{ apiKey: 'test' },
335-
{ projectId: testProject.projectId },
336-
);
337-
338-
await n8n.projectTabs.clickWorkflowsTab();
339-
await n8n.workflows.clickNewWorkflowCard();
340-
341-
await n8n.canvas.addNode('Notion');
342-
await n8n.canvas.getFirstAction().click();
343-
344-
// Only Test project credential visible
345-
await n8n.ndv.getNodeCredentialsSelect().click();
346-
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(1);
347-
});
348-
349-
test('should only show credentials in their personal project for members', async ({ n8n }) => {
350-
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
351-
352-
await n8n.navigate.toCredentials();
353-
await n8n.credentials.addResource.credential();
354-
await n8n.credentials.selectCredentialType('Notion API');
355-
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
356-
await n8n.credentials.credentialModal.save();
357-
358-
await n8n.credentials.credentialModal.changeTab('Sharing');
359-
await n8n.credentials.credentialModal.addUserToSharing(MEMBER_0_EMAIL);
360-
await n8n.credentials.credentialModal.saveSharing();
361-
await n8n.credentials.credentialModal.close();
362-
363-
await n8n.api.signin('member', 0);
364-
await n8n.navigate.toCredentials();
365-
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
366-
367-
await n8n.navigate.toWorkflow('new');
368-
369-
await n8n.canvas.addNode('Notion');
370-
await n8n.canvas.getFirstAction().click();
371-
372-
// Own credential and shared credential visible
373-
await n8n.ndv.getNodeCredentialsSelect().click();
374-
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(2);
375-
});
376-
377-
test('should only show credentials in their personal project for members if the workflow was shared with them', async ({
378-
n8n,
379-
}) => {
380-
const workflowName = 'Test workflow';
381-
382-
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
383-
384-
await n8n.navigate.toWorkflow('new');
385-
await n8n.canvas.setWorkflowName(workflowName);
386-
await n8n.page.keyboard.press('Enter');
387-
await n8n.canvas.openShareModal();
388-
await n8n.workflowSharingModal.addUser(MEMBER_0_EMAIL);
389-
await n8n.workflowSharingModal.save();
390-
391-
await n8n.api.signin('member', 0);
392-
await n8n.navigate.toCredentials();
393-
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
394-
395-
await n8n.navigate.toWorkflows();
396-
await n8n.workflows.cards.getWorkflow(workflowName).click();
397-
398-
await n8n.canvas.addNode('Notion');
399-
await n8n.canvas.getFirstAction().click();
400-
401-
// Only own credential visible (not owner's)
402-
await n8n.ndv.getNodeCredentialsSelect().click();
403-
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(1);
404-
});
405-
406-
test("should show all credentials from all personal projects the workflow's been shared into for the global owner", async ({
407-
n8n,
408-
}) => {
409-
const workflowName = 'Test workflow';
410-
411-
await n8n.api.signin('member', 1);
412-
await n8n.navigate.toCredentials();
413-
await n8n.credentials.addResource.credential();
414-
await n8n.credentials.selectCredentialType('Notion API');
415-
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
416-
await n8n.credentials.credentialModal.save();
417-
await n8n.credentials.credentialModal.close();
418-
419-
await n8n.api.signin('admin');
420-
await n8n.navigate.toCredentials();
421-
await n8n.credentials.addResource.credential();
422-
await n8n.credentials.selectCredentialType('Notion API');
423-
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
424-
await n8n.credentials.credentialModal.save();
425-
await n8n.credentials.credentialModal.close();
426-
427-
await n8n.api.signin('member', 0);
428-
await n8n.navigate.toCredentials();
429-
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
430-
await n8n.navigate.toWorkflow('new');
431-
await n8n.canvas.setWorkflowName(workflowName);
432-
await n8n.page.keyboard.press('Enter');
433-
await n8n.canvas.openShareModal();
434-
await n8n.workflowSharingModal.addUser(OWNER_EMAIL);
435-
await n8n.workflowSharingModal.addUser(ADMIN_EMAIL);
436-
await n8n.workflowSharingModal.save();
437-
438-
await n8n.api.signin('owner');
439-
await n8n.navigate.toCredentials();
440-
await n8n.credentialsComposer.createFromList('Notion API', { apiKey: 'test' });
441-
await n8n.navigate.toWorkflows();
442-
await n8n.workflows.cards.getWorkflow(workflowName).click();
443-
444-
await n8n.canvas.addNode('Notion');
445-
await n8n.canvas.getFirstAction().click();
446-
447-
// Owner sees 3 credentials: admin's, U2's, owner's
448-
await n8n.ndv.getNodeCredentialsSelect().click();
449-
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(3);
450-
});
451-
452-
test('should show all personal credentials if the global owner owns the workflow', async ({
453-
n8n,
454-
}) => {
455-
await n8n.api.signin('member', 0);
456-
await n8n.navigate.toCredentials();
457-
await n8n.credentials.addResource.credential();
458-
await n8n.credentials.selectCredentialType('Notion API');
459-
await n8n.credentials.credentialModal.fillField('apiKey', 'test');
460-
await n8n.credentials.credentialModal.save();
461-
await n8n.credentials.credentialModal.close();
462-
463-
await n8n.api.signin('owner');
464-
await n8n.navigate.toWorkflow('new');
465-
await n8n.canvas.addNode('Notion');
466-
await n8n.canvas.getFirstAction().click();
467-
468-
// Owner sees member's credential (global owner privilege)
469-
await n8n.ndv.getNodeCredentialsSelect().click();
470-
await expect(n8n.ndv.getVisiblePopper().locator('li')).toHaveCount(1);
471-
});
472-
});
473305
});

0 commit comments

Comments
 (0)