You are on page 1of 11

Project Summary

Our project aims to develop a user-friendly platform for testing graph coverages, leveraging
modern technologies such as React.js for the front end, Node.js and Express.js for the back
end, and MongoDB for storing user and graph data. By combining these technologies, we
provide a robust solution for graph testing that offers ease of use and scalability.

Unit Testing

For ensuring the reliability and correctness of our application, we have implemented
comprehensive unit testing using Jest and Babel. These testing frameworks enable us to
thoroughly test both the front-end and back-end components and functions, ensuring that our
application performs as expected under various scenarios.

Front-End Testing

In the front end, we focus our testing efforts on the Forms component, which serves as the
interface for users to input graph data, generate graphs, and save them for future reference.
Our tests cover various functionalities of the Forms component, including:

1. Input Handling: We test the functionality of updating the graph name upon input
change. This ensures that users can accurately label their graphs for easy
identification.
2. Modal Interactions: We test the opening and closing of modal dialogs for entering
edge data and saving graphs. This ensures smooth user interactions and proper
handling of modal states.
3. Graph Generation: We test the generation of graphs based on user input. This
ensures that graphs are accurately generated from the provided edge data, facilitating
further analysis and testing.
4. Test Requirement Display: We test the functionality of displaying test requirements,
such as nodes, edges, and edge pairs. This ensures that users can easily visualize the
requirements for testing coverage.
5. Test Path Generation: We test the generation of test paths, including node coverage
and edge coverage. This ensures that the application accurately identifies and presents
test paths for comprehensive coverage testing.

Back-End Testing

In the back end, we focus on testing the algorithms responsible for node coverage and edge
coverage. Our test cases cover various scenarios and edge cases to ensure the reliability and
accuracy of these algorithms. By thoroughly testing the back-end functionality, we ensure
that our application delivers accurate and actionable insights for graph coverage testing.

Overall, our testing approach ensures that our application meets the highest standards of
quality and reliability, providing users with a dependable platform for testing graph
coverages effectively.
Test Cases: Front End

Login Test: Unit Level testing

Login.test.js file

Purpose: The test verifies the login functionality of the `LoginScreen` component by
simulating a user login process. It ensures that users can log in successfully with valid
credentials and that the `onLogin` prop function is called upon successful login. This test
helps confirm that the login process works as expected, allowing users to authenticate and
access protected resources within the application.

test("should login successfully and call onLogin prop", async () => {


const mockOnLogin = jest.fn();
const axiosMock = jest.mocked(axios);
axiosMock.post.mockResolvedValueOnce({
data: { token: "test-token", message: "Login successful" },
});
render(<LoginScreen onLogin={mockOnLogin} />);
const usernameInput = screen.getByPlaceholderText("Username");
const passwordInput = screen.getByPlaceholderText("Password");
const submitButton = screen.getByRole("button", { name: /Login/i });
fireEvent.change(usernameInput, { target: { value: "testuser" } });
fireEvent.change(passwordInput, { target: { value: "password123" } });
fireEvent.click(submitButton);
await new Promise((resolve) => setTimeout(resolve, 0));

expect(axiosMock.post).toHaveBeenCalledWith(
"http://localhost:5000/auth/login",
{
username: "testuser",
password: "password123",
},
{
headers: {
"Content-Type": "application/json",
},
}
);
expect(mockOnLogin).toHaveBeenCalled();
});
Form.test.js file : Unit level testing

Test 1: Updates Graph Name on Input Change:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Verifies that the graph name updates correctly when the user
changes the input value. This test ensures that the input field for the graph
name functions as expected, allowing users to update the graph name
dynamically.

Test 2: Opens and Closes Input Edges Modal:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Tests the functionality of opening and closing the input edges
modal. It ensures that the modal opens when the corresponding button is
clicked and closes when the cancel button inside the modal is clicked. This test
confirms that the modal interaction behaves as intended.
Test 3: Generates Graph on Button Click:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Validates that clicking the "Generate Graph" button triggers the
generation of the graph. This test ensures that when users click the button, the
updateGraph function is called, indicating that the graph generation process is
initiated.

Test 4: Opens and Closes Save Graph Modal:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Tests the functionality of opening and closing the save graph modal.
It verifies that the modal opens when the "Save Graph" button is clicked and
closes when the cancel button inside the modal is clicked. This test confirms
that the modal interaction for saving the graph functions correctly.
Test 5: Shows Nodes on Button Click:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Validates that clicking the "Show Nodes" button triggers the display
of nodes. It ensures that when users click the button, the showNodes function
is called, indicating that the nodes are shown on the graph as intended.

