mirror of
https://github.com/morluto/rea.git
synced 2026-12-06 23:09:34 +00:00
test(js-app): share unavailable renderer mapping assertions (#17247)
This commit is contained in:
1 parent
8e2c638f39
commit
faf5df18c3
1 file changed
+28
-66
+28
-66
@@ -94,6 +94,31 @@ it("does not let a known-absent optional import erase another application's page
|
||||
).toHaveLength(1);
|
||||
});
|
||||
|
||||
const expectUnavailableRendererMapping = (
|
||||
graph: JavaScriptApplicationGraph,
|
||||
): void => {
|
||||
const roles = graph.nodes.filter(({ kind }) => kind === "electron-renderer");
|
||||
expect(roles).toHaveLength(1);
|
||||
const role = roles[0];
|
||||
if (role === undefined) throw new Error("Missing renderer");
|
||||
expect(role.observations).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
properties: expect.objectContaining({
|
||||
resolved_path: null,
|
||||
resolution_status: "unavailable",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
graph.edges.filter(
|
||||
({ source_node_id, relation }) =>
|
||||
source_node_id === role.node_id && relation === "maps_to",
|
||||
),
|
||||
).toEqual([]);
|
||||
};
|
||||
|
||||
const moduleFactRoles = (graph: JavaScriptApplicationGraph): string[] =>
|
||||
graph.nodes.flatMap(({ observations }) =>
|
||||
observations.flatMap(({ properties }) => {
|
||||
@@ -418,28 +443,7 @@ it.each(["unselected", "unavailable"] as const)(
|
||||
partial,
|
||||
(await analyzeArtifactFiles(partial)).analysis,
|
||||
);
|
||||
const roles = graph.nodes.filter(
|
||||
({ kind }) => kind === "electron-renderer",
|
||||
);
|
||||
expect(roles).toHaveLength(1);
|
||||
const role = roles[0];
|
||||
if (role === undefined) throw new Error("Missing renderer");
|
||||
expect(role.observations).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
properties: expect.objectContaining({
|
||||
resolved_path: null,
|
||||
resolution_status: "unavailable",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
graph.edges.filter(
|
||||
({ source_node_id, relation }) =>
|
||||
source_node_id === role.node_id && relation === "maps_to",
|
||||
),
|
||||
).toEqual([]);
|
||||
expectUnavailableRendererMapping(graph);
|
||||
} finally {
|
||||
await reader.close();
|
||||
}
|
||||
@@ -485,28 +489,7 @@ it("keeps imported loadFile ownership unknown across an application projection o
|
||||
: file,
|
||||
),
|
||||
});
|
||||
const roles = graph.nodes.filter(
|
||||
({ kind }) => kind === "electron-renderer",
|
||||
);
|
||||
expect(roles).toHaveLength(1);
|
||||
const role = roles[0];
|
||||
if (role === undefined) throw new Error("Missing renderer");
|
||||
expect(role.observations).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
properties: expect.objectContaining({
|
||||
resolved_path: null,
|
||||
resolution_status: "unavailable",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
graph.edges.filter(
|
||||
({ source_node_id, relation }) =>
|
||||
source_node_id === role.node_id && relation === "maps_to",
|
||||
),
|
||||
).toEqual([]);
|
||||
expectUnavailableRendererMapping(graph);
|
||||
} finally {
|
||||
await reader.close();
|
||||
}
|
||||
@@ -964,28 +947,7 @@ it("keeps a loadFile owner unknown when a sibling manifest is unavailable in the
|
||||
partial,
|
||||
(await analyzeArtifactFiles(partial)).analysis,
|
||||
);
|
||||
const roles = graph.nodes.filter(
|
||||
({ kind }) => kind === "electron-renderer",
|
||||
);
|
||||
expect(roles).toHaveLength(1);
|
||||
const role = roles[0];
|
||||
if (role === undefined) throw new Error("Missing renderer");
|
||||
expect(role.observations).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining({
|
||||
properties: expect.objectContaining({
|
||||
resolved_path: null,
|
||||
resolution_status: "unavailable",
|
||||
}),
|
||||
}),
|
||||
]),
|
||||
);
|
||||
expect(
|
||||
graph.edges.filter(
|
||||
({ source_node_id, relation }) =>
|
||||
source_node_id === role.node_id && relation === "maps_to",
|
||||
),
|
||||
).toEqual([]);
|
||||
expectUnavailableRendererMapping(graph);
|
||||
} finally {
|
||||
await reader.close();
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user