diff --git a/apiTest/PotterAPI/AI/AI - Get house by ID.yml b/apiTest/PotterAPI/AI/AI - Get house by ID.yml new file mode 100644 index 0000000..680d656 --- /dev/null +++ b/apiTest/PotterAPI/AI/AI - Get house by ID.yml @@ -0,0 +1,47 @@ +info: + name: AI - Get spells list + type: http + seq: 3 + +http: + method: GET + url: http://localhost:3000/spells + auth: inherit + +runtime: + scripts: + - type: tests + code: |- + const status = res.getStatus() + const body = res.getBody() + + test("Status code is 200", function() { + expect(status).to.equal(200); + }); + + test("Response should be an array", function(){ + expect(body).to.be.an('array') + }) + + test("Array should not be empty", function(){ + expect(body).to.not.be.empty + }) + + test("Array should have at least 10 spells", function(){ + expect(body.length).to.be.at.least(10) + }) + + test("First item should have spell key", function(){ + expect(body[0]).to.contain.key("spell") + }) + + test("First item should have type key", function(){ + expect(body[0]).to.contain.key("type") + }) + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false diff --git a/apiTest/PotterAPI/AI/AI - Get random house.yml b/apiTest/PotterAPI/AI/AI - Get random house.yml new file mode 100644 index 0000000..6e67065 --- /dev/null +++ b/apiTest/PotterAPI/AI/AI - Get random house.yml @@ -0,0 +1,47 @@ +info: + name: AI - Get random house + type: http + seq: 2 + +http: + method: GET + url: http://localhost:3000/sortingHat + auth: inherit + +runtime: + scripts: + - type: tests + code: |- + const status = res.getStatus() + const body = res.getBody() + + test("Status code is 200", function() { + expect(status).to.equal(200); + }); + + test("Response should contain sortingHatSays key", function(){ + expect(body).to.contain.key("sortingHatSays") + }) + + test("Response should contain house key", function(){ + expect(body).to.contain.key("house") + }) + + test("sortingHatSays should not be empty", function(){ + expect(body.sortingHatSays).not.to.be.empty + }) + + test("House should be one of the four Hogwarts houses", function(){ + expect(body.house).is.oneOf(["Gryffindor", "Slytherin", "Ravenclaw", "Hufflepuff"]) + }) + + test("Response time is less than 600 ms", function(){ + expect(res.responseTime).to.be.below(600) + }) + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false diff --git a/apiTest/PotterAPI/AI/AI - Get random quote.yml b/apiTest/PotterAPI/AI/AI - Get random quote.yml new file mode 100644 index 0000000..2ec98ef --- /dev/null +++ b/apiTest/PotterAPI/AI/AI - Get random quote.yml @@ -0,0 +1,43 @@ +info: + name: AI - Get random quote + type: http + seq: 1 + +http: + method: GET + url: http://localhost:3000/quote + auth: inherit + +runtime: + scripts: + - type: tests + code: |- + const status = res.getStatus() + const body = res.getBody() + + test("Status code is 200", function() { + expect(status).to.equal(200); + }); + + test("Response should contain author key", function(){ + expect(body).to.contain.key("author") + }) + + test("Response should contain quote key", function(){ + expect(body).to.contain.key("quote") + }) + + test("Author should not be empty", function(){ + expect(body.author).not.to.be.empty + }) + + test("Quote should not be empty", function(){ + expect(body.quote).not.to.be.empty + }) + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false diff --git a/apiTest/PotterAPI/AI/folder.yml b/apiTest/PotterAPI/AI/folder.yml new file mode 100644 index 0000000..b2995cb --- /dev/null +++ b/apiTest/PotterAPI/AI/folder.yml @@ -0,0 +1,7 @@ +info: + name: AI + type: folder + seq: 3 + +request: + auth: inherit diff --git a/apiTest/PotterAPI/Get specific spell schama.yml b/apiTest/PotterAPI/GET/Get specific spell schama.yml similarity index 100% rename from apiTest/PotterAPI/Get specific spell schama.yml rename to apiTest/PotterAPI/GET/Get specific spell schama.yml diff --git a/apiTest/PotterAPI/Get specific spell.yml b/apiTest/PotterAPI/GET/Get specific spell.yml similarity index 98% rename from apiTest/PotterAPI/Get specific spell.yml rename to apiTest/PotterAPI/GET/Get specific spell.yml index 5fa67fe..dc82d50 100644 --- a/apiTest/PotterAPI/Get specific spell.yml +++ b/apiTest/PotterAPI/GET/Get specific spell.yml @@ -1,7 +1,7 @@ info: name: Get specific spell type: http - seq: 3 + seq: 1 http: method: GET diff --git a/apiTest/PotterAPI/Get spells.yml b/apiTest/PotterAPI/GET/Get spells.yml similarity index 98% rename from apiTest/PotterAPI/Get spells.yml rename to apiTest/PotterAPI/GET/Get spells.yml index 8e496b0..872cf35 100644 --- a/apiTest/PotterAPI/Get spells.yml +++ b/apiTest/PotterAPI/GET/Get spells.yml @@ -1,7 +1,7 @@ info: name: Get spells type: http - seq: 2 + seq: 3 http: method: GET diff --git a/apiTest/PotterAPI/ShortingHat.yml b/apiTest/PotterAPI/GET/ShortingHat.yml similarity index 99% rename from apiTest/PotterAPI/ShortingHat.yml rename to apiTest/PotterAPI/GET/ShortingHat.yml index 506a8d8..201472d 100644 --- a/apiTest/PotterAPI/ShortingHat.yml +++ b/apiTest/PotterAPI/GET/ShortingHat.yml @@ -1,7 +1,7 @@ info: name: ShortingHat type: http - seq: 1 + seq: 2 http: method: GET diff --git a/apiTest/PotterAPI/GET/folder.yml b/apiTest/PotterAPI/GET/folder.yml new file mode 100644 index 0000000..82b8a18 --- /dev/null +++ b/apiTest/PotterAPI/GET/folder.yml @@ -0,0 +1,7 @@ +info: + name: GET + type: folder + seq: 1 + +request: + auth: inherit diff --git a/apiTest/PotterAPI/Add new sprll.yml b/apiTest/PotterAPI/POST/Add new sprll.yml similarity index 98% rename from apiTest/PotterAPI/Add new sprll.yml rename to apiTest/PotterAPI/POST/Add new sprll.yml index 92f49e6..4444b1d 100644 --- a/apiTest/PotterAPI/Add new sprll.yml +++ b/apiTest/PotterAPI/POST/Add new sprll.yml @@ -1,7 +1,7 @@ info: name: Add new sprll type: http - seq: 5 + seq: 1 http: method: POST diff --git a/apiTest/PotterAPI/POST/folder.yml b/apiTest/PotterAPI/POST/folder.yml new file mode 100644 index 0000000..7ac73ca --- /dev/null +++ b/apiTest/PotterAPI/POST/folder.yml @@ -0,0 +1,7 @@ +info: + name: POST + type: folder + seq: 2 + +request: + auth: inherit diff --git a/bruno_test_scenario.md b/bruno_test_scenario.md index a416312..87943c9 100644 --- a/bruno_test_scenario.md +++ b/bruno_test_scenario.md @@ -4,9 +4,12 @@ Tento dokument obsahuje přehled testovacích scénářů, tipů, triků a autom ### 📋 Stručné shrnutí toho, co v dokumentu najdete: - 1. Nastavení prostředí (Environment v Bruno): + 1. Spouštění aplikace (Backend & Frontend): + • Spuštění backend serveru na portu 3000. + • Spuštění frontend aplikace. + 2. Nastavení prostředí (Environment v Bruno): • Nastavení proměnných baseUrl (http://localhost:3000), username ( ), password ( ). - 2. Testovací scénáře pro všechny API služby: + 3. Testovací scénáře pro všechny API služby: • 🪄 Kouzla (/spells): Pozitivní testy (seznam, detail, nový záznam, úprava, smazání) a negativní testy (duplicity, chybějící Content-Type: application/json hlavička, 422 Joi validace, 404). @@ -26,6 +29,52 @@ Tento dokument obsahuje přehled testovacích scénářů, tipů, triků a autom • Postup, jak nastavit kompletní CRUD cyklus: POST ➡️ GET detail ➡️ PUT ➡️ DELETE ➡️ GET 404. --- +## 🚀 Spouštění aplikace + +Před spuštěním testů je nutné spustit backend server a případně i frontend aplikaci. + +### Backend (API Server) + +Backend je Express.js aplikace běžící na portu **3000**. + +**Spuštění z kořenové složky projektu:** +```bash +cd web/backend +npm install # Nainstaluje závislosti (pokud ještě nejsou nainstalovány) +npm start # Spustí server pomocí nodemon (automaticky restartuje při změnách) +``` + +**Přímé spuštění bez nodemon:** +```bash +cd web/backend +node app.js +``` + +Server bude dostupný na `http://localhost:3000`. + +> [!TIP] +> Pokud je port 3000 obsazen, je nutné jej uvolnit nebo změnit port přímo v souboru `web/backend/app.js` (řádek 9: `const port = 3000`). + +### Frontend (Vue.js Aplikace) + +Frontend je Vue.js aplikace, kterou lze spustit pro vývojové účely. + +**Spuštění z kořenové složky projektu:** +```bash +cd web/frontend +npm install # Nainstaluje závislosti (pokud ještě nejsou nainstalovány) +npm run serve # Spustí vývojový server (obvykle na portu 8080) +# nebo +npm start # Stejné jako npm run serve +``` + +Frontend bude dostupný na `http://localhost:8080`. + +> [!NOTE] +> Pro samotné testování API pomocí Bruno není spuštění frontend nutné. Stačí mít běžící backend server. + +--- + ## ⚙️ 1. Nastavení Bruno (Environment & Kolekce) ### Vytvoření prostředí (Environment)