Test 6: Shows Edges on Button Click:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Verifies that clicking the "Show Edges" button triggers the display
of edges. It ensures that when users click the button, the showEdges function
is called, indicating that the edges are shown on the graph as intended.
Test 7: Shows Edge Pairs on Button Click:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Tests the functionality of showing edge pairs when the
corresponding button is clicked. It ensures that clicking the "Show Edge Pairs"
button triggers the display of edge pairs, as indicated by the showEdgePairs
function being called.

Test 8: Finds Node Coverage Paths on Button Click:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Validates that clicking the "Find Node Paths" button triggers the
computation of node coverage paths. This test ensures that when users click
the button, the nodeCoverage function is called, indicating that node coverage
paths are computed as expected.
Test 9: Finds Edge Coverage Paths on Button Click:

o Unit Level Testing


o File: Forms.test.js
o Purpose: Verifies that clicking the "Find Edge Paths" button triggers the
computation of edge coverage paths. It ensures that when users click the
button, the edgeCoverage function is called, indicating that edge coverage
paths are computed as expected.

Test Cases: Back End

Test 1: Returns Empty Array for Empty Graph:

o Unit Level Testing


o File: nodeCoverage.test.js
o Purpose: Validates that the findNodeCoverage function returns an empty
array when provided with an empty graph. This test ensures that the function
handles empty graph data gracefully, returning no paths when there are no
nodes or links.
Test 2: Returns Correct Paths for Complex Graph:

o Unit Level Testing


o File: nodeCoverage.test.js
o Purpose: Verifies that the findNodeCoverage function returns the correct
paths for a complex graph with multiple nodes and links. This test ensures that
the function accurately computes all possible paths from the initial to the final
node in the graph.

test("returns empty array for empty graph", () => {


const graphData = { nodes: [], links: [] };
const initialNode = "A";
const finalNode = "B";
expect(findNodeCoverage(graphData, initialNode,
finalNode)).toEqual([]);
});
test("returns correct paths for complex graph", () => {
const graphData = {
nodes: [
{ id: "A" },
{ id: "B" },
{ id: "C" },
{ id: "D" },
{ id: "E" },
],
links: [
{ source: { id: "A" }, target: { id: "B" } },
{ source: { id: "A" }, target: { id: "C" } },
{ source: { id: "B" }, target: { id: "D" } },
{ source: { id: "C" }, target: { id: "E" } },
{ source: { id: "D" }, target: { id: "E" } },
],
};
const initialNode = "A";
const finalNode = "E";
const expectedPaths = [["A", "B", "D", "E"], ["A", "C", "E"]];
expect(findNodeCoverage(graphData, initialNode,
finalNode)).toEqual(
expectedPaths
);
});
Test 3: Returns Empty Array for Unreachable Final Node:

o Unit Level Testing


o File: nodeCoverage.test.js
o Purpose: Tests the behavior of the findNodeCoverage function when the
final node is unreachable from the initial node in the graph. It ensures that the
function returns an empty array when the final node cannot be reached from
the initial node.

Test 4: Returns Correct Paths for Bigger Graph:

o Unit Level Testing


o File: nodeCoverage.test.js
o Purpose: Validates that the findNodeCoverage function returns the correct
paths for a larger graph with multiple nodes and links. This test verifies the
accuracy of path computation for more complex graph structures.
Test 5: Returns Single-Node Path for Same Initial and Final Nodes:

o Unit Level Testing


o File: nodeCoverage.test.js
o Purpose: Verifies that the findNodeCoverage function returns a single-node
path when the initial and final nodes are the same. This test ensures that the
function handles this scenario correctly, returning a single path containing the
same node.

Test 6: Returns Empty Array for Non-Existent Initial Node:

o Unit Level Testing


o File: nodeCoverage.test.js
o Purpose: Tests the behavior of the findNodeCoverage function when the
initial node does not exist in the graph. It ensures that the function returns an
empty array when the initial node provided is not present in the graph.
Test 7: Returns Empty Array for Non-Existent Final Node:

o Unit Level Testing


o File: nodeCoverage.test.js
o Purpose: Validates that the findNodeCoverage function returns an empty
array when the final node does not exist in the graph. This test ensures that the
function handles the scenario where the final node is not present in the graph
data.

You might also like