From 5b038836567666b3fd3e4e1938fa05c37a7cfde4 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sat, 11 Dec 2021 15:06:57 +0000 Subject: [PATCH 1/5] Fix `Line:Ch` and `Cell` sort order --- .../src/features/diagnostics/listing.tsx | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx b/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx index a2e4de03c..4b402715e 100644 --- a/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx +++ b/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx @@ -226,13 +226,9 @@ export class DiagnosticsListing extends VDomRenderer { label: this.trans.__('Cell'), render_cell: row => {row.cell_number}, sort: (a, b) => - a.cell_number > b.cell_number - ? 1 - : a.data.range.start.line > b.data.range.start.line - ? 1 - : a.data.range.start.ch > b.data.range.start.ch - ? 1 - : -1, + a.cell_number - b.cell_number + || a.data.range.start.line - b.data.range.start.line + || a.data.range.start.ch - b.data.range.start.ch, is_available: context => context.adapter.has_multiple_editors }), new Column({ @@ -244,11 +240,8 @@ export class DiagnosticsListing extends VDomRenderer { ), sort: (a, b) => - a.data.range.start.line > b.data.range.start.line - ? 1 - : a.data.range.start.ch > b.data.range.start.ch - ? 1 - : -1 + a.data.range.start.line - b.data.range.start.line + || a.data.range.start.ch - b.data.range.start.ch }) ]; } From 1e6173e5a1af8a587a355724131af17f25d124ed Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sat, 11 Dec 2021 15:07:49 +0000 Subject: [PATCH 2/5] Fix diagnostic panel table header border --- packages/jupyterlab-lsp/style/diagnostics_listing.css | 2 ++ 1 file changed, 2 insertions(+) diff --git a/packages/jupyterlab-lsp/style/diagnostics_listing.css b/packages/jupyterlab-lsp/style/diagnostics_listing.css index 398f735f0..841fb5410 100644 --- a/packages/jupyterlab-lsp/style/diagnostics_listing.css +++ b/packages/jupyterlab-lsp/style/diagnostics_listing.css @@ -7,6 +7,8 @@ background: var(--jp-layout-color1); font-size: var(--jp-ui-font-size1); border-spacing: 0; + /* required to preserve borders of `` when using position:sticky */ + border-collapse: separate; width: 100%; } From b2d8a0fac4be0467c13c3b9cad1ccfd7335f23c9 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sat, 11 Dec 2021 16:22:48 +0000 Subject: [PATCH 3/5] Add a note on `jupyterlab-unfold` --- CONTRIBUTING.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index b8f9b2588..3a329ef82 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -318,6 +318,8 @@ python scripts/combine.py set FIREFOX_BINARY=C:\path\to\firefox.exe # ... windows ``` +- If you see `Element ... could not be scrolled into view` in the `Open Context Menu for File` step check if you have an alternative file browser installed (such as `jupyterlab-unfold`) which might interfere with testing (it is recommended to run the tests in an separated environment) + ### Formatting Minimal code style is enforced with `pytest-flake8` during unit testing. If installed, From ad697d7666c7df3d76351c870b5cc8012a5a2c21 Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sat, 11 Dec 2021 16:23:24 +0000 Subject: [PATCH 4/5] Test sorting of columns in diagnostic panel --- atest/04_Interface/DiagnosticsPanel.robot | 41 +++++++++++++++---- atest/examples/Panel.ipynb | 5 ++- .../src/features/diagnostics/listing.tsx | 11 ++--- 3 files changed, 43 insertions(+), 14 deletions(-) diff --git a/atest/04_Interface/DiagnosticsPanel.robot b/atest/04_Interface/DiagnosticsPanel.robot index eed984caf..3657b47a1 100644 --- a/atest/04_Interface/DiagnosticsPanel.robot +++ b/atest/04_Interface/DiagnosticsPanel.robot @@ -6,7 +6,7 @@ Test Setup Set Up Test Teardown Clean Up *** Variables *** -${EXPECTED_COUNT} 1 +${EXPECTED_COUNT} 4 ${DIAGNOSTIC} W291 trailing whitespace (pycodestyle) ${DIAGNOSTIC MESSAGE} trailing whitespace ${DIAGNOSTIC MESSAGE R} Closing curly-braces should always be on their own line @@ -54,24 +54,40 @@ Columns Can Be Hidden Capture Page Screenshot 03-message-column-toggled.png Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE} +Can Sort By Cell + # https://github.com/jupyter-lsp/jupyterlab-lsp/issues/707 + Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE} + Click Element css:.lsp-diagnostics-listing th[data-id="Line:Ch"] + Table Cell Should Equal Line:Ch row=1 column=-1 + Table Cell Should Equal 0:0 row=2 column=-1 + Table Cell Should Equal 0:8 row=3 column=-1 + Table Cell Should Equal 1:0 row=4 column=-1 + Table Cell Should Equal 1:4 row=5 column=-1 + Click Element css:.lsp-diagnostics-listing th[data-id="Line:Ch"] + Table Cell Should Equal 1:4 row=2 column=-1 + Diagnostics Can Be Ignored By Code - Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count 1 - Open Context Menu Over css:.lsp-diagnostics-listing tbody tr + Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_COUNT} + # W291 should be shown twice, lets try to hide it + ${EXPECTED_AFTER} Evaluate ${EXPECTED_COUNT}-2 + Open Context Menu Over W291 Expand Menu Entry Ignore diagnostics Select Menu Entry code Open in Advanced Settings ${DIAGNOSTICS PLUGIN ID} Capture Page Screenshot 02-code-pressed.png - Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count 0 + Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_AFTER} Diagnostics Can Be Ignored By Message - Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count 1 - Open Context Menu Over css:.lsp-diagnostics-listing tbody tr + Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_COUNT} + # W291 should be shown twice, lets try to hide it + ${EXPECTED_AFTER} Evaluate ${EXPECTED_COUNT}-2 + Open Context Menu Over W291 Expand Menu Entry Ignore diagnostics Capture Page Screenshot 02-menu-visible.png Select Menu Entry Ignore diagnostics with "W291 trailing whitespace" message Open in Advanced Settings ${DIAGNOSTICS PLUGIN ID} Capture Page Screenshot 02-message-pressed.png - Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count 0 + Wait Until Keyword Succeeds 10 x 1s Should Have Expected Rows Count ${EXPECTED_AFTER} Diagnostic Message Can Be Copied Wait Until Keyword Succeeds 10 x 1s Element Should Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE} @@ -97,6 +113,12 @@ Diagnostics Panel Works After Removing Foreign Document Wait Until Keyword Succeeds 10 x 1s Element Should Not Contain ${DIAGNOSTICS PANEL} ${DIAGNOSTIC MESSAGE R} *** Keywords *** +Open Context Menu Over W291 + Click Element css:.lsp-diagnostics-listing th[data-id="Code"] + Table Cell Should Equal Code row=1 column=2 + Table Cell Should Equal W291 row=-1 column=2 + Open Context Menu Over css:.lsp-diagnostics-listing tbody > tr:last-child + Expand Menu Entry [Arguments] ${label} ${entry} = Set Variable xpath://div[contains(@class, 'lm-Menu-itemLabel')][contains(text(), "${label}")] @@ -132,6 +154,11 @@ Should Have Expected Rows Count ${count} = Count Diagnostics In Panel Should Be True ${count} == ${expected_count} +Table Cell Should Equal + [Arguments] ${expected} ${row} ${column} + ${cell} = Get Table Cell css:table.lsp-diagnostics-listing ${row} ${column} + Should Be Equal As Strings ${cell} ${expected} + Set Up Gently Reset Workspace Open Notebook And Panel Panel.ipynb diff --git a/atest/examples/Panel.ipynb b/atest/examples/Panel.ipynb index b12eea395..c7200e969 100644 --- a/atest/examples/Panel.ipynb +++ b/atest/examples/Panel.ipynb @@ -15,13 +15,14 @@ "metadata": {}, "outputs": [], "source": [ - "test" + " \n", + "test " ] } ], "metadata": { "kernelspec": { - "display_name": "Python 3", + "display_name": "Python 3 (ipykernel)", "language": "python", "name": "python3" }, diff --git a/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx b/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx index 4b402715e..baf6363cc 100644 --- a/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx +++ b/packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx @@ -120,6 +120,7 @@ function SortableTH(props: { key={props.id} onClick={() => props.listing.sort(props.id)} className={is_sort_key ? 'lsp-sorted-header' : null} + data-id={props.id} >
@@ -226,9 +227,9 @@ export class DiagnosticsListing extends VDomRenderer { label: this.trans.__('Cell'), render_cell: row => {row.cell_number}, sort: (a, b) => - a.cell_number - b.cell_number - || a.data.range.start.line - b.data.range.start.line - || a.data.range.start.ch - b.data.range.start.ch, + a.cell_number - b.cell_number || + a.data.range.start.line - b.data.range.start.line || + a.data.range.start.ch - b.data.range.start.ch, is_available: context => context.adapter.has_multiple_editors }), new Column({ @@ -240,8 +241,8 @@ export class DiagnosticsListing extends VDomRenderer { ), sort: (a, b) => - a.data.range.start.line - b.data.range.start.line - || a.data.range.start.ch - b.data.range.start.ch + a.data.range.start.line - b.data.range.start.line || + a.data.range.start.ch - b.data.range.start.ch }) ]; } From 743d131961377d9b2368fc93357374d67f4a79ea Mon Sep 17 00:00:00 2001 From: krassowski <5832902+krassowski@users.noreply.github.com> Date: Sat, 11 Dec 2021 17:23:49 +0000 Subject: [PATCH 5/5] Temporarily pin MacOS version, see: https://github.com/jupyter-lsp/jupyterlab-lsp/pull/717#issuecomment-991717395 --- .github/workflows/job.test.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/job.test.yml b/.github/workflows/job.test.yml index 310ae08a8..f1b12ca38 100644 --- a/.github/workflows/job.test.yml +++ b/.github/workflows/job.test.yml @@ -203,14 +203,14 @@ jobs: path: ./dist acceptance: - runs-on: ${{ matrix.os }}-latest + runs-on: ${{ matrix.os }} name: atest ${{ matrix.os }} py${{ matrix.python }} needs: [build] strategy: # TODO: maybe turn back on fail-fast: false matrix: - os: [ubuntu, macos, windows] + os: ['ubuntu-latest', 'macos-10.15', 'windows-latest'] python: [3.6, 3.7, 3.8] lab: ['>=3.0.0,<4.0.0a0'] include: @@ -227,11 +227,11 @@ jobs: # Node 15 end-of-life: June 2021 nodejs: '>=15,<16.0.0.a0' # TODO: remove when mambaforge just works on setup-miniconda - - os: ubuntu + - os: 'ubuntu-latest' mambaforge: Linux-x86_64.sh - - os: macos + - os: 'macos-10.15' mambaforge: MacOSX-x86_64.sh - - os: windows + - os: 'windows-latest' mambaforge: Windows-x86_64.exe steps: @@ -353,12 +353,12 @@ jobs: smoke: name: smoke ${{ matrix.os }} py${{ matrix.python }} - runs-on: ${{ matrix.os }}-latest + runs-on: ${{ matrix.os }} needs: [build, lint] strategy: fail-fast: false matrix: - os: [ubuntu, macos, windows] + os: ['ubuntu-latest', 'macos-10.15', 'windows-latest'] python: ['3.6', '3.9', 'pypy3'] exclude: - os: windows @@ -370,11 +370,11 @@ jobs: dist: 'jupyter*lsp*.tar.gz' - python: '3.9' dist: 'jupyter*lsp*.whl' - - os: windows + - os: 'windows-latest' py_cmd: python - - os: macos + - os: 'macos-10.15' py_cmd: python3 - - os: ubuntu + - os: 'ubuntu-latest' py_cmd: python steps: - name: Install Python