Skip to content

Commit

Permalink
Merge pull request #2833 from NationalSecurityAgency/t#2821/learning_…
Browse files Browse the repository at this point in the history
…path_wrong_err_msg

#2821: fixed learning path validation message
  • Loading branch information
rmmayo authored Sep 9, 2024
2 parents 2bf93ae + 7dea839 commit c58adc9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ function validate(value, ctx) {
reason = 'Multiple badges on the same Learning path cannot have overlapping skills. '
+ `Both <b>${res.violatingSkillInBadgeName}</b> badge and <b>${toSkillName.value}</b> badge have <b>${res.violatingSkillName}</b> skill.`;
} else if (res.failureType && res.failureType === 'BadgeSkillIsAlreadyOnPath') {
reason = `Provided badge <b>${toSkillName.value}</b> has skill <b>${res.violatingSkillName}</b> which already exists on the learning path.`;
reason = res.reason.replace(/\[/g, "<b>").replace(/\]/g, "</b>");
} else if (res.failureType && res.failureType === 'AlreadyExist') {
reason = `Learning path from <b>${res.violatingSkillName}</b> to <b>${toSkillName.value}</b> already exists.`;
} else if (res.failureType && res.failureType === 'SkillInCatalog') {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2020 SkillTree
* Copyright 2024 SkillTree
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -165,7 +165,7 @@ describe('Learning Path Management Validation Tests', () => {
cy.get('[data-cy="addLearningPathItemBtn"]').should('be.disabled')
});

it('Cannot add a badge that already has one of its skills on the learning path', () => {
it('Cannot add to a badge that already has one of its skills on the learning path', () => {
cy.createSkill(1, 1, 4)
cy.createSkill(1, 1, 5)
cy.createSkill(1, 1, 6)
Expand Down Expand Up @@ -209,7 +209,29 @@ describe('Learning Path Management Validation Tests', () => {
cy.selectSkill('[data-cy="learningPathFromSkillSelector"]', 'skill9')
cy.selectSkill('[data-cy="learningPathToSkillSelector"]', 'badge3');

cy.get('[data-cy="learningPathError"]').contains('Provided badge Badge 3 has skill Very Great Skill 2 which already exists on the learning path')
cy.get('[data-cy="learningPathError"]').contains('Badge Badge 3 has skill Very Great Skill 2 which already exists on the Learning Path.')
cy.get('[data-cy="addLearningPathItemBtn"]').should('be.disabled')
});

it('Cannot add from a badge that already has one of its skills on the learning path', () => {
cy.createSkill(1, 1, 4)
cy.createSkill(1, 1, 5)
cy.createSkill(1, 1, 6)
cy.createBadge(1, 1);
cy.assignSkillToBadge(1, 1, 4);
cy.assignSkillToBadge(1, 1, 5);
cy.assignSkillToBadge(1, 1, 6);
cy.createBadge(1, 1, { enabled: true });

cy.addLearningPathItem(1, 4, 5)
cy.addLearningPathItem(1, 5, 6)

visitLearningPath()

cy.selectSkill('[data-cy="learningPathFromSkillSelector"]', 'badge1')
cy.selectSkill('[data-cy="learningPathToSkillSelector"]', 'skill1');

cy.get('[data-cy="learningPathError"]').contains('Badge Badge 1 has skill Very Great Skill 4 which already exists on the Learning Path.')
cy.get('[data-cy="addLearningPathItemBtn"]').should('be.disabled')
});

Expand Down

0 comments on commit c58adc9

Please sign in to comment.