Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix diagnostic listing sorting by cell/line, fix header border #717

Merged
merged 5 commits into from
Dec 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions .github/workflows/job.test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
41 changes: 34 additions & 7 deletions atest/04_Interface/DiagnosticsPanel.robot
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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}
Expand All @@ -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}")]
Expand Down Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions atest/examples/Panel.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
18 changes: 6 additions & 12 deletions packages/jupyterlab-lsp/src/features/diagnostics/listing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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}
>
<div>
<label>{props.label}</label>
Expand Down Expand Up @@ -226,13 +227,9 @@ export class DiagnosticsListing extends VDomRenderer<DiagnosticsListing.Model> {
label: this.trans.__('Cell'),
render_cell: row => <td key={5}>{row.cell_number}</td>,
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({
Expand All @@ -244,11 +241,8 @@ export class DiagnosticsListing extends VDomRenderer<DiagnosticsListing.Model> {
</td>
),
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
})
];
}
Expand Down
2 changes: 2 additions & 0 deletions packages/jupyterlab-lsp/style/diagnostics_listing.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
background: var(--jp-layout-color1);
font-size: var(--jp-ui-font-size1);
border-spacing: 0;
/* required to preserve borders of `<th>` when using position:sticky */
border-collapse: separate;
width: 100%;
}

Expand Down