-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
FKS-1145 add menu test for different user roles
- Loading branch information
Showing
4 changed files
with
156 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import {wait} from "@testing-library/user-event/dist/utils"; | ||
|
||
|
||
describe('Check menu items for', () => { | ||
|
||
it('Systemadministrator', () => { | ||
cy.setCookie('cypresstestuser', 'sa') | ||
wait(1000) | ||
cy.getCookie('cypresstestuser').then(cookie => expect(cookie.value).to.be.equal('sa')) | ||
|
||
cy.goToHome(); | ||
cy.wait(1000) | ||
|
||
cy.get("#dropdown-button").should("be.visible") | ||
|
||
cy.get("#dropdown-button").click() | ||
cy.get("#define-role").should("be.visible") | ||
}) | ||
|
||
it('Ressursadministrator', () => { | ||
cy.setCookie('cypresstestuser', 'ra') | ||
wait(1000) | ||
cy.getCookie('cypresstestuser').then(cookie => expect(cookie.value).to.be.equal('ra')) | ||
|
||
cy.goToHome(); | ||
cy.wait(1000) | ||
|
||
cy.get("#dropdown-button").should("be.visible") | ||
|
||
cy.get("#dropdown-button").click() | ||
cy.get("#define-role").should("not.exist") | ||
cy.get("#resource-module-admin").should("be.visible") | ||
}) | ||
|
||
it('Tjenesteadministrator', () => { | ||
cy.setCookie('cypresstestuser', 'ta') | ||
wait(1000) | ||
cy.getCookie('cypresstestuser').then(cookie => expect(cookie.value).to.be.equal('ta')) | ||
|
||
cy.goToHome(); | ||
cy.wait(1000) | ||
|
||
cy.get("#dropdown-button").should("be.visible") | ||
|
||
cy.get("#dropdown-button").click() | ||
cy.get("#define-role").should("not.exist") | ||
cy.get("#resource-module-admin").should("not.exist") | ||
cy.get("#service-admin").should("be.visible") | ||
}) | ||
|
||
it('Tildeler', () => { | ||
cy.setCookie('cypresstestuser', 'td') | ||
wait(1000) | ||
cy.getCookie('cypresstestuser').then(cookie => expect(cookie.value).to.be.equal('td')) | ||
|
||
cy.goToHome(); | ||
cy.wait(1000) | ||
|
||
cy.get("#dropdown-button").should("be.visible") | ||
|
||
cy.get("#dropdown-button").click() | ||
cy.get("#define-role").should("not.exist") | ||
cy.get("#resource-module-admin").should("not.exist") | ||
cy.get("#service-admin").should("not.exist") | ||
cy.get("#users").should("be.visible") | ||
|
||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
{ | ||
"firstName": "Mock", | ||
"firstName": "Mock Sysadmin", | ||
"lastName": "Name", | ||
"mail": "[email protected]", | ||
"organisationId": "mock.no", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,41 +14,88 @@ import {applicationCategoriesHandlers} from "./handlers/kodeverkHandlers"; | |
|
||
export const handlers = [ | ||
// Common handlers | ||
http.get('http://localhost:8062/beta/fintlabs-no/api/users/me', () => { | ||
return HttpResponse.json( | ||
{ | ||
"firstName": "Mock", | ||
"lastName": "Name", | ||
"mail": "[email protected]", | ||
"organisationId": "mock.no", | ||
"roles": [ | ||
{ | ||
"id": "pa", | ||
"name": "Portaladmin" | ||
}, | ||
{ | ||
"id": "l", | ||
"name": "Leder" | ||
}, | ||
{ | ||
"id": "sa", | ||
"name": "Systemadministrator" | ||
}, | ||
{ | ||
"id": "sb", | ||
"name": "Sluttbruker" | ||
}, | ||
{ | ||
"id": "ta", | ||
"name": "Tjenesteadministrator" | ||
}, | ||
{ | ||
"id": "td", | ||
"name": "Tildeler" | ||
} | ||
] | ||
} | ||
) | ||
http.get('http://localhost:8062/beta/fintlabs-no/api/users/me', ({cookies}) => { | ||
if (cookies.cypresstestuser === 'ra') { | ||
return HttpResponse.json( | ||
{ | ||
"firstName": "Mock", | ||
"lastName": "Name", | ||
"mail": "[email protected]", | ||
"organisationId": "mock.no", | ||
"roles": [ | ||
{ | ||
"id": "ra", | ||
"name": "Ressursadministrator" | ||
} | ||
] | ||
} | ||
) | ||
} else if (cookies.cypresstestuser === 'ta') { | ||
return HttpResponse.json( | ||
{ | ||
"firstName": "Mock", | ||
"lastName": "Name", | ||
"mail": "[email protected]", | ||
"organisationId": "mock.no", | ||
"roles": [ | ||
{ | ||
"id": "ta", | ||
"name": "Tjenesteadministrator" | ||
} | ||
] | ||
} | ||
) | ||
} else if (cookies.cypresstestuser === 'td') { | ||
return HttpResponse.json( | ||
{ | ||
"firstName": "Mock", | ||
"lastName": "Name", | ||
"mail": "[email protected]", | ||
"organisationId": "mock.no", | ||
"roles": [ | ||
{ | ||
"id": "td", | ||
"name": "Tildeler" | ||
} | ||
] | ||
} | ||
) | ||
} else { | ||
return HttpResponse.json( | ||
{ | ||
"firstName": "Mock", | ||
"lastName": "Name", | ||
"mail": "[email protected]", | ||
"organisationId": "mock.no", | ||
"roles": [ | ||
{ | ||
"id": "pa", | ||
"name": "Portaladmin" | ||
}, | ||
{ | ||
"id": "l", | ||
"name": "Leder" | ||
}, | ||
{ | ||
"id": "sa", | ||
"name": "Systemadministrator" | ||
}, | ||
{ | ||
"id": "sb", | ||
"name": "Sluttbruker" | ||
}, | ||
{ | ||
"id": "ta", | ||
"name": "Tjenesteadministrator" | ||
}, | ||
{ | ||
"id": "td", | ||
"name": "Tildeler" | ||
} | ||
] | ||
} | ||
) | ||
} | ||
}), | ||
|
||
http.get('http://localhost:8060/beta/fintlabs-no/api/orgunits', () => { | ||
|