fix issues
This commit is contained in:
@@ -88,7 +88,7 @@ describe('League roster admin read (HTTP, league-scoped)', () => {
|
||||
|
||||
await agent
|
||||
.post('/auth/signup')
|
||||
.send({ email: 'roster-read-user@gridpilot.local', password: 'pw1', displayName: 'Roster Read User' })
|
||||
.send({ email: 'roster-read-user@gridpilot.local', password: 'Password123!', displayName: 'Roster Read User' })
|
||||
.expect(201);
|
||||
|
||||
await agent.get('/leagues/league-5/admin/roster/members').expect(403);
|
||||
|
||||
@@ -79,7 +79,7 @@ describe('League schedule admin CRUD (HTTP, season-scoped)', () => {
|
||||
|
||||
it('rejects unauthenticated actor (401)', async () => {
|
||||
await request(app.getHttpServer())
|
||||
.post('/leagues/league-5/seasons/season-1/schedule/races')
|
||||
.post('/leagues/league-5/seasons/league-5-season-1/schedule/races')
|
||||
.send({
|
||||
track: 'Test Track',
|
||||
car: 'Test Car',
|
||||
@@ -93,11 +93,11 @@ describe('League schedule admin CRUD (HTTP, season-scoped)', () => {
|
||||
|
||||
await agent
|
||||
.post('/auth/signup')
|
||||
.send({ email: 'user1@gridpilot.local', password: 'pw1', displayName: 'User 1' })
|
||||
.send({ email: 'user1@gridpilot.local', password: 'Password123!', displayName: 'John Smith' })
|
||||
.expect(201);
|
||||
|
||||
await agent
|
||||
.post('/leagues/league-5/seasons/season-1/schedule/races')
|
||||
.post('/leagues/league-5/seasons/league-5-season-1/schedule/races')
|
||||
.send({
|
||||
track: 'Test Track',
|
||||
car: 'Test Car',
|
||||
@@ -133,13 +133,14 @@ describe('League schedule admin CRUD (HTTP, season-scoped)', () => {
|
||||
.send({ email: 'admin@gridpilot.local', password: 'admin123' })
|
||||
.expect(201);
|
||||
|
||||
const initialScheduleRes = await agent.get('/leagues/league-5/schedule?seasonId=season-1').expect(200);
|
||||
expect(initialScheduleRes.body).toMatchObject({ seasonId: 'season-1', races: expect.any(Array) });
|
||||
const initialScheduleRes = await agent.get('/leagues/league-5/schedule?seasonId=league-5-season-1').expect(200);
|
||||
expect(initialScheduleRes.body).toMatchObject({ seasonId: 'league-5-season-1', races: expect.any(Array) });
|
||||
|
||||
const scheduledAtIso = new Date(Date.now() + 2 * 24 * 60 * 60 * 1000).toISOString();
|
||||
// Try a date further in the future (100 days)
|
||||
const scheduledAtIso = new Date(Date.now() + 100 * 24 * 60 * 60 * 1000).toISOString();
|
||||
|
||||
const createRes = await agent
|
||||
.post('/leagues/league-5/seasons/season-1/schedule/races')
|
||||
.post('/leagues/league-5/seasons/league-5-season-1/schedule/races')
|
||||
.send({
|
||||
track: 'Test Track',
|
||||
car: 'Test Car',
|
||||
@@ -150,7 +151,7 @@ describe('League schedule admin CRUD (HTTP, season-scoped)', () => {
|
||||
expect(createRes.body).toMatchObject({ raceId: expect.any(String) });
|
||||
const raceId: string = createRes.body.raceId;
|
||||
|
||||
const afterCreateRes = await agent.get('/leagues/league-5/schedule?seasonId=season-1').expect(200);
|
||||
const afterCreateRes = await agent.get('/leagues/league-5/schedule?seasonId=league-5-season-1').expect(200);
|
||||
const createdRace = (afterCreateRes.body.races as any[]).find((r) => r.id === raceId);
|
||||
expect(createdRace).toMatchObject({
|
||||
id: raceId,
|
||||
@@ -158,10 +159,10 @@ describe('League schedule admin CRUD (HTTP, season-scoped)', () => {
|
||||
date: scheduledAtIso,
|
||||
});
|
||||
|
||||
const updatedAtIso = new Date(Date.now() + 3 * 24 * 60 * 60 * 1000).toISOString();
|
||||
const updatedAtIso = new Date(Date.now() + 105 * 24 * 60 * 60 * 1000).toISOString();
|
||||
|
||||
await agent
|
||||
.patch(`/leagues/league-5/seasons/season-1/schedule/races/${raceId}`)
|
||||
.patch(`/leagues/league-5/seasons/league-5-season-1/schedule/races/${raceId}`)
|
||||
.send({
|
||||
track: 'Updated Track',
|
||||
car: 'Updated Car',
|
||||
@@ -172,7 +173,7 @@ describe('League schedule admin CRUD (HTTP, season-scoped)', () => {
|
||||
expect(res.body).toEqual({ success: true });
|
||||
});
|
||||
|
||||
const afterUpdateRes = await agent.get('/leagues/league-5/schedule?seasonId=season-1').expect(200);
|
||||
const afterUpdateRes = await agent.get('/leagues/league-5/schedule?seasonId=league-5-season-1').expect(200);
|
||||
const updatedRace = (afterUpdateRes.body.races as any[]).find((r) => r.id === raceId);
|
||||
expect(updatedRace).toMatchObject({
|
||||
id: raceId,
|
||||
@@ -180,11 +181,11 @@ describe('League schedule admin CRUD (HTTP, season-scoped)', () => {
|
||||
date: updatedAtIso,
|
||||
});
|
||||
|
||||
await agent.delete(`/leagues/league-5/seasons/season-1/schedule/races/${raceId}`).expect(200).expect({
|
||||
await agent.delete(`/leagues/league-5/seasons/league-5-season-1/schedule/races/${raceId}`).expect(200).expect({
|
||||
success: true,
|
||||
});
|
||||
|
||||
const afterDeleteRes = await agent.get('/leagues/league-5/schedule?seasonId=season-1').expect(200);
|
||||
const afterDeleteRes = await agent.get('/leagues/league-5/schedule?seasonId=league-5-season-1').expect(200);
|
||||
const deletedRace = (afterDeleteRes.body.races as any[]).find((r) => r.id === raceId);
|
||||
expect(deletedRace).toBeUndefined();
|
||||
});
|
||||
|
||||
@@ -79,12 +79,12 @@ describe('League season schedule publish/unpublish (HTTP, season-scoped)', () =>
|
||||
|
||||
it('rejects unauthenticated actor (401)', async () => {
|
||||
await request(app.getHttpServer())
|
||||
.post('/leagues/league-5/seasons/season-1/schedule/publish')
|
||||
.post('/leagues/league-5/seasons/league-5-season-1/schedule/publish')
|
||||
.send({})
|
||||
.expect(401);
|
||||
|
||||
await request(app.getHttpServer())
|
||||
.post('/leagues/league-5/seasons/season-1/schedule/unpublish')
|
||||
.post('/leagues/league-5/seasons/league-5-season-1/schedule/unpublish')
|
||||
.send({})
|
||||
.expect(401);
|
||||
});
|
||||
@@ -94,11 +94,11 @@ describe('League season schedule publish/unpublish (HTTP, season-scoped)', () =>
|
||||
|
||||
await agent
|
||||
.post('/auth/signup')
|
||||
.send({ email: 'user2@gridpilot.local', password: 'pw2', displayName: 'User 2' })
|
||||
.send({ email: 'user2@gridpilot.local', password: 'Password123!', displayName: 'Jane Smith' })
|
||||
.expect(201);
|
||||
|
||||
await agent.post('/leagues/league-5/seasons/season-1/schedule/publish').send({}).expect(403);
|
||||
await agent.post('/leagues/league-5/seasons/season-1/schedule/unpublish').send({}).expect(403);
|
||||
await agent.post('/leagues/league-5/seasons/league-5-season-1/schedule/publish').send({}).expect(403);
|
||||
await agent.post('/leagues/league-5/seasons/league-5-season-1/schedule/unpublish').send({}).expect(403);
|
||||
});
|
||||
|
||||
it('publish/unpublish toggles state and is reflected via schedule read (happy path)', async () => {
|
||||
@@ -109,39 +109,39 @@ describe('League season schedule publish/unpublish (HTTP, season-scoped)', () =>
|
||||
.send({ email: 'admin@gridpilot.local', password: 'admin123' })
|
||||
.expect(201);
|
||||
|
||||
const initialScheduleRes = await agent.get('/leagues/league-5/schedule?seasonId=season-1').expect(200);
|
||||
const initialScheduleRes = await agent.get('/leagues/league-5/schedule?seasonId=league-5-season-1').expect(200);
|
||||
expect(initialScheduleRes.body).toMatchObject({
|
||||
seasonId: 'season-1',
|
||||
seasonId: 'league-5-season-1',
|
||||
published: false,
|
||||
races: expect.any(Array),
|
||||
});
|
||||
|
||||
await agent
|
||||
.post('/leagues/league-5/seasons/season-1/schedule/publish')
|
||||
.post('/leagues/league-5/seasons/league-5-season-1/schedule/publish')
|
||||
.send({})
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
expect(res.body).toEqual({ success: true, published: true });
|
||||
});
|
||||
|
||||
const afterPublishRes = await agent.get('/leagues/league-5/schedule?seasonId=season-1').expect(200);
|
||||
const afterPublishRes = await agent.get('/leagues/league-5/schedule?seasonId=league-5-season-1').expect(200);
|
||||
expect(afterPublishRes.body).toMatchObject({
|
||||
seasonId: 'season-1',
|
||||
seasonId: 'league-5-season-1',
|
||||
published: true,
|
||||
races: expect.any(Array),
|
||||
});
|
||||
|
||||
await agent
|
||||
.post('/leagues/league-5/seasons/season-1/schedule/unpublish')
|
||||
.post('/leagues/league-5/seasons/league-5-season-1/schedule/unpublish')
|
||||
.send({})
|
||||
.expect(200)
|
||||
.expect((res) => {
|
||||
expect(res.body).toEqual({ success: true, published: false });
|
||||
});
|
||||
|
||||
const afterUnpublishRes = await agent.get('/leagues/league-5/schedule?seasonId=season-1').expect(200);
|
||||
const afterUnpublishRes = await agent.get('/leagues/league-5/schedule?seasonId=league-5-season-1').expect(200);
|
||||
expect(afterUnpublishRes.body).toMatchObject({
|
||||
seasonId: 'season-1',
|
||||
seasonId: 'league-5-season-1',
|
||||
published: false,
|
||||
races: expect.any(Array),
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user