Skip to content

Commit 26e17ab

Browse files
Merge branch 'fullstack-hy2020:source' into source
2 parents 4b84d0c + 0db2afd commit 26e17ab

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+6389
-1426
lines changed

src/components/InfoBanner.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,11 @@ const InfoBanner = ({ visible, onHide }) => {
4545
return (
4646
<div style={style}>
4747
<div style={textStyle}>
48+
<p style={{ marginBottom: 20}}>
49+
The testing libraries used in part 5 were changed 3rd March 2024. In frontend Vite replaced Jest. For End to end-tests Playwright is the new preferred library.
50+
</p>
4851
<p>
49-
The testing library used in part 4 was changed 13th February 2024 from Jest to Node:test.
50-
If you have started with Jest, you may continue. The relevant material is still available, see the "Legacy: testing with Jest"
52+
If you have started with Jest or Cypress, you may continue. The relevant material is still available, for Jest, the link is at the top of part 5c and for the Cypress, the link is at the menu at the left.
5153
</p>
5254
</div>
5355
<div style={buttonDiv}>

src/components/layout.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import Footer from './Footer/Footer';
1010
import PropTypes from 'prop-types';
1111
import SkipToContent from './SkipToContent/SkipToContent';
1212

13-
const BANNER_TO_KEY = 'part_4_changes';
13+
const BANNER_TO_KEY = 'part_5_changes';
1414

1515
const Layout = props => {
1616
const { i18n } = useTranslation();
@@ -23,7 +23,7 @@ const Layout = props => {
2323
useEffect(() => {
2424
const key = localStorage.getItem(BANNER_TO_KEY)
2525
if (!key) {
26-
const relevant = window.location.href.includes('osa4') || window.location.href.includes('en/part4')
26+
const relevant = window.location.href.includes('osa5') || window.location.href.includes('en/part5')
2727
setVisible(relevant);
2828
}
2929
}, []);

src/content/0/en/part0a.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,10 @@ Despite changes *all the submitted exercises remain valid*, and the course can b
340340
341341
Recent major changes
342342
343-
- Parts 1-9 (11th September - 5th October): Create React app replaced with Vite
343+
- Parts 3-5 (February-March 2024): Libraries used for testing changed
344+
- Part 10 (February 26, 2024): Library versions updated
344345
- Part 11 (16th January 2024): Example project dependencies updated
346+
- Parts 1-2, 6-9 (11th September - 5th October): Create React app replaced with Vite
345347
346348
### Expanding on a previously completed course
347349

src/content/0/fi/osa0a.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,10 @@ Kurssilla ei ole enää vuosittaisia versiota. Kurssi on siis käynnissä koko a
282282
Muutoksista huolimatta <i>kaikki jo tehdyt palautukset säilyvät voimassa</i>, eli voit jatkaa kurssia päivityksistä huolimatta normaaliin tapaan.
283283

284284
Viimeaikaisia isompia muutoksia
285-
- Osat 1-9 (11.9-5.10.2023): Create React app korvattu Vitellä
285+
- Osat 3-5 (helmi-maaliskuu 2024): Testaukseen käytetyt kirjastot muutettu
286+
- Osa 10 (26.2.2024): Kirjastoversiot päivitetty
286287
- Osa 11 (16.1.2024): Esimerkkiprojektin riippuvuudet päivitetty
288+
- Osat 1-2, 6-9 (11.9-5.10.2023): Create React app korvattu Vitellä
287289

288290
### Aiemmin suoritetun kurssin täydentäminen
289291

src/content/4/en/part4a.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ There is no strict directory structure or file naming convention that is require
329329
330330
You can find the code for our current application in its entirety in the <i>part4-1</i> branch of [this GitHub repository](https://github.com/fullstack-hy2020/part3-notes-backend/tree/part4-1).
331331
332-
If you clone the project for yourself, run the _npm install_ command before starting the application with _npm start_.
332+
If you clone the project for yourself, run the _npm install_ command before starting the application with _npm run dev_.
333333
334334
### Note on exports
335335

src/content/4/en/part4d.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,9 @@ The operation must respond with a suitable status code and some kind of an error
391391

392392
**NB** Do not test password restrictions with Mongoose validations. It is not a good idea because the password received by the backend and the password hash saved to the database are not the same thing. The password length should be validated in the controller as we did in [part 3](/en/part3/validation_and_es_lint) before using Mongoose validation.
393393

394-
Also, implement tests that ensure invalid users are not created and that an invalid add user operation returns a suitable status code and error message.
394+
Also, **implement tests** that ensure invalid users are not created and that an invalid add user operation returns a suitable status code and error message.
395+
396+
**NB** if you decide to define tests on multiple files, you should note that by default each test file is executed in its own process (see _Test execution model_ in the [documentation](https://nodejs.org/api/test.html)). The consequence of this is that different test files are executed at the same time. Since the tests share the same database, simultaneous execution may cause problems. Problems are avoided by executing the tests with the option _--test-concurrency=1_, i.e. defining them to be executed sequentially.
395397

396398
#### 4.17: Blog List Expansion, step 5
397399

src/content/4/es/part4a.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,7 @@ No existe una estructura de directorio estricta o una convención de nomenclatur
327327
328328
Puedes encontrar el código para nuestra aplicación actual en su totalidad en la rama <i>part4-1</i> de [este repositorio de GitHub](https://github.com/fullstack-hy2020/part3-notes-backend/tree/part4-1).
329329
330-
Si clonas el proyecto para ti mismo, ejecuta el comando _npm install_ antes de iniciar la aplicación con _npm start_.
330+
Si clonas el proyecto para ti mismo, ejecuta el comando _npm install_ antes de iniciar la aplicación con _npm run dev_.
331331
332332
### Nota sobre las exportaciones
333333

src/content/4/fi/osa4a.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -325,7 +325,7 @@ Express-sovelluksien rakenteelle eli hakemistojen ja tiedostojen nimeämiselle e
325325
326326
Sovelluksen tämänhetkinen koodi on kokonaisuudessaan [GitHubissa](https://github.com/fullstack-hy2020/part3-notes-backend/tree/part4-1) branchissa <i>part4-1</i>.
327327
328-
Jos kloonaat projektin itsellesi, suorita komento _npm install_ ennen käynnistämistä eli komentoa _npm start_.
328+
Jos kloonaat projektin itsellesi, suorita komento _npm install_ ennen käynnistämistä eli komentoa _npm run dev_.
329329
330330
### Huomio eksporteista
331331

src/content/4/fi/osa4b.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ Kaikki operaation suorituksen jälkeinen koodi kirjoitetaan tapahtumankäsitteli
398398
```js
399399
Note.find({})
400400
.then(notes => {
401-
return notes[0].remove()
401+
return notes[0].deleteOne()
402402
})
403403
.then(response => {
404404
console.log('the first note is removed')
@@ -424,7 +424,7 @@ Ylempänä oleva monimutkaisempi esimerkki suoritettaisiin awaitin avulla seuraa
424424

425425
```js
426426
const notes = await Note.find({})
427-
const response = await notes[0].remove()
427+
const response = await notes[0].deleteOne()
428428

429429
console.log('the first note is removed')
430430
```
@@ -442,7 +442,7 @@ const main = async () => { // highlight-line
442442
const notes = await Note.find({})
443443
console.log('operaatio palautti seuraavat muistiinpanot', notes)
444444

445-
const response = await notes[0].remove()
445+
const response = await notes[0].deleteOne()
446446
console.log('the first note is removed')
447447
}
448448

@@ -1014,7 +1014,7 @@ Huomaa, että joudut tekemään koodiin [materiaalin tapaan](/osa4/backendin_tes
10141014
10151015
#### 4.9: blogilistan testit, step2
10161016
1017-
Tee testi, joka varmistaa että palautettujen blogien identifioivan kentän tulee olla nimeltään <i>id</i>. Oletusarvoisestihan tietokantaan talletettujen olioiden tunnistekenttä on <i>_id</i>.
1017+
Tee testi, joka varmistaa että palautettujen blogien identifioivan kentän tulee olla nimeltään <i>id</i>. Oletusarvoisestihan tietokantaan talletettujen olioiden tunnistekenttä on <i>_id</i>.
10181018
10191019
Muuta koodia siten, että testi menee läpi. Osassa 3 käsitelty [toJSON](/osa3/tietojen_tallettaminen_mongo_db_tietokantaan#tietokantaa-kayttava-backend) on sopiva paikka parametrin <i>id</i> määrittelyyn.
10201020

src/content/4/fi/osa4d.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,9 @@ Luomisoperaation tulee palauttaa sopiva statuskoodi ja jonkinlainen virheilmoitu
353353

354354
**HUOM** älä testaa salasanaan liittyviä ehtoja Mongoosen validointien avulla, se ei ole hyvä idea, sillä backendin vastaanottama salasana ja kantaan tallennettu salasanan tiiviste eivät ole sama asia. Salasanan oikeellisuus kannattaa testata kontrollerissa samoin kun teimme [osassa 3](/osa3/validointi_ja_es_lint) ennen validointien käyttöönottoa.
355355

356-
Tee myös testit, jotka varmistavat, että virheellisiä käyttäjiä ei luoda, ja että virheellisen käyttäjän luomisoperaatioon vastaus on järkevä statuskoodin ja virheilmoituksen osalta.
356+
**Tee myös testit**, jotka varmistavat, että virheellisiä käyttäjiä ei luoda, ja että virheellisen käyttäjän luomisoperaatioon vastaus on järkevä statuskoodin ja virheilmoituksen osalta.
357+
358+
**HUOM** jos päätät tehdä testejä useaan eri tiedostoon, on syytä huomioida se, että oletusarvoisesti jokainen testitiedosto suoritetaan omassa prosessissaan (ks. kohta _Test execution model_ [dokumentaatiosta](https://nodejs.org/api/test.html)). Seurauksena tästä on se, että eri testitiedostoja suoritetaan yhtä aikaa. Koska testit käyttävät samaa tietokantaa, saattaa yhtäaikaisesta suorituksesta aiheutua ongelmia. Ongelmat vältetään kun testit suoritetaan optiolla _--test-concurrency=1_, eli määritellään ne suoritettavaksi peräkkäin.
357359

358360
#### 4.17: blogilistan laajennus, step5
359361

0 commit comments

Comments
 (0)