Skip to content

Commit

Permalink
test md in notebook
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl committed Nov 6, 2023
1 parent 4d4e39f commit 7ab13e0
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 39 deletions.
25 changes: 7 additions & 18 deletions atest/resources/Deck.resource
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,20 @@ ${ZERO_PAD} {0:03d}


*** Keywords ***
Start Deck With Notebook Toolbar Button
[Documentation] Use the notebook toolbar to start deck.
Start Deck With Toolbar Button
[Documentation] Use the toolbar to start deck.
Wait Until Element Is Not Visible css:${CSS_LAB_SPINNER} timeout=1s
Click Element css:${JLAB CSS ACTIVE DOC}
Click Element css:${CSS_DECK_NOTEBOOK_BUTTON}
Click Element css:${CSS_DECK_TOOLBAR_BUTTON}
Wait Until Element Is Visible css:${CSS_DECK_PRESENTING} timeout=1s
Wait Until Element Is Visible css:${CSS_DECK_VISIBLE} timeout=1s
Wait Until Element Is Visible css:${CSS_DECK_REMOTE} timeout=1s

Really Start Deck With Notebook Toolbar Button
[Documentation] REALLY use the notebook toolbar to start deck.
Really Start Deck With Toolbar Button
[Documentation] REALLY use the toolbar to start deck.
Send Error Screenshots To Trash
Wait Until Keyword Succeeds 5x 0.1s Start Deck With Notebook Toolbar Button
Wait Until Keyword Succeeds 5x 0.1s Start Deck With Toolbar Button
[Teardown] Resume Screenshots

Start Markdown Deck From Editor
[Documentation] Start a deck from a markdown editor with the context menu.
[Arguments] ${host}
Select From Context Menu ${CSS_LAB_EDITOR} li${CSS_LAB_CMD_MARKDOWN_PREVIEW}
Close JupyterLab Dock Panel Tab ${host}
Close JupyterLab Dock Panel Tab Launcher
Click Element css:${CSS_LAB_MARKDOWN_VIEWER}
Execute JupyterLab Command Start Deck
Wait Until Element Is Visible css:${CSS_DECK}
Click Element css:${CSS_DECK}

Select From Context Menu
[Documentation] Open the context menu and click an item.
[Arguments] ${host} ${item}
Expand Down
19 changes: 11 additions & 8 deletions atest/resources/DeckSelectors.resource
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
*** Settings ***
Documentation Selectors defined in this repo... could be loaded from JSON?
Resource ./LabSelectors.resource


*** Variables ***
# body
Expand All @@ -10,19 +12,20 @@ ${CSS_DECK_PRESENTING} [data-jp-deck-mode="presenting"]
${CSS_DECK} .jp-Deck

# remote
${CSS_DECK_STOP} .jp-Deck-Remote .jp-deck-mod-stop
${CSS_DECK_FORWARD} .jp-Deck-Remote .jp-deck-mod-direction-forward
${CSS_DECK_BACK} .jp-Deck-Remote .jp-deck-mod-direction-back
${CSS_DECK_UP} .jp-Deck-Remote .jp-deck-mod-direction-up
${CSS_DECK_DOWN} .jp-Deck-Remote .jp-deck-mod-direction-down
${CSS_DECK_DIR_STEM} .jp-Deck-Remote .jp-deck-mod-direction
${CSS_DECK_DIR_STACK} .jp-Deck-Remote .jp-Deck-Remote-WidgetStack
${CSS_DECK_REMOTE} .jp-Deck-Remote
${CSS_DECK_STOP} ${CSS_DECK_REMOTE} .jp-deck-mod-stop
${CSS_DECK_FORWARD} ${CSS_DECK_REMOTE} .jp-deck-mod-direction-forward
${CSS_DECK_BACK} ${CSS_DECK_REMOTE} .jp-deck-mod-direction-back
${CSS_DECK_UP} ${CSS_DECK_REMOTE} .jp-deck-mod-direction-up
${CSS_DECK_DOWN} ${CSS_DECK_REMOTE} .jp-deck-mod-direction-down
${CSS_DECK_DIR_STEM} ${CSS_DECK_REMOTE} .jp-deck-mod-direction
${CSS_DECK_DIR_STACK} ${CSS_DECK_REMOTE} .jp-Deck-Remote-WidgetStack

