Skip to content

Commit

Permalink
#2948 Round percentages in transcript export
Browse files Browse the repository at this point in the history
  • Loading branch information
dwalizer committed Jan 14, 2025
1 parent f62b776 commit 5f71fa9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ export const useTranscriptPdfExport = () => {
}
overallStats.add(addStat(labelsConf.level, base64Images.trophy, 50, info.userLevel, info.totalLevels))
doc.moveUp()
const skillsPercentage = ((info.userSkillsCompleted / info.totalSkills) * 100).toFixed(1)
const pointsPercentage = ((info.userPoints / info.totalPoints) * 100).toFixed(1)
const skillsPercentage = Math.round((info.userSkillsCompleted / info.totalSkills) * 100)
const pointsPercentage = Math.round((info.userPoints / info.totalPoints) * 100)
overallStats.add(addStat(`${labelsConf.skill}s`, base64Images.arrowUp, 300, info.userSkillsCompleted, info.totalSkills, `(${skillsPercentage}%)`))
overallStats.add(addStat(`${labelsConf.point}s`, base64Images.hat, 50, info.userPoints, info.totalPoints, `(${pointsPercentage}%)`))
if (info.achievedBadges && info.achievedBadges.length > 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ describe('Transcript export tests', () => {
expect(clean(doc.text)).to.include('SkillTree Transcript')
expect(clean(doc.text)).to.include(projName)
expect(clean(doc.text)).to.include('Level: 1 / 5 ')
expect(clean(doc.text)).to.include('Points: 100 / 600 (16.7%)')
expect(clean(doc.text)).to.include('Skills: 0 / 3 (0.0%)')
expect(clean(doc.text)).to.include('Points: 100 / 600 (17%)')
expect(clean(doc.text)).to.include('Skills: 0 / 3 (0%)')
expect(clean(doc.text)).to.not.include('Badges')

// should be a title on the 2nd page
Expand Down Expand Up @@ -155,8 +155,8 @@ describe('Transcript export tests', () => {
expect(clean(doc.text)).to.include('SkillTree Transcript')
expect(clean(doc.text)).to.include(projName)
expect(clean(doc.text)).to.include('Level: 1 / 5 ')
expect(clean(doc.text)).to.include('Points: 600 / 2,600 (23.1%)')
expect(clean(doc.text)).to.include('Skills: 6 / 26 (23.1%)')
expect(clean(doc.text)).to.include('Points: 600 / 2,600 (23%)')
expect(clean(doc.text)).to.include('Skills: 6 / 26 (23%)')
expect(clean(doc.text)).to.not.include('Badges')

// should be a title on the 2nd-4th pages
Expand Down Expand Up @@ -204,8 +204,8 @@ describe('Transcript export tests', () => {
expect(clean(doc.text)).to.include('SkillTree Transcript')
expect(clean(doc.text)).to.include(projName)
expect(clean(doc.text)).to.include('Level: 1 / 5 ')
expect(clean(doc.text)).to.include('Points: 600 / 2,600 (23.1%)')
expect(clean(doc.text)).to.include('Skills: 6 / 26 (23.1%)')
expect(clean(doc.text)).to.include('Points: 600 / 2,600 (23%)')
expect(clean(doc.text)).to.include('Skills: 6 / 26 (23%)')
expect(clean(doc.text)).to.include('Badges: 1 ')

// should be a title on the 2nd page
Expand Down Expand Up @@ -403,8 +403,8 @@ describe('Transcript export tests', () => {
expect(clean(doc.text)).to.include('SkillTree Transcript')
expect(clean(doc.text)).to.include(projName)
expect(clean(doc.text)).to.include('Level: 0 / 5 ')
expect(clean(doc.text)).to.include('Points: 600 / 21,000 (2.9%)')
expect(clean(doc.text)).to.include('Skills: 6 / 210 (2.9%)')
expect(clean(doc.text)).to.include('Points: 600 / 21,000 (3%)')
expect(clean(doc.text)).to.include('Skills: 6 / 210 (3%)')
expect(clean(doc.text)).to.not.include('Badges ')

// should be a title on the 2nd-4th pages
Expand Down Expand Up @@ -607,8 +607,8 @@ describe('Transcript export tests', () => {
expect(clean(doc.text)).to.include(user1)
expect(clean(doc.text)).to.not.include(user2)
expect(clean(doc.text)).to.include('Level: 1 / 5 ')
expect(clean(doc.text)).to.include('Points: 400 / 2,600 (15.4%)')
expect(clean(doc.text)).to.include('Skills: 4 / 26 (15.4%)')
expect(clean(doc.text)).to.include('Points: 400 / 2,600 (15%)')
expect(clean(doc.text)).to.include('Skills: 4 / 26 (15%)')
expect(clean(doc.text)).to.not.include('Badges')
})

Expand All @@ -624,8 +624,8 @@ describe('Transcript export tests', () => {
expect(clean(doc.text)).to.include(user2)
expect(clean(doc.text)).to.not.include(user1)
expect(clean(doc.text)).to.include('Level: 0 / 5 ')
expect(clean(doc.text)).to.include('Points: 200 / 2,600 (7.7%)')
expect(clean(doc.text)).to.include('Skills: 2 / 26 (7.7%)')
expect(clean(doc.text)).to.include('Points: 200 / 2,600 (8%)')
expect(clean(doc.text)).to.include('Skills: 2 / 26 (8%)')
expect(clean(doc.text)).to.not.include('Badges')
})

Expand Down Expand Up @@ -691,7 +691,7 @@ describe('Transcript export tests', () => {
cy.get('[data-cy="downloadTranscriptBtn"]').click()

cy.readTranscript(projName).then((doc) => {
expect(clean(doc.text)).to.include('Skills: 2 / 4 (50.0%)')
expect(clean(doc.text)).to.include('Skills: 2 / 4 (50%)')
expect(clean(doc.text)).to.include('Achieved On')
expect(clean(doc.text)).to.not.include('Approver')
expect(clean(doc.text)).to.include(today)
Expand Down Expand Up @@ -722,7 +722,7 @@ describe('Transcript export tests', () => {
cy.get('[data-cy="downloadTranscriptBtn"]').click()

cy.readTranscript(projName).then((doc) => {
expect(clean(doc.text)).to.include('Skills: 2 / 4 (50.0%)')
expect(clean(doc.text)).to.include('Skills: 2 / 4 (50%)')
expect(clean(doc.text)).to.include('Achieved On')
expect(clean(doc.text)).to.include('Approver')
expect(clean(doc.text)).to.include(today)
Expand Down Expand Up @@ -752,7 +752,7 @@ describe('Transcript export tests', () => {
cy.get('[data-cy="downloadTranscriptBtn"]').click()

cy.readTranscript(projName).then((doc) => {
expect(clean(doc.text)).to.include('Skills: 0 / 4 (0.0%)')
expect(clean(doc.text)).to.include('Skills: 0 / 4 (0%)')
expect(clean(doc.text)).to.include('Achieved On')
expect(clean(doc.text)).to.not.include('Approver')
})
Expand Down

0 comments on commit 5f71fa9

Please sign in to comment.