Repository navigation
Add a regression test for Query Tool autocomplete reuse when there is text after the cursor. #10819 - #10881
Conversation
… text after the cursor. pgadmin-org#10819 pgadmin-org#10787 now compares validFor against the completed word, which already fixes the reuse failure when trailing SQL follows the cursor. Keep a direct validFor regression test for that case, including the issue's SELECT ... FROM demo_table reproduction. Signed-off-by: Shubham <87247136+shuseng8@users.noreply.github.com>
|
No actionable comments were generated in the recent review. WalkthroughThe change extends the autocomplete test helper with configurable document and cursor positions. New tests cover result reuse when typed text extends the matched word and invalidation when it does not. ChangesAutocomplete reuse regression coverage
Estimated code review effort: 2 (Simple) | ~7 minutes Change: Other Possibly related PRs
Suggested reviewers: Merge Risk:
|
dpage
left a comment
There was a problem hiding this comment.
Thanks for this, Shubham. It's a test-only change that pins down the #10819 behaviour now that #10787 has landed, and I'm happy with it.
I checked that the new tests actually guard the fix rather than only the fake context. With validFor switched back to comparing against fullSql.slice(word.from), the old behaviour, two of the new cases fail; with the current code all 18 tests in QueryAutocomplete.spec.js pass, and eslint is clean on the file.
Making matchBefore() in fakeContext return text is a welcome side effect too. Before this, word.text was undefined in these unit tests, so validFor was never really exercised at this level.
No changes needed.
- Correctness
- Security
- Error handling
- Tests
- Documentation (not needed for a test-only change)
|
Thanks dpage 🚀 |
Fixes #10819
This is a test-only PR. After #10787 landed, I re-ran the
validForJest cases from the earlier patch against currentmaster. They all pass:validFornow compares against the completed word (word.text) rather thanfullSql.slice(from), so a result is reused when there is text after the cursor, as Dave suggested in #10819 (comment).The earlier production change (
fullSql.slice(from, head)) is not included, to avoid conflicting with the #10787 rewrite.This PR adds a direct
validForregression test for that case, including the issue'sSELECT dem FROM demo_table;reproduction, plus the end-of-document and "typed text no longer extends the original word" checks. #10787 already has an editor-level test that reuses the response when text follows the cursor.Testing
From
web/:yarn run eslint -c .eslintrc.jsonQueryAutocomplete.spec.js: cleanyarn run jest regression/javascript/sqleditor/QueryAutocomplete.spec.js regression/javascript/sqleditor/QueryInsertSQLAtCursor.spec.js regression/javascript/components/CodeMirror: 4 suites, 102 tests passedyarn run jest: 200 suites, 1388 tests passedNot run: the Python tests or a manual check against a live server.
Summary by CodeRabbit