Skip to content

Commit 3e63ae4

Browse files
hl662Copilot
andcommitted
Extract fakeViewState to prevent cross-test-file side effects
TileRequest.test.ts and Tolerance.test.ts imported fakeViewState from TileIO.test.ts. When sharded across Electron processes, requiring either file transitively loaded TileIO.test.ts and registered all its describe blocks in the wrong shard. Both shards then ran mirukuru TileTree tests concurrently against the same iModel, causing race-condition failures on Windows CI. Fix: move fakeViewState to a dedicated FakeViewState.ts utility file so importing it no longer triggers TileIO.test.ts side effects. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 5c14908 commit 3e63ae4

4 files changed

Lines changed: 28 additions & 13 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3+
* See LICENSE.md in the project root for license terms and full copyright notice.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
// Extracted from TileIO.test.ts so other test files can import fakeViewState
7+
// without transitively loading TileIO.test.ts's describe blocks.
8+
9+
import { Id64String } from "@itwin/core-bentley";
10+
import { RenderMode, ViewFlags } from "@itwin/core-common";
11+
import { IModelConnection, ViewState } from "@itwin/core-frontend";
12+
13+
export function fakeViewState(iModel: IModelConnection, options?: { visibleEdges?: boolean, renderMode?: RenderMode, is2d?: boolean, animationId?: Id64String }): ViewState {
14+
return {
15+
iModel,
16+
is3d: () => true !== options?.is2d,
17+
viewFlags: new ViewFlags({
18+
renderMode: options?.renderMode ?? RenderMode.SmoothShade,
19+
visibleEdges: options?.visibleEdges ?? false,
20+
}),
21+
displayStyle: {},
22+
} as unknown as ViewState;
23+
}

full-stack-tests/core/src/frontend/standalone/tile/TileIO.test.ts

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,17 +66,9 @@ export class FakeREProps implements RelatedElementProps {
6666
public constructor() { this.id = Id64.invalid; }
6767
}
6868

69-
export function fakeViewState(iModel: IModelConnection, options?: { visibleEdges?: boolean, renderMode?: RenderMode, is2d?: boolean, animationId?: Id64String }): ViewState {
70-
return {
71-
iModel,
72-
is3d: () => true !== options?.is2d,
73-
viewFlags: new ViewFlags({
74-
renderMode: options?.renderMode ?? RenderMode.SmoothShade,
75-
visibleEdges: options?.visibleEdges ?? false,
76-
}),
77-
displayStyle: {},
78-
} as unknown as ViewState;
79-
}
69+
import { fakeViewState } from "./FakeViewState";
70+
// Re-export for any remaining consumers — other test files should import from "./FakeViewState" directly.
71+
export { fakeViewState } from "./FakeViewState";
8072

8173
function delta(a: number, b: number): number {
8274
return Math.abs(a - b);

full-stack-tests/core/src/frontend/standalone/tile/TileRequest.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {
1212
import type { FrontendStorage, TransferConfig } from "@itwin/object-storage-core/lib/frontend";
1313
import { TestUtility } from "../../TestUtility";
1414
import { TILE_DATA_2_0 } from "./data/TileIO.data.2.0";
15-
import { fakeViewState } from "./TileIO.test";
15+
import { fakeViewState } from "./FakeViewState";
1616
import { TestSnapshotConnection } from "../../TestSnapshotConnection";
1717
import { IModelTile, IModelTileContent, IModelTileTree, TileStorage } from "@itwin/core-frontend/lib/cjs/tile/internal";
1818

full-stack-tests/core/src/frontend/standalone/tile/Tolerance.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
} from "@itwin/core-frontend";
1515
import { Range3d, Range3dProps } from "@itwin/core-geometry";
1616
import { TestUtility } from "../../TestUtility";
17-
import { fakeViewState } from "./TileIO.test";
17+
import { fakeViewState } from "./FakeViewState";
1818
import { TestSnapshotConnection } from "../../TestSnapshotConnection";
1919
import { IModelTile, IModelTileTree } from "@itwin/core-frontend/lib/cjs/tile/internal";
2020

0 commit comments

Comments
 (0)