mirror of
https://github.com/LukasKanka/api_test.git
synced 2026-11-11 14:34:36 +01:00
AI
This commit is contained in:
1 parent
4b7af6ee7a
commit
2e185b47ef
12 files changed
+213
-6
No files matched your search
@@ -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
|
||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: AI
|
||||||
|
type: folder
|
||||||
|
seq: 3
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
File renamed without changes.
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Get specific spell
|
name: Get specific spell
|
||||||
type: http
|
type: http
|
||||||
seq: 3
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Get spells
|
name: Get spells
|
||||||
type: http
|
type: http
|
||||||
seq: 2
|
seq: 3
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: ShortingHat
|
name: ShortingHat
|
||||||
type: http
|
type: http
|
||||||
seq: 1
|
seq: 2
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: GET
|
method: GET
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: GET
|
||||||
|
type: folder
|
||||||
|
seq: 1
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
info:
|
info:
|
||||||
name: Add new sprll
|
name: Add new sprll
|
||||||
type: http
|
type: http
|
||||||
seq: 5
|
seq: 1
|
||||||
|
|
||||||
http:
|
http:
|
||||||
method: POST
|
method: POST
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
info:
|
||||||
|
name: POST
|
||||||
|
type: folder
|
||||||
|
seq: 2
|
||||||
|
|
||||||
|
request:
|
||||||
|
auth: inherit
|
||||||
+51
-2
@@ -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:
|
### 📋 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 ( ).
|
• 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
|
• 🪄 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).
|
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.
|
• 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)
|
## ⚙️ 1. Nastavení Bruno (Environment & Kolekce)
|
||||||
|
|
||||||
### Vytvoření prostředí (Environment)
|
### Vytvoření prostředí (Environment)
|
||||||
|
|||||||
Reference in new issue
Block a user