import static org.junit.jupiter.api.Assertions.*;

import org.junit.Test;

/**
 * FrontendTests
 *
 * These tests check that Frontend makes right HTML output and interacts correct with the placeholder backend and graph.
 */
public class TeamTests {

    /**
     * roleTest1:
     * Tests that the shortest path prompt HTML is generated correctly
     *  checks that the HTML contains the required input fields & button
     */
    @Test
    public void roleTest1() {
        BackendInterface backend = new Backend_Placeholder(new Graph_Placeholder());
        Frontend fe = new Frontend(backend);

        String html = fe.generateShortestPathPromptHTML();

        assertTrue(html.contains("id=\"start\""));
        assertTrue(html.contains("id=\"end\""));
        assertTrue(html.contains("Find Shortest Path"));
    }

    /**
     * roleTest2:
     * Tests the shortest path response HTML
     * Checks that it returns as an ordered list and is correct
     */
    @Test
    public void roleTest2() {
        BackendInterface backend = new Backend_Placeholder(new Graph_Placeholder());
        Frontend fe = new Frontend(backend);

        String html = fe.generateShortestPathResponseHTML(
                "Union South",
                "Weeks Hall for Geological Sciences"
        );

        // Should contain an ordered list of locations
        assertTrue(html.contains("<ol>"));
        assertTrue(html.contains("<li>Union South</li>"));
        assertTrue(html.contains("<li>Computer Sciences and Statistics</li>"));
        assertTrue(html.contains("<li>Weeks Hall for Geological Sciences</li>"));
    }

    /**
     * roleTest3:
     * Tests both the ten closest destinations prompt & response HTML
     * Checks that it has an unordered list that has all known location
     */
    @Test
    public void roleTest3() {
        BackendInterface backend = new Backend_Placeholder(new Graph_Placeholder());
        Frontend fe = new Frontend(backend);

        // Test prompt HTML
        String prompt = fe.generateTenClosestDestinationsPromptHTML();
        assertTrue(prompt.contains("id=\"from\""));
        assertTrue(prompt.contains("Ten Closest Destinations"));

        // Test response HTML
        String html = fe.generateTenClosestDestinationsResponseHTML("Union South");

        assertTrue(html.contains("<ul>"));
        assertTrue(html.contains("<li>Union South</li>"));
        assertTrue(html.contains("<li>Computer Sciences and Statistics</li>"));
    }
}
