From 748bfca6b639c68240b86e49369ac95eb74077b1 Mon Sep 17 00:00:00 2001 From: "EVOFORGE\\dimay" Date: Fri, 22 Dec 2023 10:47:52 -0500 Subject: [PATCH] #2462: improved tests --- e2e-tests/cypress/e2e/global_badges_spec.js | 148 ++---------------- .../e2e/projects_modal_management_spec.js | 54 ++----- .../e2e/skills-display-integration_spec.js | 141 ++++++++--------- 3 files changed, 93 insertions(+), 250 deletions(-) diff --git a/e2e-tests/cypress/e2e/global_badges_spec.js b/e2e-tests/cypress/e2e/global_badges_spec.js index a6c8b45d94..eebae9639c 100644 --- a/e2e-tests/cypress/e2e/global_badges_spec.js +++ b/e2e-tests/cypress/e2e/global_badges_spec.js @@ -785,152 +785,28 @@ describe('Global Badges Tests', () => { }); it('Removing all skills should not cause published Global Badge to become disabled', () => { - cy.intercept('GET', `/supervisor/badges`) - .as('getGlobalBadges'); - cy.intercept('PUT', `/supervisor/badges/ABadgeBadge`) - .as('postGlobalBadge'); - cy.intercept('GET', `/supervisor/badges/id/ABadgeBadge/exists`) - .as('idExists'); - cy.intercept('POST', '/supervisor/badges/name/exists') - .as('nameExists'); - //proj/subj/skill1 - cy.request('POST', '/app/projects/proj1', { - projectId: 'proj1', - name: 'proj1' - }); - cy.request('POST', '/admin/projects/proj1/subjects/subj1', { - projectId: 'proj1', - subjectId: 'subj1', - name: 'Subject 1' - }); - cy.request('POST', `/admin/projects/proj1/subjects/subj1/skills/skill1`, { - projectId: 'proj1', - subjectId: 'subj1', - skillId: 'skill1', - name: `This is 1`, - type: 'Skill', - pointIncrement: 100, - numPerformToCompletion: 5, - pointIncrementInterval: 0, - numMaxOccurrencesIncrementInterval: -1, - version: 0, - }); - //proj/subj/skill2 - cy.request('POST', '/app/projects/proj2', { - projectId: 'proj2', - name: 'proj2' - }); - cy.request('POST', '/admin/projects/proj2/subjects/subj1', { - projectId: 'proj2', - subjectId: 'subj1', - name: 'Subject 1' - }); - cy.request('POST', `/admin/projects/proj2/subjects/subj1/skills/skill1`, { - projectId: 'proj2', - subjectId: 'subj1', - skillId: 'skill1', - name: `This is 1`, - type: 'Skill', - pointIncrement: 100, - numPerformToCompletion: 5, - pointIncrementInterval: 0, - numMaxOccurrencesIncrementInterval: -1, - version: 0, - }); + cy.createProject(1) + cy.createSubject(1, 1) + cy.createSkill(1, 1, 1) + cy.createProject(2) + cy.createSubject(2, 1) + cy.createSkill(2, 1, 1) - cy.intercept('GET', '/supervisor/projects/proj2/levels') - .as('getLevels'); - cy.intercept('GET', '/supervisor/badges/ABadgeBadge/projects/available*') - .as('getAvailableLevels'); - - cy.visit('/administrator/'); - cy.get('[data-cy="inception-button"]').contains('Level'); - - cy.clickNav('Global Badges'); - cy.wait('@getGlobalBadges'); - - cy.clickButton('Badge'); - - cy.get('[data-cy="badgeName"]') - .type('A Badge', { delay: 100 }) - cy.wait('@nameExists'); - cy.clickSave(); - cy.wait('@idExists'); - cy.wait('@postGlobalBadge'); + cy.createGlobalBadge(1); + cy.assignSkillToGlobalBadge(1, 1, 1); + cy.assignProjectToGlobalBadge(1, 2, 5); + cy.enableGlobalBadge(); - cy.contains('A Badge') - .should('exist'); - cy.contains('Manage') - .click(); - cy.wait('@loadAvailableSkills'); - cy.selectSkill('[data-cy="skillsSelectionItem-proj2-skill1"]') + cy.visit('/administrator/globalBadges/globalBadge1'); cy.validateTable(tableSelector, [ [{ - colIndex: 0, - value: 'proj2' - }, { - colIndex: 1, - value: 'This is 1' - }, { colIndex: 2, value: 'skill1' }], ], 5); - cy.clickNav('Levels'); - cy.wait('@getAvailableLevels'); - - cy.get('#project-selector') - .click() - .type('proj2'); - cy.wait('@getAvailableLevels'); - cy.get('[data-cy="proj2_option"]').click(); - - cy.get('#level-selector') - .click() - .type('5{enter}'); - - cy.contains('Add') - .click(); - cy.validateTable(levelsTableSelector, [ - [{ - colIndex: 0, - value: 'proj2' - }, { - colIndex: 1, - value: '5' - }], - ], 5); - - cy.contains('.router-link-active', 'Badges') - .click(); - cy.wait('@getGlobalBadges'); - - cy.contains('A Badge') - .should('exist'); - - cy.get('[data-cy=badgeStatus]') - .contains('Status: Disabled') - .should('exist'); - cy.get('[data-cy=goLive]') - .click(); - cy.contains('Please Confirm!') - .should('exist'); - cy.contains('Yes, Go Live!') - .click(); - cy.wait('@getGlobalBadges'); - cy.contains('A Badge') - .should('exist'); - cy.get('[data-cy=badgeStatus]') - .contains('Status: Live') - .should('exist'); - cy.get('[data-cy=goLive]') - .should('not.exist'); - - cy.contains('Manage') - .click(); cy.get('[data-cy=deleteSkill_skill1]') - .click(); + .click(); cy.contains('YES, Delete It!') .click(); cy.contains('No Skills Added Yet'); diff --git a/e2e-tests/cypress/e2e/projects_modal_management_spec.js b/e2e-tests/cypress/e2e/projects_modal_management_spec.js index fb901fdcc3..c216a8c014 100644 --- a/e2e-tests/cypress/e2e/projects_modal_management_spec.js +++ b/e2e-tests/cypress/e2e/projects_modal_management_spec.js @@ -381,58 +381,24 @@ describe('Projects Modal Management Tests', () => { }); it('project users input field submits on enter', () => { - cy.request('POST', '/app/projects/my_project_123', { - projectId: 'my_project_123', - name: 'My Project 123' - }); - - cy.request('POST', '/admin/projects/my_project_123/subjects/subj1', { - projectId: 'my_project_123', - subjectId: 'subj1', - name: 'Subject 1' - }); - cy.request('POST', `/admin/projects/my_project_123/subjects/subj1/skills/skill1`, { - projectId: 'my_project_123', - subjectId: 'subj1', - skillId: 'skill1', - name: `This is 1`, - type: 'Skill', - pointIncrement: 100, - numPerformToCompletion: 10, - pointIncrementInterval: 0, - numMaxOccurrencesIncrementInterval: -1, - version: 0, - }); - + cy.createProject(1) + cy.createSubject(1, 1) + cy.createSkill(1, 1, 1) const now = dayjs(); - cy.reportSkill('my_project_123', 1, 'user1@skills.org', now.subtract(1, 'year') + cy.reportSkill('proj1', 1, 'user1@skills.org', now.subtract(1, 'year') .format('YYYY-MM-DD HH:mm'), false); - cy.reportSkill('my_project_123', 1, 'user2@skills.org', now.subtract(1, 'year') + cy.reportSkill('proj1', 1, 'user2@skills.org', now.subtract(1, 'year') .format('YYYY-MM-DD HH:mm'), false); - cy.reportSkill('my_project_123', 1, 'user3@skills.org', now.subtract(1, 'year') + cy.reportSkill('proj1', 1, 'user3@skills.org', now.subtract(1, 'year') .format('YYYY-MM-DD HH:mm'), false); cy.reportSkill('my_project_123', 1, 'user4@skills.org', now.subtract(1, 'year') .format('YYYY-MM-DD HH:mm'), false); - cy.intercept('GET', '/admin/projects/my_project_123') - .as('loadProj'); - cy.intercept('GET', '/api/projects/Inception/level') - .as('loadInception'); - cy.intercept('GET', '/admin/projects/my_project_123/users**') - .as('loadUsers'); - cy.visit('/administrator/projects/my_project_123'); - cy.wait('@loadProj'); - cy.wait('@loadInception'); - cy.get('[data-cy="inception-button"]').contains('Level'); - cy.get('[data-cy=nav-Users]') - .click(); - cy.wait('@loadUsers'); - cy.get('[data-cy=usersTable_viewDetailsBtn]') - .should('have.length', 4); + cy.visit('/administrator/projects/proj1/users'); + cy.get('[data-cy="skillsBTableTotalRows"]').should('have.text', '3'); + cy.get('[data-cy=users-skillIdFilter]').should('be.visible') cy.get('[data-cy=users-skillIdFilter]') .type('user1{enter}'); - cy.wait('@loadUsers'); - cy.get('[data-cy=usersTable_viewDetailsBtn]') - .should('have.length', 1); + cy.get('[data-cy="skillsBTableTotalRows"]').should('have.text', '1'); }); }); \ No newline at end of file diff --git a/e2e-tests/cypress/e2e/skills-display-integration_spec.js b/e2e-tests/cypress/e2e/skills-display-integration_spec.js index 2fc5093195..e930d3c954 100644 --- a/e2e-tests/cypress/e2e/skills-display-integration_spec.js +++ b/e2e-tests/cypress/e2e/skills-display-integration_spec.js @@ -59,75 +59,76 @@ describe('Navigation Tests', () => { .should('not.exist'); }); - it('Browser back button works in Skills Display', function () { - cy.createSkill(1, 1, 1); - cy.createSkill(1, 1, 2); - cy.createSkill(1, 1, 3); - cy.createSkill(1, 1, 4); - - cy.intercept('GET', '/api/projects/proj1/pointHistory*') - .as('pointHistoryChart'); - - cy.visit('/'); - - cy.get('[data-cy=inception-button]') - .should('not.exist'); - - cy.get('[data-cy=project-link-proj1]') - .click(); - cy.wait('@pointHistoryChart'); - cy.dashboardCd() - .contains('Overall Points'); - cy.dashboardCd() - .contains('Earn up to 800 points'); - - cy.get('[data-cy="breadcrumb-Progress And Rankings"]') - .should('be.visible'); - cy.get('[data-cy=breadcrumb-proj1]') - .should('be.visible'); - cy.get('[data-cy=breadcrumb-projects]') - .should('not.exist'); - - cy.dashboardCd() - .find('[data-cy=back]') - .should('not.exist'); - cy.dashboardCd() - .contains('PROJECT: This is project 1'); - - // to subject page - cy.dashboardCdClickSubj(0, 'Subject 1'); - cy.wait(1000); - - // navigate to Rank Overview and that it does NOT contains the internal back button - cy.dashboardCd() - .find('[data-cy=myRank]') - .click(); - cy.dashboardCd() - .contains('My Rank'); - cy.dashboardCd() - .find('[data-cy=back]') - .should('not.exist'); - - // click the browser back button and verify that we are still in the - // client display (Subject page) - cy.go('back'); // browser back button - cy.wait(1000); - cy.dashboardCd() - .contains('Subject 1'); - - // then back one more time and we should be back on the client display home page - cy.go('back'); // browser back button - cy.wait(1000); - cy.dashboardCd() - .contains('PROJECT: This is project 1'); - - // finally back one more time and we should be back on the my progress page - cy.go('back'); // browser back button - cy.wait(1000); - cy.get('[data-cy="breadcrumb-Progress And Rankings"]') - .contains('Progress And Rankings') - .should('be.visible'); - }); - + if (!Cypress.env('oauthMode')) { + it('Browser back button works in Skills Display', function () { + cy.createSkill(1, 1, 1); + cy.createSkill(1, 1, 2); + cy.createSkill(1, 1, 3); + cy.createSkill(1, 1, 4); + + cy.intercept('GET', '/api/projects/proj1/pointHistory*') + .as('pointHistoryChart'); + + cy.visit('/'); + + cy.get('[data-cy=inception-button]') + .should('not.exist'); + + cy.get('[data-cy=project-link-proj1]') + .click(); + cy.wait('@pointHistoryChart'); + cy.dashboardCd() + .contains('Overall Points'); + cy.dashboardCd() + .contains('Earn up to 800 points'); + + cy.get('[data-cy="breadcrumb-Progress And Rankings"]') + .should('be.visible'); + cy.get('[data-cy=breadcrumb-proj1]') + .should('be.visible'); + cy.get('[data-cy=breadcrumb-projects]') + .should('not.exist'); + + cy.dashboardCd() + .find('[data-cy=back]') + .should('not.exist'); + cy.dashboardCd() + .contains('PROJECT: This is project 1'); + + // to subject page + cy.dashboardCdClickSubj(0, 'Subject 1'); + cy.wait(1000); + + // navigate to Rank Overview and that it does NOT contains the internal back button + cy.dashboardCd() + .find('[data-cy=myRank]') + .click(); + cy.dashboardCd() + .contains('My Rank'); + cy.dashboardCd() + .find('[data-cy=back]') + .should('not.exist'); + + // click the browser back button and verify that we are still in the + // client display (Subject page) + cy.go('back'); // browser back button + cy.wait(1000); + cy.dashboardCd() + .contains('Subject 1'); + + // then back one more time and we should be back on the client display home page + cy.go('back'); // browser back button + cy.wait(1000); + cy.dashboardCd() + .contains('PROJECT: This is project 1'); + + // finally back one more time and we should be back on the my progress page + cy.go('back'); // browser back button + cy.wait(1000); + cy.get('[data-cy="breadcrumb-Progress And Rankings"]') + .contains('Progress And Rankings') + .should('be.visible'); + }); + } });