@{CSS_DECK_NEXT} down forward
@{CSS_DECK_PREV} up back

# notebook
${CSS_DECK_NOTEBOOK_BUTTON} .jp-ToolbarButtonComponent\[data-command="deck:toggle"]
${CSS_DECK_TOOLBAR_BUTTON} ${CSS_LAB_DOC_TOOLBAR_BTN}\[data-command="deck:toggle"]
${CSS_DECK_VISIBLE} .jp-deck-mod-visible
${CSS_DECK_ONSCREEN} .jp-deck-mod-onscreen

Expand Down
2 changes: 1 addition & 1 deletion atest/resources/Docs.resource
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Start Empty Notebook Deck
[Documentation] Start an empty deck
Launch A New JupyterLab Document
Wait Until JupyterLab Kernel Is Idle
Really Start Deck With Notebook Toolbar Button
Really Start Deck With Toolbar Button

Start Basic Notebook Deck
[Documentation] Make a few cells
Expand Down
4 changes: 3 additions & 1 deletion atest/resources/Lab.resource
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ Library JupyterLibrary
Initialize JupyterLab
[Documentation] Get the web app set up for testing.
${executable_path} = Get GeckoDriver Executable Path
Open JupyterLab executable_path=${executable_path}
Open JupyterLab
... executable_path=${executable_path}
... service_log_path=${OUTPUT_DIR}${/}geckodriver.log # this doesn't work yet
Initialize CodeMirror
Set Window Size 1366 768
Reload Page
Expand Down
8 changes: 6 additions & 2 deletions atest/resources/LabSelectors.resource
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Documentation Selectors that should maybe go upstream.

*** Variables ***
# # lumino ##
${CSS_LM_MOD_HIDDEN} .lm-mod-hidden
${CSS_LM_MOD_ACTIVE} .lm-mod-active
${CSS_LM_MENU_ITEM_LABEL} .lm-Menu-itemLabel
${CSS_LM_CLOSE_ICON} .lm-TabBar-tabCloseIcon
Expand All @@ -16,7 +17,6 @@ ${CSS_LAB_MOD_CMD} .jp-mod-commandMode
${CSS_LAB_MOD_ACTIVE} .jp-mod-active
${CSS_LAB_MOD_EDIT} .jp-mod-editMode
${CSS_LAB_MOD_RENDERED} .jp-mod-rendered
${CSS_LAB_MOD_HIDDEN} .lm-mod-hidden

