-
Notifications
You must be signed in to change notification settings - Fork 92
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Basic outline test for R and Python. Opens a file, focuses the outline and expands it to show all entries, and then validates some of the entries against expectations. Not all entries are validated for Python because some items are dynamic and can have an extra '1' in them. ### QA Notes All smoke tests should pass
- Loading branch information
1 parent
8cc2be8
commit 8b1688a
Showing
5 changed files
with
133 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
|
||
import { fail } from 'assert'; | ||
import { Code } from '../code'; | ||
import { QuickAccess } from '../quickaccess'; | ||
|
||
const HORIZONTAL_SASH = '.explorer-viewlet .monaco-sash.horizontal'; | ||
const FOCUS_OUTLINE_COMMAND = 'outline.focus'; | ||
const OUTLINE_ELEMENT = '.outline-element'; | ||
|
||
/* | ||
* Reuseable Positron outline functionality for tests to leverage. | ||
*/ | ||
export class PositronOutline { | ||
|
||
constructor(private code: Code, private quickaccess: QuickAccess) { } | ||
|
||
async getOutlineData(): Promise<string[]> { | ||
|
||
await this.quickaccess.runCommand(FOCUS_OUTLINE_COMMAND); | ||
|
||
const sashLocator = this.code.driver.page.locator(HORIZONTAL_SASH).nth(1); | ||
const sashBoundingBox = await sashLocator.boundingBox(); | ||
|
||
if (sashBoundingBox) { | ||
|
||
await this.code.driver.clickAndDrag({ | ||
from: { | ||
x: sashBoundingBox.x + 10, | ||
y: sashBoundingBox.y | ||
}, | ||
to: { | ||
x: sashBoundingBox.x + 10, | ||
y: sashBoundingBox.y - 150 | ||
} | ||
}); | ||
} else { | ||
fail('Bounding box not found'); | ||
} | ||
|
||
const outllineElements = await this.code.waitForElements(OUTLINE_ELEMENT, false); | ||
|
||
const outlineData: string[] = []; | ||
for (let i = 0; i < outllineElements.length; i++) { | ||
const element = outllineElements[i]; | ||
const text = element.textContent; | ||
outlineData.push(text); | ||
} | ||
|
||
return outlineData; | ||
} | ||
|
||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (C) 2024 Posit Software, PBC. All rights reserved. | ||
* Licensed under the Elastic License 2.0. See LICENSE.txt for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
|
||
import { join } from 'path'; | ||
import { Application, PositronPythonFixtures, PositronRFixtures } from '../../../../../automation'; | ||
import { setupAndStartApp } from '../../../test-runner/test-hooks'; | ||
|
||
|
||
describe('Outline #web #win', () => { | ||
setupAndStartApp(); | ||
|
||
describe('Outline Test - Python', () => { | ||
before(async function () { | ||
await PositronPythonFixtures.SetupFixtures(this.app as Application); | ||
}); | ||
|
||
it('Python - Verify Outline Contents [C956870]', async function () { | ||
const app = this.app as Application; | ||
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'workspaces', 'chinook-db-py', 'chinook-sqlite.py')); | ||
|
||
const outlineData = await app.workbench.positronOutline.getOutlineData(); | ||
|
||
const expected = [ | ||
'data_file_pathdata_file_path = os.path.join(os.getcwd(), \'data-files\', \'chinook\', \'chinook.db\')', | ||
'connconn = sqlite3.connect(data_file_path)', | ||
'curcur = conn.cursor()', | ||
'rowsrows = cur.fetchall()', | ||
'dfdf = pd.DataFrame(rows)' | ||
]; | ||
|
||
const missingFromUI = expected.filter(item => !outlineData.includes(item)); | ||
|
||
if (missingFromUI.length > 0) { | ||
console.log(`Missing from UI: ${missingFromUI}`); | ||
} | ||
}); | ||
}); | ||
|
||
|
||
|
||
describe('Outline Test - R', () => { | ||
before(async function () { | ||
await PositronRFixtures.SetupFixtures(this.app as Application); | ||
}); | ||
|
||
it('R - Verify Outline Contents [C956871]', async function () { | ||
const app = this.app as Application; | ||
await app.workbench.quickaccess.openFile(join(app.workspacePathOrFolder, 'workspaces', 'chinook-db-r', 'chinook-sqlite.r')); | ||
|
||
const outlineData = await app.workbench.positronOutline.getOutlineData(); | ||
|
||
const expected = [ | ||
'con', | ||
'albums', | ||
'df', | ||
]; | ||
|
||
const missingFromUI = expected.filter(item => !outlineData.includes(item)); | ||
|
||
if (missingFromUI.length > 0) { | ||
console.log(`Missing from UI: ${missingFromUI}`); | ||
} | ||
}); | ||
}); | ||
}); | ||
|
||
|