Sky-only tier label follows the overlay gate; tests pin the door's debug forwarding
All checks were successful
Build pull request / Build pull request (pull_request) Successful in 3m42s
All checks were successful
Build pull request / Build pull request (pull_request) Successful in 3m42s
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
814fa4b3ab
commit
48d6d171da
2 changed files with 41 additions and 2 deletions
|
|
@ -168,6 +168,42 @@ describe('createTerrainSkyScene', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('the sky-only tier label', () => {
|
||||
const labels = (parentAppend: ReturnType<typeof vi.fn>) =>
|
||||
parentAppend.mock.calls.filter(([e]) => e?.textContent === 'terrain · sky-only');
|
||||
|
||||
it('shows for ?tierlabel=1 only where the overlays are allowed', () => {
|
||||
search = '?tierlabel=1';
|
||||
const off = canvasWith();
|
||||
createTerrainSkyScene({ canvas: off.canvas, tier: 'low' })!.dispose();
|
||||
expect(labels(off.parentAppend)).toHaveLength(0);
|
||||
const on = canvasWith();
|
||||
createTerrainSkyScene({ canvas: on.canvas, tier: 'low', debug: true })!.dispose();
|
||||
expect(labels(on.parentAppend)).toHaveLength(1);
|
||||
});
|
||||
|
||||
it('the door allows it from the config flag, and not from a plain production config', async () => {
|
||||
vi.stubEnv('DEV', false);
|
||||
vi.stubEnv('VITE_PREVIEW_DEMO', '');
|
||||
search = '?tierlabel=1';
|
||||
const plain = canvasWith();
|
||||
(
|
||||
await startBackgroundScene({ tier: 'low', style: 'terrain' }, {}, { canvas: plain.canvas })
|
||||
)?.dispose();
|
||||
expect(labels(plain.parentAppend)).toHaveLength(0);
|
||||
const flagged = canvasWith();
|
||||
(
|
||||
await startBackgroundScene(
|
||||
{ tier: 'low', style: 'terrain', debugOverlays: true },
|
||||
{},
|
||||
{ canvas: flagged.canvas }
|
||||
)
|
||||
)?.dispose();
|
||||
expect(labels(flagged.parentAppend)).toHaveLength(1);
|
||||
vi.unstubAllEnvs();
|
||||
});
|
||||
});
|
||||
|
||||
describe('startBackgroundScene, terrain style', () => {
|
||||
it('without WebGL2 mounts the sky on the same canvas instead of returning null', async () => {
|
||||
const { canvas, painted } = canvasWith({ gl: null });
|
||||
|
|
|
|||
|
|
@ -9,7 +9,10 @@ import { CAMERA, view } from './terrainWorld';
|
|||
export const SKY_WIDTH = 96;
|
||||
|
||||
/** The sky of the terrain scene without WebGL2: the camera's first frame of `skyColour`, once, on a 2D canvas, with the star layer on top. */
|
||||
export type TerrainSkyOptions = Pick<TerrainOptions, 'canvas' | 'tier' | 'sky' | 'sun' | 'band'>;
|
||||
export type TerrainSkyOptions = Pick<
|
||||
TerrainOptions,
|
||||
'canvas' | 'tier' | 'sky' | 'sun' | 'band' | 'debug'
|
||||
>;
|
||||
|
||||
/**
|
||||
* Same contract as `createTerrainScene`. Paints the terrain scene's sky (the CPU twin of its sky shader, from the
|
||||
|
|
@ -69,7 +72,7 @@ export function createTerrainSkyScene(opts: TerrainSkyOptions): Scene | null {
|
|||
};
|
||||
window.addEventListener('resize', onResize);
|
||||
paint();
|
||||
const removeLabel = showTierLabel(canvas, 'sky-only');
|
||||
const removeLabel = showTierLabel(canvas, 'sky-only', opts.debug === true);
|
||||
|
||||
return {
|
||||
login() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue