Skip to content

Commit 595bae4

Browse files
committed
Refactor tests for updating permission
1 parent cc4de5e commit 595bae4

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

cypress/e2e/new-roles.cy.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ const USER_CREDENTIALS = {
1616
1717
password: 'Password1234',
1818
},
19+
CAN_UPDATE: {
20+
21+
password: 'Password1234',
22+
},
1923
}
2024

2125
describe('Permissions', () => {
@@ -179,4 +183,48 @@ describe('Permissions', () => {
179183
cy.root().should('not.contain', 'button:contains("Save")')
180184
})
181185
})
186+
187+
describe.only('User with `collections.update` permission', () => {
188+
beforeEach(() => {
189+
cy.session(
190+
USER_CREDENTIALS.CAN_UPDATE.email,
191+
() => {
192+
loginUser({
193+
email: USER_CREDENTIALS.CAN_UPDATE.email,
194+
password: USER_CREDENTIALS.CAN_UPDATE.password,
195+
})
196+
},
197+
{
198+
validate() {
199+
cy.wait(1000)
200+
cy.contains('Hello User who can update').should('be.visible')
201+
},
202+
},
203+
)
204+
})
205+
206+
it('cannot create/clear index', () => {
207+
visitPluginPage()
208+
cy.root().should('not.contain', 'button[role="checkbox"]')
209+
})
210+
211+
it('can update indexed data', () => {
212+
visitPluginPage()
213+
214+
cy.get('tr:contains(user)').first().contains('Yes').should('be.visible')
215+
cy.get('tr:contains(user)')
216+
.first()
217+
.contains('Hooked')
218+
.should('be.visible')
219+
220+
cy.get('tr:contains(user)').first().contains('button', 'Update').click()
221+
222+
cy.contains('div[role="status"]', 'success').should('be.visible')
223+
})
224+
225+
it('cannot change settings', () => {
226+
visitPluginPage()
227+
cy.root().should('not.contain', 'button:contains("Save")')
228+
})
229+
})
182230
})

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
"verify": "strapi-plugin verify",
88
"watch": "strapi-plugin watch",
99
"watch:link": "strapi-plugin watch:link",
10-
"playground:dev": "yarn --cwd ./playground setup && yarn --cwd ./playground dev",
10+
"playground:setup": "yarn --cwd ./playground setup",
11+
"playground:dev": "yarn --cwd ./playground dev",
1112
"playground:build": "yarn --cwd ./playground && yarn --cwd ./playground build",
1213
"playground:ci": "yarn --cwd ./playground ci",
1314
"style": "eslint --ext .js,.test.js .",

playground/pre-seeded-database.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)