{
  "metadata": {
    "language_info": {
      "codemirror_mode": {
        "name": "python",
        "version": 3
      },
      "file_extension": ".py",
      "mimetype": "text/x-python",
      "name": "python",
      "nbconvert_exporter": "python",
      "pygments_lexer": "ipython3",
      "version": "3.8"
    },
    "kernelspec": {
      "name": "python",
      "display_name": "Python (Pyodide)",
      "language": "python"
    }
  },
  "nbformat_minor": 4,
  "nbformat": 4,
  "cells": [
    {
      "cell_type": "markdown",
      "source": "# jupyterlab-deck reports\n\n> For documentation, see the [ReadTheDocs] site!\n\n[ReadTheDocs]: https://jupyterlab-deck.rtfd.io",
      "metadata": {
        "slideshow": {
          "slide_type": "slide"
        },
        "tags": []
      }
    },
    {
      "cell_type": "markdown",
      "source": "## Aceptance Tests: Robot Framework\n\n> [Robot Framework][rf] is used with [JupyterLibrary] to test that the system\n> functions as expected in the browser\n\n[rf]: https://robotframework.org\n[JupyterLibrary]: https://robotframework-jupyterlibrary.rtfd.io\n",
      "metadata": {
        "slideshow": {
          "slide_type": "slide"
        },
        "tags": []
      }
    },
    {
      "cell_type": "code",
      "source": "%%html\n<iframe src=\"./robot/log.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">",
      "metadata": {
        "jupyter": {
          "source_hidden": true
        },
        "tags": [],
        "trusted": true
      },
      "execution_count": 95,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<IPython.core.display.HTML object>",
            "text/html": "<iframe src=\"./robot/log.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">\n"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": "## Robot Screenshots",
      "metadata": {
        "slideshow": {
          "slide_type": "slide"
        },
        "tags": []
      }
    },
    {
      "cell_type": "code",
      "source": "%pip install ipywidgets\nimport ipywidgets, pathlib",
      "metadata": {
        "tags": [],
        "jupyter": {
          "source_hidden": true
        },
        "trusted": true
      },
      "execution_count": 96,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": "screens = ipywidgets.SelectionRangeSlider(options=sorted(pathlib.Path(\"robot/screenshots\").rglob(\"*.png\")), layout=dict(width=\"80%\"))\nscreens.value = [screens.options[0], screens.options[0]]\nhtml = ipywidgets.HTML(layout=dict(height=\"60vh\", max_height=\"60vh\"))",
      "metadata": {
        "tags": [],
        "jupyter": {
          "source_hidden": true
        },
        "trusted": true
      },
      "execution_count": 97,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": "def screens_changed(*a):\n    if not screens.value and len(screens.value) == 2: return\n    mm = list(map(screens.options.index, screens.value))\n    html.value = \" \".join([\n        f\"\"\"<a href=\"../files/{s}\"><img src=\"../files/{s}\" width=\"200\" /></a>\"\"\" for s in screens.options[mm[0]:mm[1]]\n    ])\nscreens_changed()\nscreens.observe(screens_changed)",
      "metadata": {
        "tags": [],
        "jupyter": {
          "source_hidden": true
        },
        "trusted": true
      },
      "execution_count": 98,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": "display(screens,html)",
      "metadata": {
        "trusted": true
      },
      "execution_count": 99,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "SelectionRangeSlider(index=(0, 0), layout=Layout(width='80%'), options=(PosixPath('robot/screenshots/li_1/lab/…",
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "a6afaa3ace6c44f0be12133c37476994"
            }
          },
          "metadata": {}
        },
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "HTML(value='', layout=Layout(height='60vh', max_height='60vh'))",
            "application/vnd.jupyter.widget-view+json": {
              "version_major": 2,
              "version_minor": 0,
              "model_id": "c8c5e270bb99466e83d2d094d9d45c98"
            }
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": "## Frontend Code Coverage: NYC\n\n> After the Robot Framework tests run against code instrumented with [istanbul](https://istanbul.js.org) a coverage report is generated with [nyc](https://github.com/istanbuljs/nyc).",
      "metadata": {
        "slideshow": {
          "slide_type": "slide"
        },
        "tags": []
      }
    },
    {
      "cell_type": "code",
      "source": "%%html\n<iframe src=\"./nyc/index.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">",
      "metadata": {
        "jupyter": {
          "source_hidden": true
        },
        "tags": [],
        "trusted": true
      },
      "execution_count": 100,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<IPython.core.display.HTML object>",
            "text/html": "<iframe src=\"./nyc/index.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">\n"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": "## Unit Tests with Pytest\n\n> [pytest](https://docs.pytest.org) is used to test that the outer python packaging environment works, and [pytest-html](https://pytest-html.readthedocs.io) generates reports.",
      "metadata": {
        "slideshow": {
          "slide_type": "slide"
        },
        "tags": []
      }
    },
    {
      "cell_type": "code",
      "source": "%%html\n<iframe src=\"pytest.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">",
      "metadata": {
        "jupyter": {
          "source_hidden": true
        },
        "tags": [],
        "trusted": true
      },
      "execution_count": 101,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<IPython.core.display.HTML object>",
            "text/html": "<iframe src=\"pytest.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">\n"
          },
          "metadata": {}
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": "## Coverage with pytest-cov\n\n> [pytest-cov](https://pytest-cov.readthedocs.io) also runs, generating python coverage.",
      "metadata": {
        "slideshow": {
          "slide_type": "slide"
        },
        "tags": []
      }
    },
    {
      "cell_type": "code",
      "source": "%%html\n<iframe src=\"htmlcov/index.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">",
      "metadata": {
        "jupyter": {
          "source_hidden": true
        },
        "tags": [],
        "trusted": true
      },
      "execution_count": 102,
      "outputs": [
        {
          "output_type": "display_data",
          "data": {
            "text/plain": "<IPython.core.display.HTML object>",
            "text/html": "<iframe src=\"htmlcov/index.html\" style=\"width: 99%; height: 70vh; overflow-y: hidden;\">\n"
          },
          "metadata": {}
        }
      ]
    }
  ]
}