-
Notifications
You must be signed in to change notification settings - Fork 134
e2e test - pyrefly basic completion suggestion #10846
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
Draft
rodrigosf672
wants to merge
2
commits into
main
Choose a base branch
from
rsf/pyrefly-tests
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+161
−0
Draft
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
134 changes: 134 additions & 0 deletions
134
test/e2e/tests/data-explorer/histogram-rounding.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,134 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
| * Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| /** | ||
| * This test suite verifies that histogram bin ranges in the Data Explorer are properly rounded | ||
| * and displayed with appropriate precision for different numeric scales. | ||
| * | ||
| * The Data Explorer generates histograms for numeric columns with binned ranges. This suite tests | ||
| * that the bin edge values are correctly rounded and formatted across various data ranges: | ||
| * - Integer ranges (whole numbers) | ||
| * - Positive decimal ranges | ||
| * - Ranges spanning negative to positive values | ||
| * - Very small values requiring scientific notation | ||
| * | ||
| * Each test case creates a DataFrame with specific numeric values, opens it in the Data Explorer, | ||
| * displays the summary panel with histograms, and verifies that hovering over histogram bins shows | ||
| * tooltips with the expected rounded range values. | ||
| * | ||
| * Histogram Rounding Test Cases | ||
| * | ||
| * | Case | Data Range | Expected Bins | Description | | ||
| * |------|-------------------|----------------------------------------------------|--------------------------------------| | ||
| * | 1 | 0.0 → 100.0 | 0–33, 34–66, 67–100 | Integer range with whole number bins | | ||
| * | 2 | 1.10 → 3.90 | 1.10–2.03, 2.03–2.97, 2.97–3.90 | Decimal range with 2-digit precision | | ||
| * | 3 | -1.10 → 2.00 | -1.10–0.4500, 0.4500–2.00 | Mixed negative/positive decimal range | | ||
| * | 4 | -0.0001 → 0.00009 | -0.0001–-5.00E-06, -5.00E-06–9.00E-05 | Very small values with scientific notation | | ||
| */ | ||
|
|
||
| import { test, tags } from '../_test.setup'; | ||
|
|
||
| test.use({ | ||
| suiteId: __filename | ||
| }); | ||
|
|
||
| test.describe('Data Explorer - Histogram Rounding', { | ||
| tag: [tags.WEB, tags.WIN, tags.DATA_EXPLORER] | ||
| }, () => { | ||
|
|
||
| test.beforeEach(async ({ hotKeys }) => { | ||
| await hotKeys.stackedLayout(); | ||
| }); | ||
|
|
||
| test.afterEach(async ({ hotKeys }) => { | ||
| await hotKeys.closeAllEditors(); | ||
| }); | ||
|
|
||
| const hoverBinWithRange = async (page: any, expectedMin: string, expectedMax: string) => { | ||
| const bins = page.locator('.vector-histogram foreignObject.tooltip-container'); | ||
| const count = await bins.count(); | ||
| if (count === 0) { | ||
| throw new Error('No histogram bins found'); | ||
| } | ||
|
|
||
| for (let i = 0; i < count; i++) { | ||
| await bins.nth(i).hover(); | ||
| const tooltip = page.locator('.hover-contents'); | ||
| await tooltip.waitFor({ state: 'visible', timeout: 5000 }); | ||
| const text = await tooltip.innerText(); | ||
| if (text.includes(`Range: ${expectedMin} to ${expectedMax}`)) { | ||
| return; // matched expected range | ||
| } | ||
| } | ||
|
|
||
| throw new Error(`No bin tooltip matched Range: ${expectedMin} to ${expectedMax}`); | ||
| }; | ||
|
|
||
| const cases = [ | ||
| { | ||
| name: 'Case 1: 0.0 → 100.0 → Bins: 0–33, 34–66, 67–100', | ||
| varName: 'histRound1', | ||
| python: `import pandas as pd\n# Integer range 0..100\nhistRound1 = pd.DataFrame({'x': list(range(0, 101, 10))})`, | ||
| expectedPairs: [ | ||
| { min: '0', max: '33' }, | ||
| { min: '34', max: '66' }, | ||
| { min: '67', max: '100' } | ||
| ] | ||
| }, | ||
| { | ||
| name: 'Case 2: 1.10 → 3.90 → Bins: 1.10–2.03, 2.03–2.97, 2.97–3.90', | ||
| varName: 'histRound2', | ||
| python: `import pandas as pd\n# Floating range ~[1.1, 3.9]\nhistRound2 = pd.DataFrame({'x': [1.1, 1.8, 2.0, 2.5, 3.0, 3.4, 3.9]})`, | ||
| expectedPairs: [ | ||
| { min: '1.10', max: '2.03' }, | ||
| { min: '2.03', max: '2.97' }, | ||
| { min: '2.97', max: '3.90' } | ||
| ] | ||
| }, | ||
| { | ||
| name: 'Case 3: -1.10 → 2.00 → Bins: -1.10–0.4500, 0.4500–2.00', | ||
| varName: 'histRound3', | ||
| python: `import pandas as pd\n# Floating range ~[-1.1, 2.0]\nhistRound3 = pd.DataFrame({'x': [-1.1, -0.5, 0.0, 1.1, 2.0]})`, | ||
| expectedPairs: [ | ||
| { min: '-1.10', max: '0.4500' }, | ||
| { min: '0.4500', max: '2.00' } | ||
| ] | ||
| }, | ||
| { | ||
| name: 'Case 4: -0.0001 → 0.00009 → Bins: -0.0001–-5.00E-06, -5.00E-06–9.00E-05', | ||
| varName: 'histRound4', | ||
| python: `import pandas as pd\n# Tiny values around zero\nhistRound4 = pd.DataFrame({'x': [-0.0001, -0.00005, 0.0, 0.00005, 0.00009]})`, | ||
| expectedPairs: [ | ||
| { min: '-0.0001', max: '-5.00E-06' }, | ||
| { min: '-5.00E-06', max: '9.00E-05' } | ||
| ] | ||
| } | ||
| ]; | ||
|
|
||
| for (const c of cases) { | ||
| test(c.name, async ({ app, executeCode, hotKeys, python }) => { | ||
| const { dataExplorer, variables, editors } = app.workbench; | ||
| const { page } = app.code.driver; | ||
|
|
||
| await executeCode('Python', c.python); | ||
|
|
||
| await variables.doubleClickVariableRow(c.varName); | ||
| await editors.verifyTab(`Data: ${c.varName}`, { isVisible: true }); | ||
|
|
||
| await hotKeys.closePrimarySidebar(); | ||
| await hotKeys.closeSecondarySidebar(); | ||
|
|
||
| await dataExplorer.summaryPanel.show(); | ||
|
|
||
| // Ensure a histogram is present | ||
| await page.locator('.vector-histogram').first().waitFor({ state: 'visible', timeout: 10000 }); | ||
|
|
||
| // Hover bins until all expected ranges are found | ||
| for (const pair of c.expectedPairs) { | ||
| await hoverBinWithRange(page, pair.min, pair.max); | ||
| } | ||
| }); | ||
| } | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,27 @@ | ||
| /*--------------------------------------------------------------------------------------------- | ||
| * Copyright (C) 2025 Posit Software, PBC. All rights reserved. | ||
| * Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
| *--------------------------------------------------------------------------------------------*/ | ||
|
|
||
| // Suite: Positron LSP: Pyrefly Integration (Untitled Files) | ||
| // CI safety notes: | ||
| // - Creates unsaved scratch buffers only; no workspace file I/O (for now) | ||
| // - Avoids workspace-wide indexing; relies on minimal interactions | ||
|
|
||
| import { test, expect, tags } from '../_test.setup'; | ||
|
|
||
| test.use({ suiteId: __filename }); | ||
|
|
||
| test.describe('Positron LSP: Pyrefly Integration (Untitled)', { tag: [tags.WEB, tags.WIN, tags.EXTENSIONS, tags.EDITOR] }, () => { | ||
|
|
||
| test('Basic Completion Suggestion', async function ({ app, runCommand }) { | ||
| await runCommand('python.createNewFile'); | ||
| await app.workbench.editors.waitForEditorFocus('Untitled-1'); | ||
| await app.workbench.clipboard.setClipboardText('import math\nm'); | ||
| await app.workbench.clipboard.paste(); | ||
| await app.workbench.editors.expectEditorToContain('import math'); | ||
| await app.code.driver.page.keyboard.press('Control+Space'); | ||
| await expect(app.code.driver.page.locator('.suggest-widget')).toBeVisible(); | ||
|
||
| }); | ||
|
|
||
| }); | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter 'page' should be typed with the proper Playwright Page type instead of 'any' for better type safety and IntelliSense support.