-
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.
- Loading branch information
1 parent
ef7ffdb
commit fadfdfc
Showing
30 changed files
with
1,252 additions
and
250 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import { Pinia, createPinia, setActivePinia } from 'pinia' | ||
import '@gouvminint/vue-dsfr/styles' | ||
import '@gouvfr/dsfr/dist/dsfr.min.css' | ||
import '@gouvfr/dsfr/dist/utility/icons/icons.min.css' | ||
import '@gouvfr/dsfr/dist/utility/utility.main.min.css' | ||
import '@/main.css' | ||
import TeamCt from '@/components/TeamCt.vue' | ||
import { createRandomDbSetup, getRandomUser } from '@dso-console/test-utils' | ||
import { useProjectStore } from '@/stores/project.js' | ||
|
||
describe('TeamCt.vue', () => { | ||
let pinia: Pinia | ||
|
||
beforeEach(() => { | ||
pinia = createPinia() | ||
|
||
setActivePinia(pinia) | ||
}) | ||
|
||
it('Should mount a TeamCt for owner', () => { | ||
useProjectStore() | ||
const randomDbSetup = createRandomDbSetup({ nbUsers: 4 }) | ||
const owner = randomDbSetup.project.roles.find(role => role.role === 'owner')?.user | ||
const newUser = getRandomUser() | ||
|
||
cy.intercept('GET', `api/v1/projects/${randomDbSetup.project.id}/users/match?letters=*`, { body: [newUser] }) | ||
|
||
const props = { | ||
userProfile: { | ||
...owner, | ||
groups: [], | ||
}, | ||
project: randomDbSetup.project, | ||
owner, | ||
} | ||
|
||
cy.mount(TeamCt, { props }) | ||
|
||
cy.getByDataTestid('teamTable').should('be.visible') | ||
.within(() => { | ||
cy.get('caption') | ||
.should('contain', `Membres du projet ${randomDbSetup.project.name}`) | ||
cy.get('tbody > tr') | ||
.should('have.length', randomDbSetup.project.roles?.length) | ||
cy.get(`td[title="${owner?.email} ne peut pas être retiré(e) du projet"]`) | ||
.should('have.class', 'disabled') | ||
cy.get('td[title^="retirer"]') | ||
.should('not.have.class', 'disabled') | ||
}) | ||
}) | ||
it('Should mount a TeamCt for admin', () => { | ||
useProjectStore() | ||
const randomDbSetup = createRandomDbSetup({ nbUsers: 4 }) | ||
const owner = randomDbSetup.project.roles.find(role => role.role === 'owner')?.user | ||
const user = randomDbSetup.project.roles.find(role => role.role !== 'owner')?.user | ||
const newUser = getRandomUser() | ||
|
||
cy.intercept('GET', `api/v1/projects/${randomDbSetup.project.id}/users/match?letters=*`, { body: [newUser] }) | ||
|
||
const props = { | ||
userProfile: { | ||
...user, | ||
groups: ['/admin'], | ||
}, | ||
project: randomDbSetup.project, | ||
owner, | ||
} | ||
|
||
cy.mount(TeamCt, { props }) | ||
|
||
cy.getByDataTestid('teamTable').should('be.visible') | ||
.within(() => { | ||
cy.get('caption') | ||
.should('contain', `Membres du projet ${randomDbSetup.project.name}`) | ||
cy.get('tbody > tr') | ||
.should('have.length', randomDbSetup.project.roles?.length) | ||
cy.get(`td[title="${owner?.email} ne peut pas être retiré(e) du projet"]`) | ||
.should('have.class', 'disabled') | ||
cy.get('td[title^="retirer"]') | ||
.should('not.have.class', 'disabled') | ||
}) | ||
}) | ||
it('Should mount a TeamCt for user', () => { | ||
useProjectStore() | ||
const randomDbSetup = createRandomDbSetup({ nbUsers: 4 }) | ||
const owner = randomDbSetup.project.roles.find(role => role.role === 'owner')?.user | ||
const user = randomDbSetup.project.roles.find(role => role.role !== 'owner')?.user | ||
const newUser = getRandomUser() | ||
|
||
cy.intercept('GET', `api/v1/projects/${randomDbSetup.project.id}/users/match?letters=*`, { body: [newUser] }) | ||
|
||
const props = { | ||
userProfile: { | ||
...user, | ||
groups: [], | ||
}, | ||
project: randomDbSetup.project, | ||
owner, | ||
} | ||
|
||
cy.mount(TeamCt, { props }) | ||
|
||
cy.getByDataTestid('teamTable').should('be.visible') | ||
.within(() => { | ||
cy.get('caption') | ||
.should('contain', `Membres du projet ${randomDbSetup.project.name}`) | ||
cy.get('tbody > tr') | ||
.should('have.length', randomDbSetup.project.roles?.length) | ||
cy.get(`td[title="${owner?.email} ne peut pas être retiré(e) du projet"]`) | ||
.should('have.class', 'disabled') | ||
cy.get('td[title="vous n\'avez pas les droits suffisants pour retirer un membre du projet"]') | ||
.should('have.class', 'disabled') | ||
}) | ||
}) | ||
}) |
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
Oops, something went wrong.