fix: correct registration flow in meal-plans tests
Some checks failed
Basil CI/CD Pipeline / Code Linting (push) Successful in 1m1s
Basil CI/CD Pipeline / Web Tests (push) Failing after 1m16s
Basil CI/CD Pipeline / API Tests (push) Failing after 1m24s
Basil CI/CD Pipeline / Shared Package Tests (push) Successful in 1m3s
Basil CI/CD Pipeline / Security Scanning (push) Successful in 1m8s
Basil CI/CD Pipeline / Build All Packages (push) Has been skipped
Basil CI/CD Pipeline / E2E Tests (push) Has been skipped
Basil CI/CD Pipeline / Build & Push Docker Images (push) Has been skipped
Basil CI/CD Pipeline / Trigger Deployment (push) Has been skipped

- Fix registration response path from body.data.user to body.user
- Add separate login call after registration to get accessToken
- Apply fix to both registration instances in test file
- Registration endpoint doesn't return token, must login separately

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-15 03:10:44 +00:00
parent a09784bd75
commit ffe17bfacf

View File

@@ -12,17 +12,29 @@ describe('Meal Plans Routes - Real Integration Tests', () => {
beforeAll(async () => {
// Suppress console.error to avoid noise from email sending failures
consoleErrorSpy = vi.spyOn(console, 'error').mockImplementation(() => {});
// Create test user and get auth token
// Create test user
const testEmail = `mealplan-test-${Date.now()}@example.com`;
const testPassword = 'TestPassword123!';
const userResponse = await request(app)
.post('/api/auth/register')
.send({
email: `mealplan-test-${Date.now()}@example.com`,
password: 'TestPassword123!',
email: testEmail,
password: testPassword,
name: 'Meal Plan Test User',
});
testUserId = userResponse.body.data.user.id;
authToken = userResponse.body.data.accessToken;
testUserId = userResponse.body.user.id;
// Login to get auth token
const loginResponse = await request(app)
.post('/api/auth/login')
.send({
email: testEmail,
password: testPassword,
});
authToken = loginResponse.body.accessToken;
// Create test recipe
const recipeResponse = await request(app)
@@ -492,16 +504,28 @@ describe('Meal Plans Routes - Real Integration Tests', () => {
beforeAll(async () => {
// Create another user
const otherEmail = `other-user-${Date.now()}@example.com`;
const otherPassword = 'OtherPassword123!';
const userResponse = await request(app)
.post('/api/auth/register')
.send({
email: `other-user-${Date.now()}@example.com`,
password: 'OtherPassword123!',
email: otherEmail,
password: otherPassword,
name: 'Other User',
});
otherUserId = userResponse.body.data.user.id;
otherUserToken = userResponse.body.data.accessToken;
otherUserId = userResponse.body.user.id;
// Login to get auth token
const loginResponse = await request(app)
.post('/api/auth/login')
.send({
email: otherEmail,
password: otherPassword,
});
otherUserToken = loginResponse.body.accessToken;
});
afterAll(async () => {