import pytest
from dash import Dash, Input, Output, dcc, html


@pytest.mark.DCC782
def test_lipa001_path(dash_dcc):
    app = Dash(__name__)
    app.layout = html.Div(
        [
            dcc.Link("Relative Path", id="link1", href="google.com"),
            dcc.Location(id="url", refresh=False),
            html.Div(id="content"),
        ]
    )

    @app.callback(Output("content", "children"), [Input("url", "pathname")])
    def display_children(children):
        return children

    dash_dcc.start_server(app)

    dash_dcc.wait_for_element("#link1").click()

    dash_dcc.wait_for_text_to_equal("#content", "/google.com")

    assert dash_dcc.get_logs() == []


@pytest.mark.DCC782
def test_lipa002_path(dash_dcc):
    app = Dash(__name__)
    app.layout = html.Div(
        [
            dcc.Link(
                children="Absolute Path",
                id="link1",
                href="https://google.com",
                refresh=True,
            ),
            dcc.Location(id="url", refresh=False),
        ]
    )
    dash_dcc.start_server(app)

    dash_dcc.wait_for_element("#link1").click()

    location = dash_dcc.driver.execute_script(
        """
        return window.location.href
        """
    )

    assert location == "https://www.google.com/"

    assert dash_dcc.get_logs() == []

@@ -395,17 +395,16 @@
 dren%22), 
-%5B
 Input(%22u
@@ -419,17 +419,16 @@
 thname%22)
-%5D
 )%0A    de
@@ -736,32 +736,290 @@
  Dash(__name__)%0A
+%0A    def extras(t):%0A        return f%22%22%22%3C!DOCTYPE html%3E%0A        %3Chtml%3E%3Cbody%3E%0A        %7Bt%5B::-1%5D%7D%0A        %3C/body%3E%3C/html%3E%0A        %22%22%22%0A    app.server.add_url_rule(%0A        %22/extra/%3Cstring:t%3E%22, view_func=extras, endpoint=%22/extra/%3Cstring:t%3E%22, methods=%5B%22GET%22%5D%0A    )%0A%0A
     app.layout =
@@ -1156,27 +1156,44 @@
 ref=
-%22https://google.com
+dash_dcc.server.url + %22/extra/eseehc
 %22,%0A 
@@ -1396,16 +1396,22 @@
 location
+, text
  = dash_
@@ -1464,16 +1464,17 @@
  return 
+%5B
 window.l
@@ -1485,16 +1485,51 @@
 ion.href
+, document.body.textContent.trim()%5D
 %0A       
@@ -1567,32 +1567,72 @@
  == 
-%22https://www.google.com/
+dash_dcc.server.url + %22/extra/eseehc%22%0A    assert text == %22cheese
 %22%0A%0A 

remove google.com from dcc tests