Skip to content

Commit 2d797b6

Browse files
committed
fix(perm_spec): add permisson tests
1 parent f9f7c11 commit 2d797b6

1 file changed

Lines changed: 114 additions & 47 deletions

File tree

Lines changed: 114 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,119 @@
11
/// <reference types="Cypress" />
2-
32
context('Permission Manager', () => {
43
describe('working with tree view', () => {
5-
before(() => {
6-
cy.connect()
7-
})
8-
9-
describe('db context menu', () => {
10-
it('display users and groups', function () {
11-
// expand users and groups
12-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item [node-id$=security]').should('be.visible').click();
13-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item [node-id$=security\\/user]').should('be.visible');
14-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item [node-id$=security\\/group]').should('be.visible');
15-
// expand and check users
16-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item [node-id$=security\\/user]').click();
17-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item .fa-user.fs-icon + [node-id*=security\\/user\\/]').should('have.length.gt', 0);
18-
// expand and check groups
19-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item [node-id$=security\\/group]').click();
20-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item .fa-users.fs-icon + [node-id*=security\\/group\\/]').should('have.length.gt', 0);
21-
})
22-
it('open user information', function () {
23-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item [node-id$=security\\/user]').should('be.visible');
24-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item .fa-user.fs-icon + [node-id*=security\\/user\\/]').should('have.length.gt', 0);
25-
const firstUser = cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item .fa-user.fs-icon + [node-id*=security\\/user\\/]').first();
26-
firstUser.then(user => {
27-
const userName = user.text();
28-
firstUser.rightclick();
29-
cy.get('.p-Widget.p-Menu .p-Menu-item[data-type=command][data-command=fusion\\.edit-user]').should('be.visible').click();
30-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogTitle').should('contain.text', 'Edit User: ' + userName);
31-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogContent .pb-body').should('be.visible').find('span + input.theia-input[type=text]').should('have.value', userName);
32-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button.secondary').should('be.visible').click();
33-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell').should('not.exist');
34-
});
35-
})
36-
it('open group information', function () {
37-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item [node-id$=security\\/group]').should('be.visible');
38-
cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item .fa-users.fs-icon + [node-id*=security\\/group\\/]').should('have.length.gt', 0);
39-
const firstGroup = cy.get('.p-Widget.theia-Tree .theia-TreeNode.fusion-item .fa-users.fs-icon + [node-id*=security\\/group\\/]').first();
40-
firstGroup.then(group => {
41-
const groupName = group.text();
42-
firstGroup.rightclick();
43-
cy.get('.p-Widget.p-Menu .p-Menu-item[data-type=command][data-command=fusion\\.edit-group]').should('be.visible').click();
44-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogTitle').should('contain.text', 'Edit Group: ' + groupName);
45-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogContent .pb-body').should('be.visible').find('span + input.theia-input[type=text]').should('have.value', groupName);
46-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell .dialogBlock .dialogControl .theia-button.secondary').should('be.visible').click();
47-
cy.get('.p-Widget.dialogOverlay#theia-dialog-shell').should('not.exist');
48-
});
49-
})
4+
before(() => {
5+
cy.connect()
6+
cy.visit('/')
7+
cy.get(`[node-id=${CSS.escape('admin@' + Cypress.env('API_HOST'))}]`)
8+
.click()
9+
})
10+
11+
// TODO(DP): note how the tree expansion for groups and users is memorized we need to clean that up
12+
13+
describe('the security item', () => {
14+
it('should have user entries', () => {
15+
cy.get('[node-id$=security]')
16+
.click()
17+
cy.get('.ReactVirtualized__Grid')
18+
.contains('Users')
19+
.click()
20+
cy.get('[node-id$=guest]')
21+
.should('be.visible')
5022
})
23+
24+
it('should let us create a new user', () => {
25+
cy.get('[node-id$=security]')
26+
.rightclick()
27+
cy.get('[data-command="fusion.add-user"]')
28+
.contains('Add')
29+
.should('be.visible')
30+
// TODO(DP): finish creating a test user
31+
})
32+
33+
it('should display user properties card', () => {
34+
cy.get('[node-id$=user\\/guest]')
35+
.rightclick()
36+
cy.get('.p-Menu > ul > .p-Menu-item')
37+
.should('be.visible')
38+
.should('have.length', 2)
39+
cy.get('[data-command="fusion.edit-user"]')
40+
.click()
41+
cy.get('.dialogTitle')
42+
.contains('guest')
43+
cy.get('.pb-headers > a')
44+
.should('have.length', 3)
45+
cy.get('.dialogContent')
46+
.contains('Username')
47+
cy.get('.pb-headers > a:nth-child(2)')
48+
.click()
49+
cy.get('.dialogContent')
50+
.contains('Primary group')
51+
cy.get('.pb-headers > a:nth-child(3)')
52+
.click()
53+
cy.get('.active > .pb-tab > .keys > tr')
54+
.should('have.length', 9)
55+
cy.get('.secondary')
56+
.click()
57+
})
58+
59+
it.skip('should let us delete a user', () => {
60+
cy.get('.ReactVirtualized__Grid')
61+
.contains('Users')
62+
.click()
63+
cy.get('[node-id$=use\\/guest]')
64+
.should('be.visible')
65+
})
66+
67+
})
68+
69+
describe('the groups item', () => {
70+
it('should have group entries', () => {
71+
cy.get('.ReactVirtualized__Grid')
72+
.contains('Groups')
73+
.click()
74+
cy.get('[node-id$=group\\/guest]')
75+
.should('be.visible')
76+
})
77+
78+
it('should let us create a new group', () => {
79+
cy.get('[node-id$=security]')
80+
.rightclick()
81+
cy.get('[data-command="fusion.add-group"]')
82+
.contains('Add')
83+
.should('be.visible')
84+
// TODO(DP): finish creating a test group
85+
})
86+
87+
it('should display group properties card', () => {
88+
cy.get('[node-id$=group\\/guest]')
89+
.rightclick()
90+
cy.get('.p-Menu > ul > .p-Menu-item')
91+
.should('be.visible')
92+
.should('have.length', 2)
93+
cy.get('[data-command="fusion.edit-group"]')
94+
.click()
95+
cy.get('.dialogTitle')
96+
.contains('guest')
97+
cy.get('.pb-headers > a')
98+
.should('have.length', 2)
99+
cy.get('.dialogContent')
100+
.contains('Group name')
101+
cy.get('.pb-headers > a:nth-child(2)')
102+
.click()
103+
cy.get('.active > .pb-tab > .keys > tr')
104+
.should('have.length', 3)
105+
cy.get('.secondary')
106+
.click()
107+
})
108+
109+
it.skip('should let us delete a group', () => {
110+
cy.get('.ReactVirtualized__Grid')
111+
.contains('Users')
112+
.click()
113+
cy.get('[node-id$=use\\/guest]')
114+
.should('be.visible')
115+
})
116+
})
117+
51118
})
52-
})
119+
})

0 commit comments

Comments
 (0)