Pr pour correction groupe room #5#2
Conversation
did 4 e2e tests
Co-authored-by: Kym <kymbibop@users.noreply.github.com>
| cy.get('input.input-field').type('Michel') | ||
| cy.get('#startOptions > :nth-child(2)').select('Geography') | ||
| cy.get('.start-button').click() | ||
| cy.get('.choices > :nth-child(1)').click() |
dannyforest
left a comment
There was a problem hiding this comment.
À cause des commentaires dans LocalStorage.spec.js, j'ai dû compter 4 tests qu'on n'étant pas bons. Donc j'ai dû enlever 4 tests non-fonctionnels.
Le total est donc de 4/5 pour les tests unitaires.
Note finale:
Section 1: 4/5
Section 2: 4/5
Section 3: 5/5
Section 4: 5/5
Total: 18/20
| cy.get('.add-question-button').then(($button) => { | ||
| $button.click() | ||
| expect(stub.getCall(0)).to.be.calledWith('Questions saved!') | ||
| cy.get(':nth-child(53)').should('be.visible') // #4 |
There was a problem hiding this comment.
c'est dangereux ici de check pour index 53. Il serait plutôt recommander de trouver exactement celui que vous venez d'ajouter sans se fier à l'index.
| it('removes a question', () => { | ||
| const stub = cy.stub() | ||
| cy.on('window:confirm', stub) | ||
| cy.get(':nth-child(52) > .delete-button').then(($button) => { |
| it('show when there is no category selected', () => { | ||
| const wrapper = mount(Leaderboards) | ||
|
|
||
| expect(wrapper.text()).toContain('Leaderboards') // #1 |
There was a problem hiding this comment.
Si vous avez accès à un sélecteur plus direct, c'est mieux
| } | ||
| ] | ||
| }) | ||
| vi.stubGlobal('localStorage', { |
| it('reads local storage', () => { | ||
| wrapper = mount(Leaderboards) | ||
|
|
||
| expect(wrapper.vm.highScores).toStrictEqual(mockHighScores) // #3 |
There was a problem hiding this comment.
hmm... il n'y a pas de chances que ce soit autrement puisque vous le mettez directement à la ligne 48. Ici on devrait plutôt faire un mockReturnValue au lieu d'un setItem(). Je ne peux pas compter ce test comme un bon test malheureusement.
|
|
||
| await wrapper.vm.updateHighScore() | ||
|
|
||
| expect(JSON.parse(localStorage.getItem('highScores'))).toStrictEqual(mockHighScores) // #6 |
There was a problem hiding this comment.
le getItem() ici n'a pas le choix de valoir mockHighScores, encore une fois à cause que c'est set dans le beforeEach()
|
|
||
| describe('initial state', () => { | ||
| it('verifies options and categories', () => { | ||
| expect(wrapper.findAll('select')[0].findAll('option')[0].text()).toBe('Select a category') // #20 |
There was a problem hiding this comment.
amélioration possible: faire une variable avec: wrapper.findAll('select')[0].findAll('option')
| it('verifies options and categories', () => { | ||
| expect(wrapper.findAll('select')[0].findAll('option')[0].text()).toBe('Select a category') // #20 | ||
| expect(wrapper.findAll('select')[0].findAll('option').length).toEqual( | ||
| wrapper.props('categories').length + 1 |
There was a problem hiding this comment.
amélioration possible: le +1 serait plus clair avec un commentaire
| }) | ||
| }) | ||
| it('counts down', async () => { | ||
| vi.advanceTimersByTime(10000) |
There was a problem hiding this comment.
ça pouvait aussi ce faire avec wrapper.tick(10000) si je ne me trompe pas.
| } | ||
| }) | ||
| const LeaderboardsComponent = wrapper.findComponent(Leaderboards) | ||
| expect(LeaderboardsComponent.exists()).toBeTruthy() // #8 |
There was a problem hiding this comment.
ça aurait pu être fait dans le même it()
No description provided.