git clone https://github.com/sahar-fehri/express-booking.git
cd express-booking
docker-compose up
Under postman folder you will find the environment and the collection to import into your postman.
Import the collection and for the env change the ip to put your own IP.
Finally you should have a total of 5 endpoints.
Open your browser at http://ip:3000/api-docs/
-
Register a user
-
Login the user and copy the jwt token in the response
-
Click Authorize button and paste the token
-
Test the rest of the endpoints (book/cancel/availabilities)
Everytime you want to book with a new user please redo the first 3 steps
We suppose that room ids will go from 0 to 19 and the timestamps will come fromt the frontend, but for the sake of testing we wont use real timestamps.
Companies entered for user registration should be either: cola
or pepsi
-
Register a user by entering for example:
name: sam
email: sam@gmail.com
password: 123
company: cola
-
Login the user by entering:
email: sam@gmail.com
password: 123
-
Book a room with id:0 from 8AM to 9AM by sam:
resource: 0
from: 8
to: 9
Should be successful
-
Book same room with id:0 from 8AM to 9AM by sam:
resource: 0
from: 8
to: 9
Should fail with error text 'AlreadyBooked'
-
Book another room with id:2 from 11AM to 12 by sam:
resource: 2
from: 11
to: 12
Should be successful
-
Check availabilities (Should find two booked rooms)
-
Book another same room with id:2 from 11AM to 13AM ny sam
resource: 2
from: 11
to: 13
Should fail with error text 'Slot Already Booked'
-
Register another user:
name: elon
email: elon@gmail.com
password: 123
company: pepsi
-
Login the user by entering:
email: elon@gmail.com
password: 123
-
Cancel room already booked by sam with id:2 from 11AM to 12 by sam:
resource: 2
from: 11
to: 12
Should fail with errortext 'You did not book this slot'
You can try to book/cancel different slots and check the availibility.
If you try booking 10 different rooms with users from only cola for exp the 11th booking should fail.
Happy testing 😁 🎉