Skip to content

Conversation

@Flo2315
Copy link
Contributor

@Flo2315 Flo2315 commented Jun 28, 2021

Init Jest

  • installation de package suivants (certaines versions sont en alpha ou rc mais c'est les seuls qui fonctionnent), j'ai repris les versions installées sur leonardo (je crois que Joffrey avait géléré aussi à installer jest) car les dernières versions de certain packages genères des erreurs de compilation (vue-template-compiler)
"dependencies": {
   "@babel/preset-env": "^7.14.2",
   "@babel/preset-typescript": "^7.13.0",
},
"devDependencies": {
   "@types/jest": "^26.0.23",
   "@vue/compiler-sfc": "3.1.1",
   "@vue/test-utils": "^2.0.0-rc.6",
   "jest": "^26.6.3",
   "ts-jest": "^26.5.6",
   "vue-jest": "^5.0.0-alpha.9",
   "vue-loader": "^16.2.0",
   "vue-tsc": "^0.0.24"
}
  • Création d'un premier test de composant (LcButton) mêmes tests que sur donatello, j'ai un peu refacto et corrigé des erreurs car certain test failed, surtout lié à la partie link il manquait des condition dans le code.

  • Réorganisation du composant en créant un dossier LcButton qui contient le composant ainsi que les tests.

  • Configuration GithubAction pour les unit test

  • Mise en cache de yarn (node_modules) sur github actions https://github.com/actions/cache/blob/main/examples.md#node---yarn

@Flo2315 Flo2315 added the review label Jun 28, 2021
@Flo2315 Flo2315 force-pushed the feat/init-jest branch 3 times, most recently from 5977cba to 3a97a4d Compare June 29, 2021 02:43
@Flo2315 Flo2315 changed the base branch from master to dev June 29, 2021 06:28
@sbourdon13 sbourdon13 self-requested a review June 29, 2021 08:04
Copy link
Contributor

@sbourdon13 sbourdon13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment ça se fait qu'on ait la couleur red sur storybook ?
image

it('Should be a loader button', () => {
wrapper = mount(LcButton, { props: { loader: true } })

expect(wrapper.html()).toMatchSnapshot()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ce serait peut-être pas mal de vérifier que la div du loader existe ? Hier en faisant de la review j'ai vu un snapshot sur leonardo "should display list of result" qui avant la pr ne contenait aucun résultat 😬 donc je pense que c'est pas mal d'assurer ses arrières quand on utilise le snapshot, comme pour les classes juste en-dessous

})

it('Must have a primary color as default', () => {
expect(wrapper.html()).toMatchSnapshot()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pourquoi ne pas vérifier la classe primary plutôt ?

expect(wrapper.vm).toBeTruthy()
})

it('Should be a loader button', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est-ce qu'on mettrait pas des minuscules aux tests ?

expect(wrapper.classes('lc-btn--grey')).toBeTruthy()
})

it('Should have a black class color', async() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est-ce qu'on pourrait pas faire une boucle pour les 5 derniers test ? ils ont la même structure, y a que le nom de la couleur qui change

})

it('Must have a primary color as default', () => {
expect(wrapper.html()).toMatchSnapshot()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem autant tester la classe

expect(wrapper.classes('lc-link--black')).toBeTruthy()
})

it('Should have a white class color', async() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

idem est-ce qu'on peut faire une boucle


it('Should be a variant outline', () => {
wrapper = mount(LcButton, { props: { variant: 'outline' } })
// await wrapper.setProps({ variant: 'outline' })
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commentaire

expect(wrapper.classes('lc-btn--lg')).toBeTruthy()
})

it('Should have a xl class size', async() => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

boucle pour ces tests ?

})

describe('Link', () => {
it('Must be a none button', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je comprends pas ce que ça veut dire.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

je pas trop compris non plus, j'ai changé le wording du test

@@ -1,5 +1,5 @@
import LcTooltip from '../components/LcTooltip'
import LcButton from '../components/LcButton'
import LcButton from '../components/LcButton/LcButton'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

est-ce qu'on pourrait mettre index.vue pour alléger l'écriture, comme on a fait pour donatello Search/index.vue, ou est-ce que pour storybook ça doit être cette architecture de fichiers LcButton/LcButton ?

Copy link
Contributor Author

@Flo2315 Flo2315 Jun 30, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je t'avoue la j'ai fais au plus rapide pour centralisé tout dans le même dossier les "tests" et le "composant".
Je regarderait dans un autre ticket je pense car il y aura peut-être de la configuration lié à storybook ;)

@sbourdon13 sbourdon13 added rejected Changes are requested and removed review labels Jun 29, 2021
@Flo2315
Copy link
Contributor Author

Flo2315 commented Jun 30, 2021

comment ça se fait qu'on ait la couleur red sur storybook ?

J'ai ajouté la couleur rouge elle n'avait jamais été prévu pour le bouton mais seulement pour l'icone j'ai l'impression

@Flo2315 Flo2315 added review and removed rejected Changes are requested labels Jun 30, 2021
sbourdon13
sbourdon13 previously approved these changes Jun 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants