-
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.
Merge pull request #1458 from cloud-pi-native/develop
Develop
- Loading branch information
Showing
77 changed files
with
1,641 additions
and
584 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,80 @@ | ||
import type { User } from '@cpn-console/shared' | ||
import { getModelById } from '../support/func.js' | ||
|
||
const userClaire = getModelById('user', 'cb8e5b4b-7b7b-40f5-935f-594f48ae6567') as User | ||
const userTibo = getModelById('user', 'cb8e5b4b-7b7b-40f5-935f-594f48ae6566') as User | ||
|
||
describe('Header', () => { | ||
it('Should display name once logged', () => { | ||
cy.kcLogin((userClaire.firstName.slice(0, 1) + userClaire.lastName).toLowerCase()) | ||
.visit('/') | ||
.getByDataTestid('menuUserList') | ||
.should('contain', `${userClaire.firstName} ${userClaire.lastName}`) | ||
}) | ||
|
||
it('Should display profile infos', () => { | ||
cy.kcLogin('tcolin') | ||
.visit('/profile/info') | ||
cy.getByDataTestid('profileInfos') | ||
.should('contain.text', `${userTibo.lastName}, ${userTibo.firstName}`) | ||
.should('contain.text', userTibo.id) | ||
.should('contain.text', 'Admin') | ||
.should('contain.text', userTibo.email) | ||
}) | ||
|
||
it('Should create pat', () => { | ||
cy.intercept('GET', 'api/v1/user/tokens*').as('listTokens') | ||
cy.intercept('POST', 'api/v1/user/tokens').as('createToken') | ||
cy.intercept('DELETE', 'api/v1/user/tokens/*').as('deleteToken') | ||
|
||
cy.kcLogin('tcolin') | ||
.visit('/') | ||
.getByDataTestid('menuUserList') | ||
.click() | ||
cy.getByDataTestid('menuUserTokens') | ||
.click() | ||
cy.wait('@listTokens', { timeout: 15_000 }) | ||
cy.url().should('contain', '/profile/tokens') | ||
cy.getByDataTestid('showNewTokenFormBtn') | ||
.click() | ||
|
||
cy.getByDataTestid('newTokenName') | ||
.click() | ||
.clear() | ||
.type('test2') | ||
cy.getByDataTestid('expirationDateInput') | ||
.click() | ||
.clear() | ||
.type('2100-11-22') | ||
cy.getByDataTestid('saveBtn') | ||
.click() | ||
cy.wait('@createToken') | ||
cy.getByDataTestid('newTokenPassword') | ||
.should('be.visible') | ||
|
||
// Réinitialiser le formulaire | ||
cy.getByDataTestid('showNewTokenFormBtn') | ||
.click() | ||
cy.getByDataTestid('newTokenPassword').should('not.exist') | ||
|
||
cy.getByDataTestid('tokenTable').within(() => { | ||
cy.get(`tbody tr:nth-of-type(1)`).within(() => { | ||
cy.get('td:nth-of-type(1)').should('contain', 'test2') | ||
cy.get('td:nth-of-type(2)').should('contain', (new Date()).getFullYear()) | ||
cy.get('td:nth-of-type(3)').should('contain', 2100) | ||
cy.get('td:nth-of-type(4)').should('contain', 'Jamais') | ||
cy.get('td:nth-of-type(5)').should('contain', 'Actif') | ||
cy.get('td:nth-of-type(6)') | ||
.click() | ||
}) | ||
}) | ||
|
||
cy.getByDataTestid('confirmDeletionBtn') | ||
.click() | ||
cy.wait('@deleteToken') | ||
cy.getByDataTestid('tokenTable').within(() => { | ||
cy.get(`tbody tr`) | ||
.should('have.length', 1) | ||
}) | ||
}) | ||
}) |
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
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
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 |
---|---|---|
@@ -1,19 +1,8 @@ | ||
import { getModelById } from '../support/func.js' | ||
|
||
const user = getModelById('user', 'cb8e5b4b-7b7b-40f5-935f-594f48ae6565') | ||
|
||
describe('Redirect to 404 if page not found', () => { | ||
it('should redirect loggedout user to 404 if page not found', () => { | ||
cy.visit('/nowhere') | ||
cy.url().should('contain', '/404') | ||
cy.getByDataTestid('whoami-hint') | ||
.should('not.exist') | ||
}) | ||
it('should redirect loggedin user to 404 if page not found', () => { | ||
cy.kcLogin('test') | ||
cy.visit('/nowhere') | ||
cy.url().should('contain', '/404') | ||
cy.getByDataTestid('whoami-hint') | ||
.should('contain', `${user.firstName} ${user.lastName}`) | ||
cy.get('.fr-h1') | ||
.should('contain.text', 'Page non trouvée') | ||
}) | ||
}) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,25 @@ | ||
<script lang="ts" setup> | ||
import { useProjectStore } from '@/stores/project.js' | ||
import type { Project } from '@/utils/project-utils.js' | ||
const props = defineProps<{ | ||
projectId: Project['id'] | undefined | ||
}>() | ||
const projectStore = useProjectStore() | ||
const project = computed<Project | undefined>(() => projectStore.projectsById[props.projectId ?? '']) | ||
</script> | ||
|
||
<template> | ||
<div | ||
v-if="project?.operationsInProgress.length" | ||
class="fixed bottom-5 right-5 z-999 shadow-lg background-default-grey" | ||
> | ||
<DsfrAlert | ||
data-testid="operationInProgressAlert" | ||
title="Opération en cours..." | ||
:description="project?.operationsInProgress.length === 2 ? 'Une ou plusieurs tâches en attente' : ''" | ||
type="info" | ||
/> | ||
</div> | ||
</template> |
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,49 @@ | ||
<script lang="ts" setup> | ||
import { ProjectAuthorized } from '@cpn-console/shared' | ||
import { useProjectStore } from '@/stores/project.js' | ||
import type { Project } from '@/utils/project-utils.js' | ||
import { useSnackbarStore } from '@/stores/snackbar.js' | ||
const props = defineProps<{ | ||
projectId: Project['id'] | ||
}>() | ||
const snackbarStore = useSnackbarStore() | ||
const projectStore = useProjectStore() | ||
const project = computed(() => projectStore.projectsById[props.projectId]) | ||
const operationsInProgress = computed(() => project.value.operationsInProgress) | ||
async function replayHooks() { | ||
await project.value.Commands.replay() | ||
switch (project.value.status) { | ||
case 'created': | ||
snackbarStore.setMessage('Le projet a été reprovisionné avec succès.', 'success') | ||
break | ||
case 'failed': | ||
snackbarStore.setMessage('Le projet a été reprovisionné mais a rencontré une erreur bloquante.\nVeuillez consulter les journaux puis réessayer dans quelques instants.\nSi le problème persiste, vous pouvez contacter un administrateur.', 'error') | ||
break | ||
case 'warning': | ||
snackbarStore.setMessage('Le projet a été reprovisionné et a rencontré une erreur non bloquante.\nVeuillez consulter les journaux puis réessayer dans quelques instants.\nSi le problème persiste, vous pouvez contacter un administrateur.', 'warning', 20_000) | ||
break | ||
default: | ||
snackbarStore.setMessage('Le projet a été reprovisionné mais se trouve dans un état inconnu.', 'info') | ||
break | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<div | ||
v-if="ProjectAuthorized.ReplayHooks({ projectPermissions: project.myPerms })" | ||
class="fr-mt-2w" | ||
> | ||
<DsfrButton | ||
data-testid="replayHooksBtn" | ||
label="Reprovisionner le projet" | ||
:icon="{ name: 'ri:refresh-fill', animation: operationsInProgress.includes('replay') ? 'spin' : '' }" | ||
secondary | ||
:disabled="project.locked || operationsInProgress.includes('replay')" | ||
@click="replayHooks" | ||
/> | ||
</div> | ||
</template> |
Oops, something went wrong.