Skip to content

Commit

Permalink
Update test suite with "all" possible scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
wlsf82 committed Jul 29, 2024
1 parent 71f8347 commit d22f9ce
Showing 1 changed file with 61 additions and 2 deletions.
63 changes: 61 additions & 2 deletions cypress/e2e/checklist.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ describe('Cypress Skills Checklist', () => {
} else {
cy.visit('./src/index.html')
}

cy.contains('footer', '0 / ').should('be.visible')
cy.contains('footer', '(0%) - Nível: Iniciante (Jr.)').should('be.visible')
})

context('Footer', () => {
Expand All @@ -18,10 +21,66 @@ describe('Cypress Skills Checklist', () => {
cy.contains('footer', '0%').should('not.exist')
})

it('checking all checkboxes leads to 100% completion and the DevOps level', () => {
it('checking less than 50% of checkboxes keeps the skill at junior level', () => {
cy.get('input[type="checkbox"]')
.its('length')
.then(length => {
const numOfCheckboxesEquivalentoToLessThanFiftyPercent = (length / 2) - 1
const tempArray = Array(numOfCheckboxesEquivalentoToLessThanFiftyPercent).fill(0)
tempArray.forEach((_, index) => {
cy.get('input[type="checkbox"]').eq(index).check()
})
})

cy.contains('footer', 'Nível: Iniciante (Jr.)').should('be.visible')
})

it('checking at least 50% of checkboxes changes the skill to mid-level', () => {
cy.get('input[type="checkbox"]')
.its('length')
.then(length => {
const numOfCheckboxesEquivalentoToAtLeastFiftyPercent = length / 2
const tempArray = Array(numOfCheckboxesEquivalentoToAtLeastFiftyPercent).fill(0)
tempArray.forEach((_, index) => {
cy.get('input[type="checkbox"]').eq(index).check()
})
})

cy.contains('footer', '(50%) - Nível: Intermediário (Pleno)').should('be.visible')
})

it('checking at least 75% of checkboxes changes the skill to senior level', () => {
cy.get('input[type="checkbox"]')
.its('length')
.then(length => {
let numOfCheckboxesEquivalentoToAtLeastSeventyFivePercent = Math.ceil(length * .75)
const tempArray = Array(numOfCheckboxesEquivalentoToAtLeastSeventyFivePercent).fill(0)
tempArray.forEach((_, index) => {
cy.get('input[type="checkbox"]').eq(index).check()
})
})

cy.contains('footer', 'Nível: Avançado (Sr.)').should('be.visible')
})

it('checking at least 95% of checkboxes changes the skill to DevOps level', () => {
cy.get('input[type="checkbox"]')
.its('length')
.then(length => {
let numOfCheckboxesEquivalentoToAtLeastNinetyFivePercent = Math.ceil(length * .95)
const tempArray = Array(numOfCheckboxesEquivalentoToAtLeastNinetyFivePercent).fill(0)
tempArray.forEach((_, index) => {
cy.get('input[type="checkbox"]').eq(index).check()
})
})

cy.contains('footer', 'Nível: DevOps').should('be.visible')
})

it('claps to those who reach 100% of completion', () => {
cy.get('input[type="checkbox"]').check()

cy.contains('footer', '(100%) - Nível: DevOps').should('be.visible')
cy.contains('footer', '(100%) - Nível: DevOps 👏👏👏').should('be.visible')
})
})

Expand Down

0 comments on commit d22f9ce

Please sign in to comment.