From 7dea839d22928f3ec82a8d1948ec896b63ca9027 Mon Sep 17 00:00:00 2001 From: Dima May Date: Mon, 9 Sep 2024 17:34:09 +0000 Subject: [PATCH] #2821: fixed learning path validation message --- .../dependencies/PrerequisiteSelector.vue | 2 +- ...earning_path_management_validation_spec.js | 28 +++++++++++++++++-- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/dashboard/src/components/skills/dependencies/PrerequisiteSelector.vue b/dashboard/src/components/skills/dependencies/PrerequisiteSelector.vue index b2468d20e3..6982e032af 100644 --- a/dashboard/src/components/skills/dependencies/PrerequisiteSelector.vue +++ b/dashboard/src/components/skills/dependencies/PrerequisiteSelector.vue @@ -161,7 +161,7 @@ function validate(value, ctx) { reason = 'Multiple badges on the same Learning path cannot have overlapping skills. ' + `Both ${res.violatingSkillInBadgeName} badge and ${toSkillName.value} badge have ${res.violatingSkillName} skill.`; } else if (res.failureType && res.failureType === 'BadgeSkillIsAlreadyOnPath') { - reason = `Provided badge ${toSkillName.value} has skill ${res.violatingSkillName} which already exists on the learning path.`; + reason = res.reason.replace(/\[/g, "").replace(/\]/g, ""); } else if (res.failureType && res.failureType === 'AlreadyExist') { reason = `Learning path from ${res.violatingSkillName} to ${toSkillName.value} already exists.`; } else if (res.failureType && res.failureType === 'SkillInCatalog') { diff --git a/e2e-tests/cypress/e2e/learning-path/learning_path_management_validation_spec.js b/e2e-tests/cypress/e2e/learning-path/learning_path_management_validation_spec.js index 9d86205f83..19f84105fd 100644 --- a/e2e-tests/cypress/e2e/learning-path/learning_path_management_validation_spec.js +++ b/e2e-tests/cypress/e2e/learning-path/learning_path_management_validation_spec.js @@ -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. @@ -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) @@ -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') });