Skip to content

Commit a0f2f5d

Browse files
authored
test(client): e2e imports avoiding /internal (#25349)
apart from explicit test utils and some exceptions. Explicitly allow /alpha, /beta, and /legacy without lint suppression.
1 parent e91b4fe commit a0f2f5d

File tree

14 files changed

+62
-45
lines changed

14 files changed

+62
-45
lines changed

packages/service-clients/end-to-end-tests/azure-client/.eslintrc.cjs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,27 @@
33
* Licensed under the MIT License.
44
*/
55

6+
const importInternalModulesAllowedForTest = [
7+
// Allow import of Fluid Framework external API exports.
8+
"@fluidframework/*/{beta,alpha,legacy}",
9+
"fluid-framework/{beta,alpha,legacy}",
10+
11+
// Allow import of Fluid Framework non-production test-utils APIs.
12+
"@fluidframework/*/test-utils",
13+
14+
// Allow imports from sibling and ancestral sibling directories,
15+
// but not from cousin directories. Parent is allowed but only
16+
// because there isn't a known way to deny it.
17+
"*/index.js",
18+
19+
// Should `telemetry-utils` provide support through `/test-utils` instead of `/internal`?
20+
"@fluidframework/telemetry-utils/internal",
21+
22+
// Should `test-*utils` provide support through `/test-utils` instead of `/internal`?
23+
"@fluidframework/test-utils/internal",
24+
"@fluidframework/test-runtime-utils/internal",
25+
];
26+
627
module.exports = {
728
extends: [require.resolve("@fluidframework/eslint-config-fluid"), "prettier"],
829
rules: {
@@ -28,6 +49,12 @@ module.exports = {
2849
rules: {
2950
// Some deprecated APIs are permissible in tests; use `warn` to keep them visible
3051
"import/no-deprecated": "warn",
52+
"import/no-internal-modules": [
53+
"error",
54+
{
55+
allow: importInternalModulesAllowedForTest,
56+
},
57+
],
3158
},
3259
},
3360
],

packages/service-clients/end-to-end-tests/azure-client/src/test/AzureClientFactory.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,22 @@
55

66
import {
77
AzureClient,
8-
type AzureClientPropsInternal,
98
type AzureLocalConnectionConfig,
109
type AzureRemoteConnectionConfig,
1110
type ITelemetryBaseLogger,
12-
} from "@fluidframework/azure-client/internal";
11+
} from "@fluidframework/azure-client";
12+
// eslint-disable-next-line import/no-internal-modules -- TODO consider a test exposure to avoid /internal
13+
import type { AzureClientPropsInternal } from "@fluidframework/azure-client/internal";
1314
import {
1415
AzureClient as AzureClientLegacy,
1516
type AzureLocalConnectionConfig as AzureLocalConnectionConfigLegacy,
1617
type AzureRemoteConnectionConfig as AzureRemoteConnectionConfigLegacy,
1718
type ITelemetryBaseLogger as ITelemetryBaseLoggerLegacy,
1819
} from "@fluidframework/azure-client-legacy";
19-
import type { IRuntimeFactory } from "@fluidframework/container-definitions/internal";
20+
import type { IRuntimeFactory } from "@fluidframework/container-definitions/legacy";
2021
import type { IConfigProviderBase } from "@fluidframework/core-interfaces";
21-
import { ScopeType } from "@fluidframework/driver-definitions/internal";
22-
import type {
23-
CompatibilityMode,
24-
ContainerSchema,
25-
} from "@fluidframework/fluid-static/internal";
22+
import { ScopeType } from "@fluidframework/driver-definitions/legacy";
23+
import type { CompatibilityMode, ContainerSchema } from "@fluidframework/fluid-static";
2624
import {
2725
type MockLogger,
2826
createChildLogger,

packages/service-clients/end-to-end-tests/azure-client/src/test/AzureTokenFactory.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*/
55

66
import type { ITokenProvider } from "@fluidframework/azure-client";
7-
import type { ScopeType } from "@fluidframework/driver-definitions/internal";
7+
import type { ScopeType } from "@fluidframework/driver-definitions/legacy";
88
import { InsecureTokenProvider } from "@fluidframework/test-runtime-utils/internal";
99

1010
export function createAzureTokenProvider(

packages/service-clients/end-to-end-tests/azure-client/src/test/TestDataObject.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,17 @@
55

66
import type { SignalListener } from "@fluid-experimental/data-objects";
77
import { EventEmitter } from "@fluid-internal/client-utils";
8+
// eslint-disable-next-line import/no-internal-modules -- TODO consider a test exposure to avoid /internal
9+
import { createDataObjectKind } from "@fluidframework/aqueduct/internal";
810
import {
911
DataObject,
1012
DataObjectFactory,
1113
type IDataObjectProps,
12-
createDataObjectKind,
13-
} from "@fluidframework/aqueduct/internal";
14+
} from "@fluidframework/aqueduct/legacy";
1415
import type { IErrorEvent, IFluidHandle } from "@fluidframework/core-interfaces";
15-
import { SharedCounter } from "@fluidframework/counter/internal";
16-
import type { Jsonable } from "@fluidframework/datastore-definitions/internal";
17-
import type { IInboundSignalMessage } from "@fluidframework/runtime-definitions/internal";
16+
import { SharedCounter } from "@fluidframework/counter/legacy";
17+
import type { Jsonable } from "@fluidframework/datastore-definitions/legacy";
18+
import type { IInboundSignalMessage } from "@fluidframework/runtime-definitions/legacy";
1819

1920
class TestDataObjectClass extends DataObject {
2021
public static readonly Name = "@fluid-example/test-data-object";

packages/service-clients/end-to-end-tests/azure-client/src/test/audience.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { AzureClient, AzureContainerServices } from "@fluidframework/azure-
99
import { AttachState } from "@fluidframework/container-definitions";
1010
import { ConnectionState } from "@fluidframework/container-loader";
1111
import type { ContainerSchema, IFluidContainer } from "@fluidframework/fluid-static";
12-
import { SharedMap } from "@fluidframework/map/internal";
12+
import { SharedMap } from "@fluidframework/map/legacy";
1313
import { timeoutPromise } from "@fluidframework/test-utils/internal";
1414
import type { AxiosResponse } from "axios";
1515

packages/service-clients/end-to-end-tests/azure-client/src/test/containerCreate.spec.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,19 @@ import type { ConfigTypes, IConfigProviderBase } from "@fluidframework/core-inte
1313
import {
1414
MessageType,
1515
type ISequencedDocumentMessage,
16-
} from "@fluidframework/driver-definitions/internal";
16+
} from "@fluidframework/driver-definitions/legacy";
17+
// eslint-disable-next-line import/no-internal-modules -- TODO consider a test exposure to avoid /internal
18+
import { isTreeContainerSchema } from "@fluidframework/fluid-static/internal";
1719
import {
1820
type ContainerSchema,
1921
createTreeContainerRuntimeFactory,
20-
isTreeContainerSchema,
2122
type IFluidContainer,
22-
} from "@fluidframework/fluid-static/internal";
23-
import { SharedMap } from "@fluidframework/map/internal";
23+
} from "@fluidframework/fluid-static/legacy";
24+
import { SharedMap } from "@fluidframework/map/legacy";
2425
import { SharedMap as SharedMapLegacy } from "@fluidframework/map-legacy";
2526
import { MockLogger, UsageError } from "@fluidframework/telemetry-utils/internal";
2627
import { timeoutPromise } from "@fluidframework/test-utils/internal";
27-
import { SharedTree } from "@fluidframework/tree/internal";
28+
import { SharedTree } from "@fluidframework/tree/legacy";
2829
import type { AxiosResponse } from "axios";
2930
import type { SinonSandbox } from "sinon";
3031
import { createSandbox } from "sinon";

packages/service-clients/end-to-end-tests/azure-client/src/test/ddsTests.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import type { AzureClient } from "@fluidframework/azure-client";
99
import { ConnectionState } from "@fluidframework/container-loader";
1010
import type { IFluidHandle } from "@fluidframework/core-interfaces";
1111
import type { ContainerSchema, IFluidContainer } from "@fluidframework/fluid-static";
12-
import { type ISharedMap, SharedMap } from "@fluidframework/map/internal";
12+
import { type ISharedMap, SharedMap } from "@fluidframework/map/legacy";
1313
import { timeoutPromise } from "@fluidframework/test-utils/internal";
1414
import type { AxiosResponse } from "axios";
1515

packages/service-clients/end-to-end-tests/azure-client/src/test/multiprocess/childClient.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
type LatestRaw,
2323
type LatestMapRaw,
2424
type StatesWorkspace,
25-
// eslint-disable-next-line import/no-internal-modules
2625
} from "@fluidframework/presence/beta";
2726
import { InsecureTokenProvider } from "@fluidframework/test-runtime-utils/internal";
2827
import { timeoutPromise } from "@fluidframework/test-utils/internal";
@@ -32,15 +31,10 @@ import { createAzureTokenProvider } from "../AzureTokenFactory.js";
3231
import { TestDataObject } from "../TestDataObject.js";
3332
import type { configProvider } from "../utils.js";
3433

