test: fix auth test expectations and add test commands to Makefile
- Update auth.test.js to match current API error messages - Registration success message includes email verification notice - Duplicate credentials use generic message to prevent user enumeration - Add test commands to Makefile - make test: run all backend tests - make test-watch: run tests in watch mode - make test-coverage: run tests with coverage report All auth tests now pass (19/19 ✓)
This commit is contained in:
16
Makefile
16
Makefile
@@ -11,7 +11,8 @@ endif
|
||||
|
||||
.PHONY: help dev-cli prod-cli \
|
||||
dev-up dev-down dev-up-rebuild \
|
||||
prod-up prod-down prod-up-rebuild
|
||||
prod-up prod-down prod-up-rebuild \
|
||||
test test-watch test-coverage
|
||||
|
||||
help:
|
||||
@echo "Available targets:"
|
||||
@@ -23,6 +24,9 @@ help:
|
||||
@echo " make prod-up # docker compose --profile prod up -d"
|
||||
@echo " make prod-up-rebuild # docker compose --profile prod up -d --build"
|
||||
@echo " make prod-down # docker compose --profile prod down"
|
||||
@echo " make test # Run backend tests"
|
||||
@echo " make test-watch # Run backend tests in watch mode"
|
||||
@echo " make test-coverage # Run backend tests with coverage report"
|
||||
@echo "Notes: GNU Make nie wspiera subkomend z odstępami (np. 'make prod up')."
|
||||
@echo " Użyj odpowiednich celów z myślnikiem."
|
||||
|
||||
@@ -52,3 +56,13 @@ prod-up-rebuild:
|
||||
|
||||
prod-down:
|
||||
$(COMPOSE) --profile prod down
|
||||
|
||||
# Tests
|
||||
test:
|
||||
$(COMPOSE) exec $(BACKEND_SVC) npm test
|
||||
|
||||
test-watch:
|
||||
$(COMPOSE) exec $(BACKEND_SVC) npm run test:watch
|
||||
|
||||
test-coverage:
|
||||
$(COMPOSE) exec $(BACKEND_SVC) npm test -- --coverage
|
||||
|
||||
@@ -27,7 +27,7 @@ describe('Authentication API Tests', () => {
|
||||
.expect(201);
|
||||
|
||||
expect(response.body).toHaveProperty('success', true);
|
||||
expect(response.body).toHaveProperty('message', 'User registered successfully');
|
||||
expect(response.body).toHaveProperty('message', 'User registered successfully. Please check your email to verify your account.');
|
||||
expect(response.body.data).toHaveProperty('user');
|
||||
expect(response.body.data).toHaveProperty('token');
|
||||
expect(response.body.data.user).toHaveProperty('id');
|
||||
@@ -49,7 +49,7 @@ describe('Authentication API Tests', () => {
|
||||
.expect(400);
|
||||
|
||||
expect(response.body).toHaveProperty('success', false);
|
||||
expect(response.body).toHaveProperty('error', 'Email already registered');
|
||||
expect(response.body).toHaveProperty('error', 'An account with these credentials already exists. Please try logging in or use different credentials.');
|
||||
});
|
||||
|
||||
it('should reject registration with duplicate username', async () => {
|
||||
@@ -64,7 +64,7 @@ describe('Authentication API Tests', () => {
|
||||
.expect(400);
|
||||
|
||||
expect(response.body).toHaveProperty('success', false);
|
||||
expect(response.body).toHaveProperty('error', 'Username already taken');
|
||||
expect(response.body).toHaveProperty('error', 'An account with these credentials already exists. Please try logging in or use different credentials.');
|
||||
});
|
||||
|
||||
it('should reject registration with invalid email', async () => {
|
||||
|
||||
Reference in New Issue
Block a user