Skip to content

Commit

Permalink
feat(client): display current course on ship page
Browse files Browse the repository at this point in the history
  • Loading branch information
clemlatz committed May 9, 2024
1 parent 4578698 commit 43e2b73
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/app/models/ship.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export default class ShipModel extends Model {
@attr declare speedInKilometersPerSecond: number;
@attr declare currentPosition: Position;
@attr declare currentLocation: Location;
@attr declare currentCourse: number;
@attr declare destinationPosition: Position;
@attr declare destinationLocation: Location;
@attr declare timeToDestination: number | null;
Expand Down
5 changes: 5 additions & 0 deletions client/app/templates/ships/get.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,11 @@
{{@model.destinationLocation.name}}
</dd>

<dt id="current-course">Current course</dt>
<dd aria-labelledby="current-course">
{{@model.currentCourse}} °
</dd>

<dt id="time-to-destination">Time to destination</dt>
<dd aria-labelledby="time-to-destination">
{{#if @model.timeToDestination}}
Expand Down
2 changes: 2 additions & 0 deletions client/mirage/fixtures/ships.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export default [
speedInKilometersPerSecond: 100,
currentPosition: { x: 3, y: 4 },
currentLocation: { name: 'Moon' },
currentCourse: 0,
destinationPosition: null,
destinationLocation: null,
timeToDestination: null,
Expand All @@ -23,6 +24,7 @@ export default [
speedInKilometersPerSecond: 100,
currentPosition: { x: 1, y: 2 },
currentLocation: { name: 'Earth' },
currentCourse: 84,
destinationPosition: { x: 3, y: 4 },
destinationLocation: { name: 'Moon' },
timeToDestination: 312,
Expand Down
6 changes: 6 additions & 0 deletions client/tests/acceptance/ship-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ module('Acceptance | ship', function (hooks) {
assert
.dom(screen.getByRole('definition', { name: 'Current location' }))
.hasText('3.000 4.000 Moon');
assert
.dom(screen.getByRole('definition', { name: 'Current course' }))
.hasText('0 °');
assert
.dom(screen.getByRole('definition', { name: 'Current destination' }))
.hasText('—');
Expand All @@ -61,6 +64,9 @@ module('Acceptance | ship', function (hooks) {
assert
.dom(screen.getByRole('heading', { name: 'Bebop', level: 2 }))
.exists();
assert
.dom(screen.getByRole('definition', { name: 'Current course' }))
.hasText('84 °');
assert
.dom(screen.getByRole('definition', { name: 'Current destination' }))
.hasText('3.000 4.000 Moon');
Expand Down

0 comments on commit 43e2b73

Please sign in to comment.