test: high coverage for all UI tests

This commit is contained in:
JobvAlewijk
2025-12-07 15:32:20 +00:00
committed by Gerla, J. (Justin)
parent c639a37dfc
commit 086caea737
18 changed files with 1641 additions and 83 deletions

View File

@@ -68,7 +68,7 @@ export const NodeConnects = {
phase: PhaseConnects,
norm: NormConnects,
goal: GoalConnects,
trigger: TriggerConnects,
trigger: TriggerConnects,
}
/**
@@ -79,6 +79,7 @@ export const NodeConnects = {
export const NodeDeletes = {
start: () => false,
end: () => false,
test: () => false, // Used for coverage of universal/ undefined nodes
}
/**
@@ -91,4 +92,5 @@ export const NodesInPhase = {
start: () => false,
end: () => false,
phase: () => false,
test: () => false, // Used for coverage of universal/ undefined nodes
}

View File

@@ -47,7 +47,11 @@ function DraggableNode({ className, children, nodeType, onDrop }: DraggableNodeP
});
return (
<div className={className} ref={draggableRef}>
<div className={className}
ref={draggableRef}
id={`draggable-${nodeType}`}
data-testid={`draggable-${nodeType}`}
>
{children}
</div>
);
@@ -149,6 +153,7 @@ export function DndToolbar() {
{/* Maps over all the nodes that are droppable, and puts them in the panel */}
{droppableNodes.map(({type, data}) => (
<DraggableNode
key={type}
className={styles[`draggable-node-${type}`]} // Our current style signature for nodes
nodeType={type}
onDrop={handleNodeDrop}

View File

@@ -40,14 +40,11 @@ export default function EndNode(props: NodeProps<EndNode>) {
/**
* Functionality for reducing this node into its more compact json program
* @param node the node to reduce
* @param nodes all nodes present
* @param _nodes all nodes present
* @returns Dictionary, {id: node.id}
*/
export function EndReduce(node: Node, nodes: Node[]) {
export function EndReduce(node: Node, _nodes: Node[]) {
// Replace this for nodes functionality
if (nodes.length <= -1) {
console.warn("Impossible nodes length in EndReduce")
}
return {
id: node.id
}
@@ -55,13 +52,9 @@ export function EndReduce(node: Node, nodes: Node[]) {
/**
* Any connection functionality that should get called when a connection is made to this node type (end)
* @param thisNode the node of which the functionality gets called
* @param otherNode the other node which has connected
* @param isThisSource whether this node is the one that is the source of the connection
* @param _thisNode the node of which the functionality gets called
* @param _otherNode the other node which has connected
* @param _isThisSource whether this node is the one that is the source of the connection
*/
export function EndConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
// Replace this for connection logic
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
console.warn("Impossible node connection called in EndConnects")
}
export function EndConnects(_thisNode: Node, _otherNode: Node, _isThisSource: boolean) {
}

View File

@@ -76,13 +76,9 @@ export default function GoalNode({id, data}: NodeProps<GoalNode>) {
/**
* Reduces each Goal, including its children down into its relevant data.
* @param node: The Node Properties of this node.
* @param nodes: all the nodes in the graph
* @param _nodes: all the nodes in the graph
*/
export function GoalReduce(node: Node, nodes: Node[]) {
// Replace this for nodes functionality
if (nodes.length <= -1) {
console.warn("Impossible nodes length in GoalReduce")
}
export function GoalReduce(node: Node, _nodes: Node[]) {
const data = node.data as GoalNodeData;
return {
id: node.id,
@@ -94,13 +90,10 @@ export function GoalReduce(node: Node, nodes: Node[]) {
/**
* This function is called whenever a connection is made with this node type (Goal)
* @param thisNode the node of this node type which function is called
* @param otherNode the other node which was part of the connection
* @param isThisSource whether this instance of the node was the source in the connection, true = yes.
* @param _thisNode the node of this node type which function is called
* @param _otherNode the other node which was part of the connection
* @param _isThisSource whether this instance of the node was the source in the connection, true = yes.
*/
export function GoalConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
export function GoalConnects(_thisNode: Node, _otherNode: Node, _isThisSource: boolean) {
// Replace this for connection logic
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
console.warn("Impossible node connection called in EndConnects")
}
}

View File

@@ -61,13 +61,9 @@ export default function NormNode(props: NodeProps<NormNode>) {
/**
* Reduces each Norm, including its children down into its relevant data.
* @param node: The Node Properties of this node.
* @param nodes: all the nodes in the graph
* @param _nodes: all the nodes in the graph
*/
export function NormReduce(node: Node, nodes: Node[]) {
// Replace this for nodes functionality
if (nodes.length <= -1) {
console.warn("Impossible nodes length in NormReduce")
}
export function NormReduce(node: Node, _nodes: Node[]) {
const data = node.data as NormNodeData;
return {
id: node.id,
@@ -78,13 +74,9 @@ export function NormReduce(node: Node, nodes: Node[]) {
/**
* This function is called whenever a connection is made with this node type (Norm)
* @param thisNode the node of this node type which function is called
* @param otherNode the other node which was part of the connection
* @param isThisSource whether this instance of the node was the source in the connection, true = yes.
* @param _thisNode the node of this node type which function is called
* @param _otherNode the other node which was part of the connection
* @param _isThisSource whether this instance of the node was the source in the connection, true = yes.
*/
export function NormConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
// Replace this for connection logic
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
console.warn("Impossible node connection called in EndConnects")
}
export function NormConnects(_thisNode: Node, _otherNode: Node, _isThisSource: boolean) {
}

View File

@@ -78,8 +78,10 @@ export function PhaseReduce(node: Node, nodes: Node[]) {
.filter(([t]) => !nodesNotInPhase.includes(t))
.map(([t]) => t);
// children nodes
const childrenNodes = nodes.filter((node) => data.children.includes(node.id));
// children nodes - make sure to check for empty arrays
let childrenNodes: Node[] = [];
if (data.children)
childrenNodes = nodes.filter((node) => data.children.includes(node.id));
// Build the result object
const result: Record<string, unknown> = {

View File

@@ -40,14 +40,11 @@ export default function StartNode(props: NodeProps<StartNode>) {
/**
* The reduce function for this node type.
* @param node this node
* @param nodes all the nodes in the graph
* @param _nodes all the nodes in the graph
* @returns a reduced structure of this node
*/
export function StartReduce(node: Node, nodes: Node[]) {
export function StartReduce(node: Node, _nodes: Node[]) {
// Replace this for nodes functionality
if (nodes.length <= -1) {
console.warn("Impossible nodes length in StartReduce")
}
return {
id: node.id
}
@@ -55,13 +52,9 @@ export function StartReduce(node: Node, nodes: Node[]) {
/**
* This function is called whenever a connection is made with this node type (start)
* @param thisNode the node of this node type which function is called
* @param otherNode the other node which was part of the connection
* @param isThisSource whether this instance of the node was the source in the connection, true = yes.
* @param _thisNode the node of this node type which function is called
* @param _otherNode the other node which was part of the connection
* @param _isThisSource whether this instance of the node was the source in the connection, true = yes.
*/
export function StartConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
// Replace this for connection logic
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
console.warn("Impossible node connection called in EndConnects")
}
export function StartConnects(_thisNode: Node, _otherNode: Node, _isThisSource: boolean) {
}

View File

@@ -80,14 +80,10 @@ export default function TriggerNode(props: NodeProps<TriggerNode>) {
/**
* Reduces each Trigger, including its children down into its core data.
* @param node - The Trigger node to reduce.
* @param nodes - The list of all nodes in the current flow graph.
* @param _nodes - The list of all nodes in the current flow graph.
* @returns A simplified object containing the node label and its list of triggers.
*/
export function TriggerReduce(node: Node, nodes: Node[]) {
// Replace this for nodes functionality
if (nodes.length <= -1) {
console.warn("Impossible nodes length in TriggerReduce")
}
export function TriggerReduce(node: Node, _nodes: Node[]) {
const data = node.data;
switch (data.triggerType) {
case "keywords":
@@ -106,17 +102,13 @@ export function TriggerReduce(node: Node, nodes: Node[]) {
}
/**
* Handles logic that occurs when a connection is made involving a Trigger node.
*
* @param thisNode - The current Trigger node being connected.
* @param otherNode - The other node involved in the connection.
* @param isThisSource - Whether this node was the source of the connection.
* This function is called whenever a connection is made with this node type (trigger)
* @param _thisNode the node of this node type which function is called
* @param _otherNode the other node which was part of the connection
* @param _isThisSource whether this instance of the node was the source in the connection, true = yes.
*/
export function TriggerConnects(thisNode: Node, otherNode: Node, isThisSource: boolean) {
// Replace this for connection logic
if (thisNode == undefined && otherNode == undefined && isThisSource == false) {
console.warn("Impossible node connection called in EndConnects")
}
export function TriggerConnects(_thisNode: Node, _otherNode: Node, _isThisSource: boolean) {
}
// Definitions for the possible triggers, being keywords and emotions