Skip to content

Commit 0c7ab8c

Browse files
committed
Refactor admin permission tests
1 parent 3e8af29 commit 0c7ab8c

File tree

2 files changed

+71
-2
lines changed

2 files changed

+71
-2
lines changed

cypress/e2e/new-roles.cy.js

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
const {
2+
apiKey,
23
env,
3-
[env]: { adminUrl },
4+
[env]: { host, adminUrl },
45
} = Cypress.env()
56

67
const USER_CREDENTIALS = {
@@ -24,6 +25,10 @@ const USER_CREDENTIALS = {
2425
2526
password: 'Password1234',
2627
},
28+
CAN_MANAGE: {
29+
30+
password: 'Password1234',
31+
},
2732
}
2833

2934
describe('Permissions', () => {
@@ -232,7 +237,7 @@ describe('Permissions', () => {
232237
})
233238
})
234239

235-
describe.only('User with `collections.delete` permission', () => {
240+
describe('User with `collections.delete` permission', () => {
236241
beforeEach(() => {
237242
cy.session(
238243
USER_CREDENTIALS.CAN_DELETE.email,
@@ -305,4 +310,68 @@ describe('Permissions', () => {
305310
cy.root().should('not.contain', 'button:contains("Save")')
306311
})
307312
})
313+
314+
describe('User with `settings.edit` permission', () => {
315+
beforeEach(() => {
316+
cy.session(
317+
USER_CREDENTIALS.CAN_MANAGE.email,
318+
() => {
319+
loginUser({
320+
email: USER_CREDENTIALS.CAN_MANAGE.email,
321+
password: USER_CREDENTIALS.CAN_MANAGE.password,
322+
})
323+
},
324+
{
325+
validate() {
326+
cy.wait(1000)
327+
cy.contains('Hello User who can manage settings').should(
328+
'be.visible',
329+
)
330+
},
331+
},
332+
)
333+
})
334+
335+
it('cannot create/clear index', () => {
336+
visitPluginPage()
337+
cy.root().should('not.contain', 'button[role="checkbox"]')
338+
})
339+
340+
it('cannot update indexed data', () => {
341+
visitPluginPage()
342+
cy.root().should('not.contain', 'button:contains("Update")')
343+
})
344+
345+
it('can update settings', () => {
346+
visitPluginPage()
347+
cy.get('button:contains("Settings")').click()
348+
349+
cy.contains('button', 'Save').should('be.visible')
350+
351+
cy.get('input[name="host"]').clear()
352+
cy.get('input[name="host"]').type('http://localhost:7777')
353+
cy.get('input[name="apiKey"]').clear()
354+
cy.get('input[name="apiKey"]').type('test')
355+
356+
cy.contains('button', 'Save').click()
357+
358+
visitPluginPage()
359+
cy.get('button:contains("Settings")').click()
360+
361+
cy.get('input[name="host"]').should('have.value', 'http://localhost:7777')
362+
cy.get('input[name="apiKey"]').should('have.value', 'test')
363+
364+
cy.get('input[name="host"]').clear()
365+
cy.get('input[name="host"]').type(host)
366+
cy.get('input[name="apiKey"]').clear()
367+
cy.get('input[name="apiKey"]').type(apiKey)
368+
cy.contains('button', 'Save').click()
369+
370+
visitPluginPage()
371+
cy.get('button:contains("Settings")').click()
372+
373+
cy.get('input[name="host"]').should('have.value', host)
374+
cy.get('input[name="apiKey"]').should('have.value', apiKey)
375+
})
376+
})
308377
})

playground/pre-seeded-database.db

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)