module CoreTests.Grid_SubPlotTitles

open Expecto
open Plotly.NET
open Plotly.NET.LayoutObjects
open Plotly.NET.TraceObjects

open TestUtils
open TestUtils.HtmlCodegen
open Grid_SubPlotTitles_TestCharts

module ``Add logic for positioning subplot titles in LayoutGrid #388`` = 

    [<Tests>]
    let ``Add subplot titles`` =
        testList "FeatureAddition.Add subplot titles in LayoutGrid" [
            test "cartesian 2x2 grid data" {
                ``Add logic for positioning subplot titles in LayoutGrid #388``.``cartesian 2x2 grid with subplot titles``
                |> JsonGen.tracesJsonIs """[{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x2","yaxis":"y2"},{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x3","yaxis":"y3"},{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x4","yaxis":"y4"}]""" 
            }
            test "cartesian 2x2 grid  layout" {
                """var layout = {"xaxis":{},"yaxis":{},"xaxis2":{},"yaxis2":{},"xaxis3":{},"yaxis3":{},"xaxis4":{},"yaxis4":{},"annotations":[{"x":0.22222222222222224,"y":1.0,"showarrow":false,"text":"1,1","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.7777777777777778,"y":1.0,"showarrow":false,"text":"1,2","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.22222222222222224,"y":0.4117647058823529,"showarrow":false,"text":"2,1","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.7777777777777778,"y":0.4117647058823529,"showarrow":false,"text":"2,2","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"}],"grid":{"rows":2,"columns":2,"roworder":"top to bottom","pattern":"independent"}};"""
                |> chartGeneratedContains ``Add logic for positioning subplot titles in LayoutGrid #388``.``cartesian 2x2 grid with subplot titles``
            }
            test "cartesian singlestack data" {
                """var data = [{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x2","yaxis":"y2"},{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x3","yaxis":"y3"},{"type":"scatter","mode":"markers","x":[1],"y":[2],"marker":{},"line":{},"xaxis":"x4","yaxis":"y4"}];"""
                |> chartGeneratedContains ``Add logic for positioning subplot titles in LayoutGrid #388``.``cartesian single stack with subplot titles``
            }
            test "cartesian singlestack layout" {
                """var layout = {"xaxis":{},"yaxis":{},"xaxis2":{},"yaxis2":{},"xaxis3":{},"yaxis3":{},"xaxis4":{},"yaxis4":{},"annotations":[{"x":0.5,"y":0.9999999999999999,"showarrow":false,"text":"1","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.7297297297297296,"showarrow":false,"text":"2","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.4594594594594594,"showarrow":false,"text":"3","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.18918918918918914,"showarrow":false,"text":"4","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"}],"grid":{"rows":4,"columns":1,"roworder":"top to bottom","pattern":"independent"}};"""
                |> chartGeneratedContains ``Add logic for positioning subplot titles in LayoutGrid #388``.``cartesian single stack with subplot titles``
            }
            test "singlestack with different subplot types data" {
                """var data = [{"type":"scatter","name":"2D Cartesian","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatter3d","name":"3D Cartesian","mode":"markers","x":[1],"y":[3],"z":[2],"marker":{},"line":{},"scene":"scene2"},{"type":"scatterpolar","name":"Polar","mode":"markers","r":[10],"theta":[20],"marker":{},"subplot":"polar3"},{"type":"scattergeo","name":"Geo","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"geo":"geo4"}];"""
                |> chartGeneratedContains ``Add logic for positioning subplot titles in LayoutGrid #388``.``singlestack with different subplot types and subplot titles``
            }
            test "singlestack with different subplot types layout" {
                """var layout = {"xaxis":{},"yaxis":{},"scene2":{"camera":{"projection":{"type":"perspective"}},"domain":{"row":1,"column":0}},"polar3":{"domain":{"row":2,"column":0}},"geo4":{"domain":{"row":3,"column":0}},"annotations":[{"x":0.5,"y":0.9999999999999999,"showarrow":false,"text":"2D Cartesian","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.7297297297297296,"showarrow":false,"text":"3D Cartesian","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.4594594594594594,"showarrow":false,"text":"Polar","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.18918918918918914,"showarrow":false,"text":"Geo","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"}],"grid":{"rows":4,"columns":1,"roworder":"top to bottom","pattern":"independent"}};"""
                |> chartGeneratedContains ``Add logic for positioning subplot titles in LayoutGrid #388``.``singlestack with different subplot types and subplot titles``
            }
            test "chart grid with all subplot types data" {
                """var data = [{"type":"scatter","name":"2D Cartesian","mode":"markers","x":[1,2],"y":[2,3],"marker":{},"line":{},"xaxis":"x","yaxis":"y"},{"type":"scatter3d","name":"3D Cartesian","mode":"markers","x":[1],"y":[3],"z":[2],"marker":{},"line":{},"scene":"scene2"},{"type":"scatterpolar","name":"Polar","mode":"markers","r":[10],"theta":[20],"marker":{},"subplot":"polar3"},{"type":"scattergeo","name":"Geo","mode":"markers","lat":[2],"lon":[1],"marker":{},"line":{},"geo":"geo4"},{"type":"scattermapbox","name":"MapBox","mode":"markers","lat":[2],"lon":[1],"cluster":{},"marker":{},"line":{},"subplot":"mapbox5"},{"type":"scatterternary","name":"Ternary","mode":"markers","a":[1,2],"b":[2,3],"c":[3,4],"marker":{},"line":{},"subplot":"ternary6"},{"type":"carpet","opacity":0.75,"x":[2.0,3.0,4.0,5.0,2.2,3.1,4.1,5.1,1.5,2.5,3.5,4.5],"y":[1.0,1.4,1.6,1.75,2.0,2.5,2.7,2.75,3.0,3.5,3.7,3.75],"a":[0.0,1.0,2.0,3.0,0.0,1.0,2.0,3.0,0.0,1.0,2.0,3.0],"b":[4.0,4.0,4.0,4.0,5.0,5.0,5.0,5.0,6.0,6.0,6.0,6.0],"aaxis":{"type":"linear","tickprefix":"a = ","minorgridcount":9,"smoothing":0.0},"baxis":{"type":"linear","tickprefix":"b = ","minorgridcount":9,"smoothing":0.0},"carpet":"contour","xaxis":"x7","yaxis":"y7"},{"type":"contourcarpet","z":[1.0,1.96,2.56,3.0625,4.0,5.0625,1.0,7.5625,9.0,12.25,15.21,14.0625],"a":[0,1,2,3,0,1,2,3,0,1,2,3],"b":[4,4,4,4,5,5,5,5,6,6,6,6],"line":{"color":"rgba(255, 255, 255, 1.0)"},"showscale":false,"carpet":"contour","contours":{"showlabels":true}},{"type":"pie","name":"Domain","values":[10,40,50],"marker":{"line":{},"pattern":{}},"domain":{"row":2,"column":1}},{"type":"scattersmith","name":"Smith","mode":"markers+text","imag":[0.5,1.0,2.0,3.0],"real":[0.5,1.0,2.0,3.0],"text":["one","two","three","four","five","six","seven"],"textposition":"top center","marker":{"size":[10,20,30,40]},"line":{},"subplot":"smith9"},{"type":"box","name":"Combined 1","x":"y","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x10","yaxis":"y10"},{"type":"box","name":"Combined 2","x":"y'","y":[2.0,1.5,5.0,1.5,2.0,2.5,2.1,2.5,1.5,1.0,2.0,1.5,5.0,1.5,3.0,2.5,2.5,1.5,3.5,1.0],"marker":{},"line":{},"boxpoints":"all","jitter":0.1,"xaxis":"x10","yaxis":"y10"}];"""
                |> chartGeneratedContains ``Add logic for positioning subplot titles in LayoutGrid #388``.``chart grid with all subplot types and subplot titles``
            }
            test "chart grid with all subplot types layout" {
                """var layout = {"xaxis":{},"yaxis":{},"scene2":{"camera":{"projection":{"type":"perspective"}},"domain":{"row":0,"column":1}},"polar3":{"domain":{"row":0,"column":2}},"geo4":{"domain":{"row":1,"column":0}},"mapbox5":{"style":"open-street-map","domain":{"row":1,"column":1}},"ternary6":{"domain":{"row":1,"column":2}},"xaxis7":{},"yaxis7":{},"smith9":{"domain":{"row":2,"column":2}},"xaxis10":{},"yaxis10":{},"annotations":[{"x":0.14285714285714288,"y":1.045,"font":{"size":20.0},"showarrow":false,"text":"Point","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":1.045,"font":{"size":20.0},"showarrow":false,"text":"Point3D","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.8571428571428572,"y":1.045,"font":{"size":20.0},"showarrow":false,"text":"PointPolar","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.14285714285714288,"y":0.7592857142857142,"font":{"size":20.0},"showarrow":false,"text":"PointGeo","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.7592857142857142,"font":{"size":20.0},"showarrow":false,"text":"PointMapbox","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.8571428571428572,"y":0.7592857142857142,"font":{"size":20.0},"showarrow":false,"text":"PointTernary","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.14285714285714288,"y":0.47357142857142853,"font":{"size":20.0},"showarrow":false,"text":"ContourCarpet","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.5,"y":0.47357142857142853,"font":{"size":20.0},"showarrow":false,"text":"Pie","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.8571428571428572,"y":0.47357142857142853,"font":{"size":20.0},"showarrow":false,"text":"BubbleSmith","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"},{"x":0.14285714285714288,"y":0.18785714285714283,"font":{"size":20.0},"showarrow":false,"text":"Combined BoxPlot","xanchor":"center","xref":"paper","yanchor":"bottom","yref":"paper"}],"grid":{"rows":4,"columns":3,"roworder":"top to bottom","pattern":"independent","ygap":0.5},"width":1000,"height":1000};"""
                |> chartGeneratedContains ``Add logic for positioning subplot titles in LayoutGrid #388``.``chart grid with all subplot types and subplot titles``
            }
        ]