Skip to content

Commit a3346dd

Browse files
committed
test: user without access wannot see plugin
1 parent b057ced commit a3346dd

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

cypress/e2e/new-roles.cy.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,15 @@ describe('wip test refactor', () => {
101101
expect(true).to.be.true
102102
})
103103

104-
it('should not see plugin in sidepanel', () => {
105-
loginAsAdmin(userCredentials.email, userCredentials.password).then(
106-
response => {
107-
expect(response.status).to.eq(200)
108-
},
109-
)
104+
it('should not see the Meilisearch plugin in sidepanel', () => {
105+
cy.login({
106+
adminUrl: 'http://localhost:1337/admin',
107+
email: userCredentials.email,
108+
password: userCredentials.password,
109+
shouldContain: 'Hello Admin No Access',
110+
})
111+
cy.visit('http://localhost:1337/admin')
112+
cy.get('nav').should('not.contain', 'a[aria-label="Meilisearch"]')
110113
})
111114
})
112115

cypress/e2e/utils.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export const STRAPI_ADMIN_ROLES = {
2+
SUPER_ADMIN: 1,
3+
ADMIN: 2,
4+
EDITOR: 3,
5+
AUTHOR: 4,
6+
}

cypress/support/commands.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,21 @@
3030
* @param {string} email
3131
* @param {string} password
3232
*/
33-
const login = ({ adminUrl, email, password }) => {
33+
const login = ({ adminUrl, email, password, shouldContain }) => {
3434
cy.session(
3535
[email, password],
3636
() => {
3737
cy.visit(adminUrl)
38-
cy.get('form', { timeout: 10000 }).should('be.visible')
38+
cy.get('form').should('be.visible')
3939
cy.get('input[name="email"]').type(email)
4040
cy.get('input[name="password"]').type(password)
4141
cy.get('button[role="checkbox"]').click()
4242
cy.get('button[type="submit"]').click()
4343
},
4444
{
4545
validate() {
46-
cy.wait(1000)
4746
cy.visit(adminUrl)
48-
cy.contains('Welcome 👋', { timeout: 10000 }).should('be.visible')
47+
cy.contains(shouldContain).should('be.visible')
4948
},
5049
},
5150
)

0 commit comments

Comments
 (0)