-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
e2e tests: add expanded variables test (#5109)
### Intent Add a test to verify that variables display correct values and types when expanded. ### Approach The test runs a Python script to create a polars data frame with various data types. It expands each variable in the UI and asserts that the displayed values and types match the expected data. ### QA Notes Tagged to run on PRs. (test runs in under 15-20s)
- Loading branch information
Showing
8 changed files
with
133 additions
and
14 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
56 changes: 56 additions & 0 deletions
56
test/smoke/src/areas/positron/variables/variables-expanded.test.ts
This file contains 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,56 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
import { expect } from '@playwright/test'; | ||
import { Application, PositronPythonFixtures } from '../../../../../automation'; | ||
import { setupAndStartApp } from '../../../test-runner/test-hooks'; | ||
|
||
describe('Variables - Expanded View #web #win', () => { | ||
setupAndStartApp(); | ||
|
||
beforeEach(async function () { | ||
const app = this.app as Application; | ||
await PositronPythonFixtures.SetupFixtures(app); | ||
await app.workbench.positronConsole.executeCode('Python', script, '>>>'); | ||
await app.workbench.positronLayouts.enterLayout('fullSizedAuxBar'); | ||
|
||
}); | ||
|
||
it('Python - should display children values and types when variable is expanded', async function () { | ||
const app = this.app as Application; | ||
const variables = app.workbench.positronVariables; | ||
|
||
await variables.expandVariable('df'); | ||
for (const variable of Object.keys(expectedData)) { | ||
const actualData = await variables.getVariableChildren(variable); | ||
expect(actualData).toEqual(expectedData[variable]); | ||
} | ||
}); | ||
}); | ||
|
||
const script = ` | ||
import polars as pl | ||
from datetime import date | ||
df = pl.DataFrame( | ||
{ | ||
"foo": [1, 2, 3], | ||
"bar": [6.0, 7.0, 8.0], | ||
"ham": [date(2020, 1, 2), date(2021, 3, 4), date(2022, 5, 6)], | ||
"green": [None, 2, 3], | ||
"eggs": [0.5, None, 2.5], | ||
"cheese": [True, None, False], | ||
} | ||
) | ||
`; | ||
|
||
const expectedData = { | ||
foo: { 0: { type: "int", value: "1" }, 1: { type: "int", value: "2" }, 2: { type: "int", value: "3" } }, | ||
bar: { 0: { type: "float", value: "6.0" }, 1: { type: "float", value: "7.0" }, 2: { type: "float", value: "8.0" } }, | ||
ham: { 0: { type: "date", value: "datetime.date(2020, 1, 2)" }, 1: { type: "date", value: "datetime.date(2021, 3, 4)" }, 2: { type: "date", value: "datetime.date(2022, 5, 6)" } }, | ||
green: { 0: { type: "NoneType", value: "None" }, 1: { type: "int", value: "2" }, 2: { type: "int", value: "3" } }, | ||
eggs: { 0: { type: "float", value: "0.5" }, 1: { type: "NoneType", value: "None" }, 2: { type: "float", value: "2.5" } }, | ||
cheese: { 0: { type: "bool", value: "True" }, 1: { type: "NoneType", value: "None" }, 2: { type: "bool", value: "False" } }, | ||
}; |
File renamed without changes.
File renamed without changes.