Test that a body page opens the next body on its Sun's side and turns an exoplanet for show
Two behaviours of the body page had no test. Showing a body resets the remembered side of the equator (sunSide = 0), so the next body opens on its own Sun's side wherever the reader left the camera; the only test that switched bodies went from Saturn's June Sun (south) to Earth's (north), which moves the camera with or without the reset. And the page turns an exoplanet 0.08 radians a second for show, which no test opened. - 'opens the next body shown on its own Sun's side, wherever the reader left the camera: Earth after Saturn in December': Saturn on 2032-12-01, the camera taken north, then Earth, whose December Sun is south too. Guarded mutant, the reset replaced by void 0: this test fails alone, "expected 0.5999999999999999 to be less than 0". - 'turns an exoplanet slowly for show, clock or no clock': the fake loader now carries one exoplanet round the Sun's record; one second with the clock standing turns it 0.08 radians. Guarded mutant, the turn replaced by void deltaSeconds: this test fails alone. The template comment said no one has measured an exoplanet's day. The app ships two whose spin has been: 2M1207 b turns in 10.7 +1.2/-0.6 hours (Zhou et al. 2016, ApJ 818, 176) and beta Pic b's lines are broadened by 25 +/- 3 km/s (Snellen et al. 2014, Nature 509, 63). It now says the catalogue does not carry the day, which is what ExoplanetRecord holds. Unit suite 869 passed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -46,6 +46,8 @@ const MERCURY: BodyRecord = {
|
||||
rotationalElements: {poleRaDeg: [281.0103, -0.0328, 0], poleDecDeg: [61.4155, -0.0049, 0], primeMeridianDeg: [329.5988, 6.1385108, 0]}
|
||||
};
|
||||
const BODIES = [EARTH, SATURN, ERIS, HYPERION, MERCURY];
|
||||
// An exoplanet round the Sun's record, which is all the page needs of its host.
|
||||
const EXOPLANET: ExoplanetRecord = { id: 'x b', hostStarId: 0, hostStarName: 'Sol', name: 'X b', orbit: { semiMajorAxisAu: 0.05 } };
|
||||
|
||||
/** Stands in for the WebGPU engine: a scene, a camera, and the tick hook, driven by hand. */
|
||||
class FakeEngineService {
|
||||
@@ -82,7 +84,7 @@ class FakeDataLoaderService {
|
||||
return Promise.resolve(BODIES);
|
||||
}
|
||||
loadExoplanets(): Promise<ExoplanetRecord[]> {
|
||||
return Promise.resolve([]);
|
||||
return Promise.resolve([EXOPLANET]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -188,6 +190,14 @@ describe('BodyDetailSceneComponent', () => {
|
||||
expect(new THREE.Vector3(0, 1, 0).applyQuaternion(page.planet.quaternion).y).toBeCloseTo(1, 12);
|
||||
});
|
||||
|
||||
it('turns an exoplanet slowly for show, clock or no clock: the catalogue carries no day for it', async () => {
|
||||
await open('x b');
|
||||
const start = page.planet.rotation.y;
|
||||
// The clock stands; a second of the page's own time is 0.08 radians.
|
||||
engine.tick(1);
|
||||
expect(page.planet.rotation.y - start).toBeCloseTo(0.08, 12);
|
||||
});
|
||||
|
||||
it('says on its dock the date the body is drawn for, and nothing at the present, and offers the clock', async () => {
|
||||
await open('saturn', '2032-06-01T12:00Z', true);
|
||||
fixture.detectChanges();
|
||||
@@ -230,6 +240,23 @@ describe('BodyDetailSceneComponent', () => {
|
||||
expect(camera.getWorldDirection(new THREE.Vector3()).angleTo(toSaturn)).toBeLessThan(1e-9);
|
||||
});
|
||||
|
||||
it('opens the next body shown on its own Sun’s side, wherever the reader left the camera: Earth after Saturn in December', async () => {
|
||||
await open('saturn', '2032-12-01T12:00Z');
|
||||
const camera = engine.getCamera();
|
||||
expect(camera.position.y).toBeLessThan(0);
|
||||
// Taken north by the reader, over Saturn's unlit ring face.
|
||||
camera.position.y = 0.6;
|
||||
engine.tick(0.016);
|
||||
expect(camera.position.y).toBeGreaterThan(0);
|
||||
|
||||
route.next(convertToParamMap({ id: 'earth' }));
|
||||
await flushAsync();
|
||||
engine.tick(0.016);
|
||||
// December: Earth's Sun is south, as Saturn's was, so only the side chosen afresh moves the camera.
|
||||
expect(page.sunLight.position.y).toBeLessThan(0);
|
||||
expect(camera.position.y).toBeLessThan(0);
|
||||
});
|
||||
|
||||
it('leaves the camera on its side while the Sun only grazes the equator: Mercury through two crossings', async () => {
|
||||
// The Sun is south of Mercury's equator on 2026-10-20, north from about 1 November, and south
|
||||
// again from about 6 December, never more than 0.034 degrees either side.
|
||||
|
||||
@@ -75,7 +75,8 @@ const SUN_SIDE_MIN_SINE = Math.sin((3 * Math.PI) / 180);
|
||||
<!-- Search, what has been kept and the clock: there is no scene readout here, the info
|
||||
panel is the reading, and the panel's own control is what keeps this body. A solar-system
|
||||
body is drawn at the clock's date and turns at its rate, so both are shown and can be set
|
||||
here; an exoplanet, whose day no one has measured, turns for show whatever the clock says. -->
|
||||
here; an exoplanet, whose day the catalogue does not carry, turns for show whatever the
|
||||
clock says. -->
|
||||
<app-hud-dock [date]="date()" [clock]="true" (bookmarkChosen)="goToBookmark($event)" />
|
||||
</div>
|
||||
`
|
||||
|
||||
Reference in New Issue
Block a user