# files
${CSS_LAB_FILES_HOME} .jp-BreadCrumbs-home
Expand All @@ -27,13 +27,17 @@ ${CSS_LAB_NOT_INTERNAL_ANCHOR} a[href*\="#"]:not([href^="https"]):not(${CSS
${CSS_LAB_TAB_NOT_CURRENT} .lm-DockPanel .lm-TabBar-tab:not(.jp-mod-current)

# docs
${CSS_LAB_DOC} .jp-Document
${CSS_LAB_DOC_VISIBLE} ${CSS_LAB_DOC}:not(${CSS_LM_MOD_HIDDEN})
${CSS_LAB_SPINNER} .jp-Spinner
${CSS_LAB_INTERNAL_ANCHOR} .jp-InternalAnchorLink
${CSS_LAB_TOOLBAR_BTN} .jp-ToolbarButtonComponent
${CSS_LAB_DOC_TOOLBAR_BTN} ${CSS_LAB_DOC_VISIBLE} ${CSS_LAB_TOOLBAR_BTN}

# meta
${CSS_LAB_ADVANCED_COLLAPSE} .jp-NotebookTools .jp-Collapse-header
${CSS_LAB_CELL_META_JSON} .jp-MetadataEditorTool
${CSS_LAB_CELL_META_JSON_HIDDEN} ${CSS_LAB_MOD_HIDDEN} ${CSS_LAB_CELL_META_JSON}
${CSS_LAB_CELL_META_JSON_HIDDEN} ${CSS_LM_MOD_HIDDEN} ${CSS_LAB_CELL_META_JSON}

# notebook
${CSS_LAB_NB_TOOLBAR} .jp-NotebookPanel-toolbar
Expand Down
6 changes: 2 additions & 4 deletions atest/suites/lab/01-examples.robot
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@ Visit All Example Slides And Fragments
${stem} = Set Variable ${example.lower().replace(" ", "_")}
Open Example ${example}
Capture Page Screenshot ${stem}-00-before-deck.png
IF ${example.endswith('.ipynb')}
Really Start Deck With Notebook Toolbar Button
ELSE IF ${example.endswith('.md')}
Start Markdown Deck From Editor ${example}
IF ${example.endswith('.ipynb')} or ${example.endswith('.md')}
Really Start Deck With Toolbar Button
ELSE
Execute JupyterLab Command Start Deck
END
Expand Down
20 changes: 16 additions & 4 deletions atest/suites/nb/01-examples.robot
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,20 @@ Force Tags suite:examples


*** Test Cases ***
The README Markdown Can Be Navigated
[Documentation] All slides and fragments are reachable.
[Tags] activity:markdown
Visit All Example Slides And Fragments ${README_MD}
Execute JupyterLab Command Start Deck
Wait Until Element Is Visible css:${CSS_DECK}
${anchors} = Get WebElements css:${CSS_LAB_MARKDOWN_VIEWER} a[href\^="#"]
${anchors} = Filter Visible Elements ${anchors}
Click Element ${anchors[0]}
Capture Page Screenshot readme.md-10-post-deck-anchor.png
Press Keys css:body SHIFT+SPACE
Capture Page Screenshot readme.md-10-post-deck-reverse.png
[Teardown] Reset Example Test

The README Notebook Can Be Navigated
[Documentation] All slides and fragments are reachable.
[Tags] activity:notebook
Expand All @@ -28,10 +42,8 @@ Visit All Example Slides And Fragments
${stem} = Set Variable ${example.lower().replace(" ", "_")}
Open Example ${example} switch_window=README
Capture Page Screenshot ${stem}-00-before-deck.png
IF ${example.endswith('.ipynb')}
Really Start Deck With Notebook Toolbar Button
ELSE IF ${example.endswith('.md')}
Start Markdown Deck From Editor ${example}
IF ${example.endswith('.ipynb')} or ${example.endswith('.md')}
Really Start Deck With Toolbar Button
ELSE
Execute JupyterLab Command Start Deck
END
Expand Down
3 changes: 2 additions & 1 deletion dodo.py
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,8 @@ def run_robot_with_retries(lab_env, out_root, extra_args=None):
screens.mkdir(parents=True)

for screen_root in out_root.glob("*/screenshots/*"):
shutil.copytree(screen_root, screens / screen_root.name)
if screen_root.is_dir():
shutil.copytree(screen_root, screens / screen_root.name)

return fail_count == 0

Expand Down
2 changes: 2 additions & 0 deletions js/jupyterlab-deck/src/markdown/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,11 @@ export class EditorDeckExtension
panel: FileEditorPanel,
context: DocumentRegistry.IContext<DocumentRegistry.ICodeModel>,
): IDisposable {
/* istanbul ignore if */
if (!MARKDOWN_MIMETYPES.includes(context.model.mimeType)) {
return new DisposableDelegate(() => {});
}

const button = new CommandToolbarButton({
commands: this._commands,
label: '',
Expand Down
1 change: 1 addition & 0 deletions js/jupyterlab-deck/src/markdown/presenter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ export class SimpleMarkdownPresenter
}

protected _getPreviewPanel(panel: MarkdownDocument | FileEditorPanel) {
/* istanbul ignore if */
if (panel instanceof MarkdownDocument) {
return panel;
}
Expand Down

0 comments on commit 7ab13e0

Please sign in to comment.