Skip to content

Commit

Permalink
#2490: insufficient warning on project and subject pages
Browse files Browse the repository at this point in the history
  • Loading branch information
sudo-may committed Jun 20, 2024
1 parent d948fdd commit 3d601cd
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 5 deletions.
16 changes: 12 additions & 4 deletions dashboard-prime/src/components/projects/ProjectPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,6 @@ const headerOptions = computed(() => {
stats.push({
label: 'Points',
count: project.value.totalPoints,
warnMsg: project.value.totalPoints < minimumPoints ? 'Project has insufficient points assigned. Skills cannot be achieved until project has at least 100 points.' : null,
icon: 'far fa-arrow-alt-circle-up skills-color-points',
secondaryStats: [{
label: 'reused',
Expand Down Expand Up @@ -162,8 +161,9 @@ const headerOptions = computed(() => {
}
})
const minimumPoints = computed(() => {
return appConfig.minimumProjectPoints
const isInsufficientPoints = computed(() => {
const projPoints = project.value?.totalPoints || 0
return projPoints < appConfig.minimumProjectPoints
})
const copyAndDisplayShareProjInfo = () => {
Expand Down Expand Up @@ -197,12 +197,16 @@ const setProject = (newProject) => {
projectDetailsState.project = newProject
}
const isProjectExpiring = computed(() => {
return project.value && project.value.expiring && !isReadOnlyProj.value
})
</script>
<template>
<div ref="mainFocus">
<PageHeader :loading="isLoading" :options="headerOptions">
<template #banner v-if="project && project.expiring && !isReadOnlyProj">
<template #banner v-if="isProjectExpiring">
<project-expiration-warning :project="project" @extended="project.expiring = false" />
</template>
<template #subTitle v-if="project">
Expand Down Expand Up @@ -280,6 +284,10 @@ const setProject = (newProject) => {
</template>
</PageHeader>
<Message v-if="isInsufficientPoints" :closable="false" data-cy="projectInsufficientPoints">
Project has insufficient points assigned. Skills cannot be achieved until project has at least <Tag>{{ appConfig.minimumProjectPoints }}</Tag> points.
</Message>
<import-finalize-alert />
<Navigation :nav-items="navItems">
Expand Down
9 changes: 8 additions & 1 deletion dashboard-prime/src/components/subjects/SubjectPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ const headerOptions = computed(() => {
label: 'Points',
count: subject.totalPoints,
warn: subject.totalPoints < minimumPoints.value,
warnMsg: (subject.totalPoints + subject.totalPointsReused) < minimumPoints.value ? `Subject has insufficient points assigned. Skills cannot be achieved until subject has at least ${minimumPoints.value} points.` : null,
icon: 'far fa-arrow-alt-circle-up skills-color-points',
secondaryStats: [{
label: 'reused',
Expand All @@ -99,6 +98,10 @@ const headerOptions = computed(() => {
}
})
const isInsufficientPoints = computed(() => {
return subjectState.subject.totalPoints < appConfig.minimumSubjectPoints
})
const minimumPoints = computed(() => {
return appConfig.minimumSubjectPoints
})
Expand Down Expand Up @@ -156,6 +159,10 @@ const subjectEdited = (updatedSubject) => {
</template>
</page-header>

<Message v-if="isInsufficientPoints" :closable="false" data-cy="subjInsufficientPoints">
Subject has insufficient points assigned. Skills cannot be achieved until subject has at least <Tag>{{ appConfig.minimumSubjectPoints}}</Tag> points
</Message>

<import-finalize-alert />

<navigation v-if="!isLoadingData" :nav-items="navItems">
Expand Down
29 changes: 29 additions & 0 deletions e2e-tests/cypress/e2e/projects_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,35 @@ describe('Projects Tests', () => {
.contains('Project has insufficient points assigned');
cy.get('[data-cy="projectCard_proj3"] [data-cy="projectCardWarning"]')
.contains('Project has insufficient points assigned');

cy.get('[data-cy="projectCard_proj2"] [data-cy="projectCardWarning"] [data-pc-section="closeicon"]').click();
cy.get('[data-cy="projectCard_proj3"] [data-cy="projectCardWarning"]')
.contains('Project has insufficient points assigned');
cy.get('[data-cy="projectCard_proj1"] [data-cy="projectCardWarning"]').should('not.exist')
cy.get('[data-cy="projectCard_proj2"] [data-cy="projectCardWarning"]').should('not.exist')

cy.visit('/administrator');
cy.get('[data-cy="projectCard_proj3"] [data-cy="projectCardWarning"]')
.contains('Project has insufficient points assigned');
cy.get('[data-cy="projectCard_proj1"] [data-cy="projectCardWarning"]').should('not.exist')
cy.get('[data-cy="projectCard_proj2"] [data-cy="projectCardWarning"]').should('not.exist')

cy.get('[data-cy="projCard_proj2_manageLink"]').click()
cy.contains('No Subjects Yet')
cy.get('[data-cy="projectInsufficientPoints"]')

cy.get('[data-cy="breadcrumb-Projects"]').click()
cy.get('[data-cy="projCard_proj1_manageLink"]').click()
cy.get('[data-cy="subjectCard-subj1"]')
cy.get('[data-cy="projectInsufficientPoints"]').should('not.exist')

cy.visit('/administrator/projects/proj2');
cy.contains('No Subjects Yet')
cy.get('[data-cy="projectInsufficientPoints"]')

cy.visit('/administrator/projects/proj1');
cy.get('[data-cy="subjectCard-subj1"]')
cy.get('[data-cy="projectInsufficientPoints"]').should('not.exist')
});

it('project description is retained after editing', () => {
Expand Down
24 changes: 24 additions & 0 deletions e2e-tests/cypress/e2e/subjects_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -965,4 +965,28 @@ describe('Subjects Tests', () => {
cy.wait('@validateDesc')
cy.get('[data-cy="descriptionError"]').contains('Mocked up validation failure')
});

it('insufficient points warning', () => {
cy.createSubject(1, 1);
cy.createSkill(1, 1, 1);
cy.createSubject(1, 2);

cy.visit('/administrator/projects/proj1')
cy.get('[data-cy="subjectCard-subj2"] [data-cy="titleLink"]').click()
cy.contains('No Skills Yet')
cy.get('[data-cy="subjInsufficientPoints"]')

cy.get('[data-cy="breadcrumb-proj1"]').click()
cy.get('[data-cy="subjectCard-subj1"] [data-cy="titleLink"]').click()
cy.get('[data-cy="manageSkillLink_skill1"]')
cy.get('[data-cy="subjInsufficientPoints"]').should('not.exist')

cy.visit('/administrator/projects/proj1/subjects/subj2')
cy.contains('No Skills Yet')
cy.get('[data-cy="subjInsufficientPoints"]')

cy.visit('/administrator/projects/proj1/subjects/subj1')
cy.get('[data-cy="manageSkillLink_skill1"]')
cy.get('[data-cy="subjInsufficientPoints"]').should('not.exist')
})
});

0 comments on commit 3d601cd

Please sign in to comment.