Skip to content

Commit

Permalink
Merge pull request #2604 from NationalSecurityAgency/t#2490/cypress_t…
Browse files Browse the repository at this point in the history
…ests

T#2490/cypress tests
  • Loading branch information
dwalizer authored Jun 25, 2024
2 parents 2e11a2b + dba59a7 commit 009edbb
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 62 deletions.
19 changes: 13 additions & 6 deletions dashboard-prime/src/components/skills/Skills.vue
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ limitations under the License.
*/
<script setup>
import { computed, ref, onMounted, provide } from 'vue'
import { useAppConfig } from '@/common-components/stores/UseAppConfig.js';
import { useProjConfig } from '@/stores/UseProjConfig.js'
import { useSubjectSkillsState } from '@/stores/UseSubjectSkillsState.js'
import { useSubjectsState } from '@/stores/UseSubjectsState.js'
Expand All @@ -28,6 +29,7 @@ import { SkillsReporter } from '@skilltree/skills-client-js'
import EditSkillGroup from '@/components/skills/skillsGroup/EditSkillGroup.vue'
import ImportFromCatalogDialog from '@/components/skills/catalog/ImportFromCatalogDialog.vue'
const appConfig = useAppConfig()
const projConfig = useProjConfig()
const route = useRoute()
const skillsState = useSubjectSkillsState()
Expand All @@ -39,8 +41,11 @@ const isLoading = computed(() => {
})
const addSkillDisabled = computed(() => {
// return this.skills && this.numSubjectSkills >= appConfig.maxSkillsPerSubject;
return false
return subjectState.subject.numSkills >= appConfig.maxSkillsPerSubject;
})
const addSkillsDisabledMsg = computed(() => {
return `The maximum number of Skills allowed is ${appConfig.maxSkillsPerSubject}.`
})
const importDialog = ref({
Expand Down Expand Up @@ -155,10 +160,12 @@ const skillCreatedOrUpdated = (skill) => {
:is-loading="isLoading"
aria-label="new skill">
<div v-if="!projConfig.isReadOnlyProj">
<!-- <i v-if="addSkillDisabled" class="fas fa-exclamation-circle text-warning ml-1 mr-1"-->
<!-- style="pointer-events: all; font-size: 1.5rem;"-->
<!-- :aria-label="addSkillsDisabledMsg"-->
<!-- v-b-tooltip.hover="addSkillsDisabledMsg"/>-->
<Message severity="warn"
class="mx-2"
:aria-label="addSkillsDisabledMsg"
data-cy="addSkillDisabledWarning" v-if="addSkillDisabled" :closable="false">
{{ addSkillsDisabledMsg }}
</Message>
<SkillsButton
id="importFromCatalogBtn"
ref="importFromCatalogBtn"
Expand Down
7 changes: 6 additions & 1 deletion dashboard-prime/src/components/skills/SkillsTable.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import AddSkillTagDialog from '@/components/skills/tags/AddSkillTagDialog.vue'
import RemoveSkillTagDialog from '@/components/skills/tags/RemoveSkillTagDialog.vue'
import SkillsDataTable from '@/components/utils/table/SkillsDataTable.vue'
import { useLog } from '@/components/utils/misc/useLog.js'
import { useAppConfig } from '@/common-components/stores/UseAppConfig.js';
const YEARLY = 'YEARLY';
const MONTHLY = 'MONTHLY';
Expand All @@ -56,6 +57,7 @@ const props = defineProps({
})
const responsive = useResponsiveBreakpoints()
const appConfig = useAppConfig()
const skillsState = useSubjectSkillsState()
const subjectState = useSubjectsState()
const projConfig = useProjConfig()
Expand Down Expand Up @@ -204,7 +206,10 @@ const onColumnSort = () => {
reorderEnable.value = false
}
const addSkillDisabled = ref(false)
const addSkillDisabled = computed(() => {
return subjectState.subject.numSkills >= appConfig.maxSkillsPerSubject;
})
const createOrUpdateSkill = inject('createOrUpdateSkill')
const handleEditBtnClick = (skill) => {
if (skill.isCatalogSkill && skill.catalogType === 'imported') {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ const onReuseOrMove = (changedSkills) => {
movedOrReusedSkills.value = changedSkills
}
const hasDestinations = computed(() => destinations.value && destinations.value.length > 0)
const showStepper = computed(() => !state.value.skillsWereMovedOrReusedAlready && hasDestinations.value)
const showStepper = computed(() => !state.value.skillsWereMovedOrReusedAlready && hasDestinations.value && !importFinalizePending.value)
const importFinalizePending = computed(() => finalizeInfo.value.numSkillsToFinalize && finalizeInfo.value.numSkillsToFinalize > 0)
const onVisibleChanged = (isVisible) => {
if (!isVisible) {
Expand All @@ -138,7 +139,7 @@ const handleFocus = () => {
>
<div data-cy="reuseOrMoveDialog">
<skills-spinner :is-loading="isLoadingData" class="my-8" />
<div v-if="!isLoadingData" class="w-100">
<div v-if="!isLoadingData" data-cy="reuseModalContent" class="w-100">
<no-content2
class="mt-5 mb-4"
v-if="state.skillsWereMovedOrReusedAlready"
Expand All @@ -150,6 +151,11 @@ const handleFocus = () => {
v-if="!hasDestinations && !state.skillsWereMovedOrReusedAlready"
title="No Destinations Available"
:message="`There are no Subjects or Groups that this skill can be ${actionNameInPast} ${actionDirection}. Please create additional subjects and/or groups if you want to ${actionNameLowerCase} skills.`" />
<no-content2
class="mt-5 mb-4"
v-if="importFinalizePending"
:title="`Cannot ${textCustomization.actionName}`"
:message="`Cannot initiate skill ${actionNameLowerCase} while skill finalization is pending.`"/>

<Stepper v-if="showStepper" :linear="true" class="w-100">
<StepperPanel header="Select Destination">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
describe('Client Display Accessibility Video Tests', () => {
const testVideo = '/static/videos/create-quiz.mp4'

it.skip('display video on skill page', () => {
it('display video on skill page', () => {
cy.intercept('GET', '/api/projects/proj1/skills/skill1/videoCaptions')
.as('getVideoCaptions');
cy.createProject(1)
Expand Down
4 changes: 2 additions & 2 deletions e2e-tests/cypress/e2e/error_pages_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ describe('Error Pages Tests', () => {
.contains('Badge [fake] doesn\'t exist');
});

it.skip('Global Badge Not Found', () => {
it('Global Badge Not Found', () => {
const supervisorUser = '[email protected]';
cy.register(supervisorUser, 'password');
cy.login('[email protected]', 'password');
Expand All @@ -222,7 +222,7 @@ describe('Error Pages Tests', () => {
.contains('GlobalBadge [fake] doesn\'t exist.');
});

it.skip('Global Badge Not Authorized', () => {
it('Global Badge Not Authorized', () => {
const supervisorUser = '[email protected]';
cy.register(supervisorUser, 'password');
cy.login('[email protected]', 'password');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,25 +26,23 @@ describe('Skill Reuse and Dashboard Tests', () => {
cy.createSubject(1, 2);
});

it.skip('Search and Navigate directly to a skill properly labels reused skills', () => {
it('Search and Navigate directly to a skill properly labels reused skills', () => {
cy.reuseSkillIntoAnotherSubject(1, 1, 2);
cy.createSkillsGroup(1, 1, 12);
cy.reuseSkillIntoAnotherGroup(1, 1, 1, 12);

cy.visit('/administrator/projects/proj1/');

cy.get('input.vs__search')
.invoke('attr', 'placeholder')
.should('contain', 'Search and Navigate directly to a skill');
cy.get('[data-cy="skillsSelector"]').should('contain', 'Search and Navigate directly to a skill')
cy.get('[data-cy="skillsSelector"]')
.click();
cy.get('[data-cy="skillsSelector"]')
cy.get('li.p-dropdown-empty-message')
.contains('Type to search for skills')
.should('be.visible');
cy.get('[data-cy="skillsSelector"]')
cy.get(`[data-pc-section="filterinput"]`)
.type('s');

cy.get('[data-cy="skillsSelector"] [data-cy="skillsSelector-skillId"]')
cy.get('[data-cy="skillsSelector-skillId"]')
.should('have.length', 3)
.as('skillIds');
cy.get('@skillIds')
Expand All @@ -57,7 +55,7 @@ describe('Skill Reuse and Dashboard Tests', () => {
.eq(2)
.contains('skill1');

cy.get('[data-cy="skillsSelector"] [data-cy="skillsSelector-skillName"]')
cy.get('[data-cy="skillsSelector-skillName"]')
.should('have.length', 3)
.as('skillIds');
cy.get('@skillIds')
Expand All @@ -71,15 +69,15 @@ describe('Skill Reuse and Dashboard Tests', () => {
.eq(2)
.find('[data-cy="reusedBadge"]');

cy.get('[data-cy="skillsSelector"] [data-cy="skillsSelector-groupName"]')
cy.get('[data-cy="skillsSelector-groupName"]')
.should('have.length', 1)
.as('skillIds');
cy.get('@skillIds')
.eq(0)
.contains('Awesome Group 12 Subj1');
});

it.skip('reused skills must NOT be available for badges', () => {
it('reused skills must NOT be available for badges', () => {
cy.reuseSkillIntoAnotherSubject(1, 1, 2);
cy.createSkillsGroup(1, 1, 12);
cy.reuseSkillIntoAnotherGroup(1, 1, 1, 12);
Expand All @@ -88,15 +86,15 @@ describe('Skill Reuse and Dashboard Tests', () => {
cy.visit('/administrator/projects/proj1/badges/badge1');
cy.get('[data-cy="skillsSelector"]')
.click();
cy.get('[data-cy="skillsSelector"] [data-cy="skillsSelector-skillId"]')
cy.get('[data-cy="skillsSelector-skillId"]')
.should('have.length', 1)
.as('skillIds');
cy.get('@skillIds')
.eq(0)
.contains('skill1');
});

it.skip('cannot initiate reuse when finalization is pending', () => {
it('cannot initiate reuse when finalization is pending', () => {
cy.createSkill(1, 1, 1);
cy.createSkill(1, 1, 2);
cy.exportSkillToCatalog(1, 1, 1);
Expand All @@ -111,17 +109,15 @@ describe('Skill Reuse and Dashboard Tests', () => {
cy.importSkillFromCatalog(2, 1, 1, 2);

cy.visit('/administrator/projects/proj2/subjects/subj1/');
cy.get('[data-cy="skillSelect-skill11"]')
.click({ force: true });
cy.get('[data-cy="skillsTable"] [data-p-index="2"] [data-pc-name="rowcheckbox"]').click()
cy.get('[data-cy="skillActionsBtn"]')
.click();
cy.get('[data-cy="skillReuseBtn"]')
.click();
cy.get('[data-cy="skillsActionsMenu"] [aria-label="Reuse in this Project"]').click()
cy.get('[data-cy="reuseModalContent"]')
.contains('Cannot initiate skill reuse while skill finalization is pending');
});

it.skip('cannot initiate reuse when finalization is running', () => {
it('cannot initiate reuse when finalization is running', () => {
cy.createSkill(1, 1, 1);
cy.createSkill(1, 1, 2);
cy.exportSkillToCatalog(1, 1, 1);
Expand All @@ -137,17 +133,14 @@ describe('Skill Reuse and Dashboard Tests', () => {
cy.importSkillFromCatalog(2, 1, 1, 2);

cy.visit('/administrator/projects/proj2/subjects/subj1/');
cy.get('[data-cy="skillSelect-skill11"]');
cy.get('[data-cy="skillsTable"] [data-p-index="2"] [data-pc-name="rowcheckbox"]').click()
cy.get('[data-cy="finalizeBtn"]')
.click();
cy.get('[data-cy="doPerformFinalizeButton"]')
cy.get('[data-cy="saveDialogBtn"]')
.click();
cy.get('[data-cy="skillSelect-skill11"]')
.click({ force: true });
cy.get('[data-cy="skillActionsBtn"]')
.click();
cy.get('[data-cy="skillReuseBtn"]')
.click();
cy.get('[data-cy="skillsActionsMenu"] [aria-label="Reuse in this Project"]').click()
cy.get('[data-cy="reuseModalContent"]')
.contains('Cannot initiate skill reuse while skill finalization is pending');
cy.waitForBackendAsyncTasksToComplete();
Expand Down
19 changes: 10 additions & 9 deletions e2e-tests/cypress/e2e/skills_group_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ describe('Skills Group Tests', () => {
cy.get('[data-cy="ChildRowSkillGroupDisplay_BlahGroup"] [data-cy="description"]').contains('Description for this group!');
})

it.skip('group\'s description supports markdown', () => {
it('group\'s description supports markdown', () => {
const markdown = "# Title1\n## Title2\n### Title 3\n#### Title 4\n##### Title 5\nTitle 6\n\n";
cy.createSkillsGroup(1, 1, 1, { description : markdown });

Expand Down Expand Up @@ -494,7 +494,7 @@ describe('Skills Group Tests', () => {
cy.get('[data-cy="pageHeader"]').contains('SKILL: Very Great Skill 2');
});

it.skip('Report Skill Events: ability to report skill events after group is enabled', () => {
it('Report Skill Events: ability to report skill events after group is enabled', () => {
cy.intercept('/admin/projects/proj1/subjects/subj1/skills/skill2').as('getSkill2')
cy.intercept('POST', '/app/users/projects/proj1/suggestClientUsers?userSuggestOption=ONE').as('userSuggest');
cy.createSkillsGroup(1, 1, 1);
Expand All @@ -520,11 +520,12 @@ describe('Skills Group Tests', () => {
cy.get('[data-cy="nav-Add Event"] .fa-exclamation-circle').should('not.exist');
cy.get('[data-cy="userIdInput"]').type('user1{enter}')
cy.wait('@userSuggest');
cy.get('[data-cy="userIdInput"]').contains('user1')
cy.get('[data-cy="userIdInput"]').type('{enter}')
cy.get('[data-cy="userIdInput"] input').should('have.value', 'user1')
cy.get('[data-cy="addSkillEventButton"]').should('be.enabled');
});

it.skip('Report Skill Events: must not be able to report skill events if there is not enough points because group is not enabled', () => {
it('Report Skill Events: must not be able to report skill events if there is not enough points because group is not enabled', () => {
cy.intercept('/admin/projects/proj1/subjects/subj1/skills/skill2').as('getSkill2')
cy.intercept('POST', '/app/users/projects/proj1/suggestClientUsers?userSuggestOption=ONE').as('userSuggest');

Expand All @@ -549,7 +550,7 @@ describe('Skills Group Tests', () => {

cy.get('[data-cy="userIdInput"]').type('user1{enter}')
cy.wait('@userSuggest');
cy.get('[data-cy="userIdInput"]').contains('user1')
cy.get('[data-cy="userIdInput"] input').should('have.value', 'user1')
cy.get('[data-cy="addSkillEventButton"]').should('be.disabled');
});

Expand Down Expand Up @@ -783,17 +784,17 @@ describe('Skills Group Tests', () => {
cy.get('[data-cy="pageHeaderStat_Skills"] [data-cy="statValue"]').should('have.text', '4');
})

it.skip('search and navigate to group\'s skill', () => {
it('search and navigate to group\'s skill', () => {
cy.createSkillsGroup(1, 1, 1);
cy.addSkillToGroup(1, 1, 1, 1);
cy.addSkillToGroup(1, 1, 1, 2);

cy.visit('/administrator/projects/proj1/');
cy.get('[data-cy="skillsSelector"]').click();
cy.get('[data-cy="skillsSelector"]').contains('Type to search for skills').should('be.visible')
cy.get('[data-cy="skillsSelector"]').type('skill')
cy.get('li.p-dropdown-empty-message').contains('Type to search for skills').should('be.visible')
cy.get(`[data-pc-section="filterinput"]`).type('skill')

cy.get('[data-cy="skillsSelector"] [data-cy="skillsSelector-skillId"]').should('have.length', 2).as('skillIds');
cy.get('[data-cy="skillsSelectionItem-skillId"]').should('have.length', 2).as('skillIds');
cy.get('@skillIds').eq(0).contains('skill1');
cy.get('@skillIds').eq(1).contains('skill2');
cy.get('@skillIds').eq(1).click();
Expand Down
Loading

0 comments on commit 009edbb

Please sign in to comment.