Run format

This commit is contained in:
Stedoss
2026-07-28 03:36:54 +01:00
parent 7f37617c18
commit 7ccac068eb
7 changed files with 47 additions and 39 deletions
@@ -11,7 +11,8 @@ public class MissionControlContext(DbContextOptions<MissionControlContext> optio
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<Mission>()
modelBuilder
.Entity<Mission>()
.HasMany(mission => mission.MissionLaunches)
.WithOne(missionLaunch => missionLaunch.Mission)
.HasForeignKey(missionLaunch => missionLaunch.MissionId)
@@ -25,6 +25,8 @@ public record MissionResponse
Description = mission.Description,
Status = mission.Status,
CreatedAt = mission.CreatedAt,
MissionLaunches = mission.MissionLaunches.Select(MissionLaunchResponse.FromDomain).ToList(),
MissionLaunches = mission
.MissionLaunches.Select(MissionLaunchResponse.FromDomain)
.ToList(),
};
}
@@ -14,8 +14,8 @@ public class ListMissions(MissionControlContext dbContext)
public override async Task HandleAsync(CancellationToken ct)
{
var missions = await dbContext.Missions
.AsNoTracking()
var missions = await dbContext
.Missions.AsNoTracking()
.Include(m => m.MissionLaunches.OrderByDescending(l => l.ScheduledFor))
.OrderByDescending(m => m.CreatedAt)
.ToListAsync(ct);
@@ -16,7 +16,10 @@ public class CreateMissionLaunch(MissionControlContext dbContext)
public override async Task HandleAsync(CreateMissionLaunchRequest req, CancellationToken ct)
{
var missionExists = await dbContext.Missions.AnyAsync(mission => mission.Id == req.MissionId, ct);
var missionExists = await dbContext.Missions.AnyAsync(
mission => mission.Id == req.MissionId,
ct
);
if (!missionExists)
{
await Send.NotFoundAsync(ct);
@@ -1,30 +1,32 @@
import { MantineProvider } from '@mantine/core';
import { render, screen } from '@testing-library/react';
import { describe, expect, it } from 'vitest';
import type { MissionLaunch } from '../../api/missionLaunches';
import type { Mission } from '../../api/missions';
import { MissionsTable } from './MissionsTable';
import type { MissionLaunch } from '../../api/missionLaunches';
function missionLaunches(): MissionLaunch[] {
return [{
id: 'launch id',
scheduledFor: '2026-07-07T13:56:00+00:00',
status: 'Pending',
createdAt: '2026-07-07T13:56:00+00:00',
}];
return [
{
id: 'launch id',
scheduledFor: '2026-07-07T13:56:00+00:00',
status: 'Pending',
createdAt: '2026-07-07T13:56:00+00:00',
},
];
}
function getMockMissions(withLaunches = false): Mission[] {
return [
{
id: 'a mission id',
name: 'mission name is here!',
description: null,
status: 'Planned',
createdAt: '',
missionLaunches: withLaunches ? missionLaunches() : [],
},
];
{
id: 'a mission id',
name: 'mission name is here!',
description: null,
status: 'Planned',
createdAt: '',
missionLaunches: withLaunches ? missionLaunches() : [],
},
];
}
describe('MissionsTable', () => {
@@ -60,9 +62,7 @@ describe('MissionsTable', () => {
screen.getAllByTestId('row-expand')[0].click();
expect(
screen.queryByText(
'No launches have been created for this mission yet!',
),
screen.queryByText('No launches have been created for this mission yet!'),
).toBeInTheDocument();
});
@@ -76,9 +76,7 @@ describe('MissionsTable', () => {
screen.getAllByTestId('row-expand')[0].click();
expect(
screen.queryByText(
'No launches have been created for this mission yet!',
),
screen.queryByText('No launches have been created for this mission yet!'),
).toBeNull();
});
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { toReadableDateTime } from "./dateUtils";
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import { toReadableDateTime } from './dateUtils';
beforeEach(() => {
vi.stubEnv('TZ', 'UTC');
@@ -14,13 +14,13 @@ describe('dateUtils', () => {
it('returns invalid date when datetime passed is in incorrect format', () => {
const date = toReadableDateTime('invalid');
expect(date).toBe("Invalid Date");
expect(date).toBe('Invalid Date');
});
it ('returns readable date when datetime passed is in valid format', () => {
it('returns readable date when datetime passed is in valid format', () => {
const date = toReadableDateTime('2026-07-27T23:27:22.1976394+00:00');
expect(date).toBe('27/07/2026, 23:27:22');
});
});
});
});