35-
import type { MessageFromChild, MessageToChild } from "./messageTypes.js";
34+
import type { MessageFromChild, MessageToChild, UserIdAndName } from "./messageTypes.js";
3635

3736
type MessageFromParent = MessageToChild;
3837
type MessageToParent = Required<MessageFromChild>;
39-
interface UserIdAndName {
40-
id: string;
41-
name: string;
42-
}
43-
4438
const connectTimeoutMs = 10_000;
4539
// Identifier given to child process
4640
const process_id = process.argv[2];

packages/service-clients/end-to-end-tests/azure-client/src/test/multiprocess/messageTypes.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33
* Licensed under the MIT License.
44
*/
55

6-
import type { AzureUser } from "@fluidframework/azure-client/internal";
7-
import type { JsonSerializable } from "@fluidframework/core-interfaces/internal";
86
// eslint-disable-next-line import/no-internal-modules
7+
import type { JsonSerializable } from "@fluidframework/core-interfaces/internal";
98
import type { AttendeeId } from "@fluidframework/presence/beta";
109

10+
export interface UserIdAndName {
11+
id: string;
12+
name: string;
13+
}
14+
1115
/**
1216
* Message types sent from the orchestrator to the child processes
1317
*/
@@ -35,7 +39,7 @@ interface PingCommand {
3539
*/
3640
export interface ConnectCommand {
3741
command: "connect";
38-
user: AzureUser;
42+
user: UserIdAndName;
3943
/**
4044
* The ID of the Fluid container to connect to.
4145
* If not provided, a new Fluid container will be created.

packages/service-clients/end-to-end-tests/azure-client/src/test/multiprocess/orchestratorUtils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
import { fork, type ChildProcess } from "node:child_process";
77

8-
// eslint-disable-next-line import/no-internal-modules
98
import type { AttendeeId } from "@fluidframework/presence/beta";
109
import { timeoutAwait, timeoutPromise } from "@fluidframework/test-utils/internal";
1110

0 commit comments

Comments
 (0)