-
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 problems tests for Python and R, including facilities for editing code based on line & "term". Validates squiggle presence and error counts, un-does changes and validates errors and squiggles go away. ### QA Notes All tests should pass @:problems @:web @:win
- Loading branch information
1 parent
257cbcd
commit 0140de6
Showing
6 changed files
with
225 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { Code } from '../infra/code'; | ||
import { QuickAccess } from './quickaccess'; | ||
|
||
export const enum ProblemSeverity { | ||
WARNING = 0, | ||
ERROR = 1 | ||
} | ||
|
||
export class Problems { | ||
|
||
static PROBLEMS_VIEW_SELECTOR = '.panel .markers-panel'; | ||
|
||
constructor(private code: Code, private quickaccess: QuickAccess) { } | ||
|
||
async showProblemsView(): Promise<any> { | ||
await this.quickaccess.runCommand('workbench.panel.markers.view.focus'); | ||
await this.waitForProblemsView(); | ||
} | ||
|
||
async waitForProblemsView(): Promise<void> { | ||
await expect(this.code.driver.page.locator(Problems.PROBLEMS_VIEW_SELECTOR)).toBeVisible(); | ||
} | ||
|
||
|
||
static getSelectorInProblemsView(problemType: ProblemSeverity): string { | ||
const selector = problemType === ProblemSeverity.WARNING ? 'codicon-warning' : 'codicon-error'; | ||
return `div[id="workbench.panel.markers"] .monaco-tl-contents .marker-icon .${selector}`; | ||
} | ||
|
||
static getSelectorInEditor(problemType: ProblemSeverity): string { | ||
const selector = problemType === ProblemSeverity.WARNING ? 'squiggly-warning' : 'squiggly-error'; | ||
return `.view-overlays .cdr.${selector}`; | ||
} | ||
} |
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,111 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* 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 { Problems, ProblemSeverity } from '../../infra'; | ||
import { test, tags } from '../_test.setup'; | ||
import { join } from 'path'; | ||
|
||
test.use({ | ||
suiteId: __filename | ||
}); | ||
|
||
test.describe('Problems', { | ||
tag: [tags.DEBUG, tags.WEB, tags.WIN] | ||
}, () => { | ||
|
||
test('Python - Verify Problems Functionality', { tag: [tags.WIN, tags.WEB, tags.PROBLEMS] }, async function ({ app, python, openFile }) { | ||
|
||
await test.step('Open file and replace "rows" on line 9 with exclamation point', async () => { | ||
await openFile(join('workspaces', 'chinook-db-py', 'chinook-sqlite.py')); | ||
|
||
await app.workbench.editor.clickOnTerm('chinook-sqlite.py', 'rows', 9, true); | ||
|
||
await app.code.driver.page.keyboard.type('!'); | ||
}); | ||
|
||
await test.step('Verify File Squiggly', async () => { | ||
const fileSquiggly = Problems.getSelectorInEditor(ProblemSeverity.ERROR); | ||
await expect(app.code.driver.page.locator(fileSquiggly)).toBeVisible(); | ||
}); | ||
|
||
const errorsSelector = Problems.getSelectorInProblemsView(ProblemSeverity.ERROR); | ||
|
||
await app.workbench.problems.showProblemsView(); | ||
|
||
await test.step('Verify Problems Count', async () => { | ||
const errorLocators = await app.code.driver.page.locator(errorsSelector).all(); | ||
|
||
expect(errorLocators.length).toBe(4); | ||
}); | ||
|
||
await test.step('Revert error', async () => { | ||
await app.code.driver.page.keyboard.press(process.platform === 'darwin' ? 'Meta+Z' : 'Control+Z'); | ||
|
||
}); | ||
|
||
await test.step('Verify File Squiggly Is Gone', async () => { | ||
const fileSquiggly = Problems.getSelectorInEditor(ProblemSeverity.ERROR); | ||
await expect(app.code.driver.page.locator(fileSquiggly)).not.toBeVisible(); | ||
}); | ||
|
||
await test.step('Verify Problems Count is 0', async () => { | ||
|
||
await expect(async () => { | ||
const errorLocators = await app.code.driver.page.locator(errorsSelector).all(); | ||
expect(errorLocators.length).toBe(0); | ||
}).toPass({ timeout: 20000 }); | ||
|
||
}); | ||
|
||
}); | ||
|
||
test('R - Verify Problems Functionality', { tag: [tags.WIN, tags.WEB, tags.PROBLEMS] }, async function ({ app, r, openFile }) { | ||
|
||
await test.step('Open file and replace "albums" on line 5 with exclamation point', async () => { | ||
await openFile(join('workspaces', 'chinook-db-r', 'chinook-sqlite.r')); | ||
|
||
await app.workbench.editor.clickOnTerm('chinook-sqlite.r', 'albums', 5, true); | ||
|
||
await app.code.driver.page.keyboard.type('!'); | ||
}); | ||
|
||
await test.step('Verify File Squiggly', async () => { | ||
const fileSquiggly = Problems.getSelectorInEditor(ProblemSeverity.ERROR); | ||
await expect(app.code.driver.page.locator(fileSquiggly)).toBeVisible(); | ||
}); | ||
|
||
const errorsSelector = Problems.getSelectorInProblemsView(ProblemSeverity.ERROR); | ||
|
||
await app.workbench.problems.showProblemsView(); | ||
|
||
await test.step('Verify Problems Count', async () => { | ||
const errorLocators = await app.code.driver.page.locator(errorsSelector).all(); | ||
|
||
expect(errorLocators.length).toBe(1); | ||
}); | ||
|
||
await test.step('Revert error', async () => { | ||
await app.code.driver.page.keyboard.press(process.platform === 'darwin' ? 'Meta+Z' : 'Control+Z'); | ||
|
||
}); | ||
|
||
await test.step('Verify File Squiggly Is Gone', async () => { | ||
const fileSquiggly = Problems.getSelectorInEditor(ProblemSeverity.ERROR); | ||
await expect(app.code.driver.page.locator(fileSquiggly)).not.toBeVisible(); | ||
}); | ||
|
||
await test.step('Verify Problems Count is 0', async () => { | ||
|
||
await expect(async () => { | ||
const errorLocators = await app.code.driver.page.locator(errorsSelector).all(); | ||
|
||
expect(errorLocators.length).toBe(0); | ||
}).toPass({ timeout: 20000 }); | ||
|
||
}); | ||
|
||
}); | ||
}); |