Skip to content
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

E2E tests: add pop out tests for plots to editor #5634

Merged
merged 3 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions test/automation/src/positron/positronClipboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,14 @@ export class PositronClipboard {

return clipboardImageBuffer ? Buffer.from(clipboardImageBuffer) : null;
}

async clearClipboard(): Promise<void> {
// Grant permissions to modify the clipboard
await this.code.driver.context.grantPermissions(['clipboard-write']);

// Use the page context to overwrite the clipboard
await this.code.driver.page.evaluate(async () => {
await navigator.clipboard.writeText(''); // Clear clipboard by writing an empty string
});
}
}
8 changes: 8 additions & 0 deletions test/automation/src/positron/positronPlots.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,4 +133,12 @@ export class PositronPlots {
await expect(this.savePlotModal).not.toBeVisible();
}
}

async openPlotInEditor() {
await this.code.driver.page.locator('.codicon-go-to-file').click();
}

async waitForPlotInEditor() {
await expect(this.code.driver.page.locator('.editor-container img')).toBeVisible({ timeout: 30000 });
}
}
43 changes: 40 additions & 3 deletions test/e2e/features/plots/plots.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,11 @@ test.use({
test.describe('Plots', () => {
// Some tests are not tagged @win because they woould require a new master image.
test.describe('Python Plots', () => {

test.beforeAll(async function ({ userSettings }) {
await userSettings.set([['application.experimental.positronPlotsInEditorTab', 'true']]);
});

test.beforeEach(async function ({ app, interpreter }) {
// Set the viewport to a size that ensures all the plots view actions are visible
if (process.platform === 'linux') {
Expand Down Expand Up @@ -61,10 +66,20 @@ test.describe('Plots', () => {
if (!headless) {
await app.workbench.positronPlots.copyCurrentPlotToClipboard();

const clipboardImageBuffer = await app.workbench.positronClipboard.getClipboardImage();
let clipboardImageBuffer = await app.workbench.positronClipboard.getClipboardImage();
expect(clipboardImageBuffer).not.toBeNull();

await app.workbench.positronClipboard.clearClipboard();
clipboardImageBuffer = await app.workbench.positronClipboard.getClipboardImage();
expect(clipboardImageBuffer).toBeNull();
}

await test.step('Verify plot can be opened in editor', async () => {
await app.workbench.positronPlots.openPlotInEditor();
await app.workbench.positronPlots.waitForPlotInEditor();
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors');
});

await app.workbench.positronLayouts.enterLayout('fullSizedAuxBar');
await app.workbench.positronPlots.clearPlots();
await app.workbench.positronLayouts.enterLayout('stacked');
Expand All @@ -90,6 +105,13 @@ test.describe('Plots', () => {
await app.workbench.positronPlots.currentPlot.screenshot({ path: path.join(...diffPlotsPath, 'graphviz.png') });
fail(`Image comparison failed with mismatch percentage: ${data.rawMisMatchPercentage}`);
}

await test.step('Verify plot can be opened in editor', async () => {
await app.workbench.positronPlots.openPlotInEditor();
await app.workbench.positronPlots.waitForPlotInEditor();
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors');
});

});

test('Python - Verifies the plots pane action bar - Plot actions [C656297]', { tag: ['@web', '@win'] }, async function ({ app }) {
Expand Down Expand Up @@ -240,9 +262,14 @@ test.describe('Plots', () => {
});

test.describe('R Plots', () => {

test.beforeAll(async function ({ userSettings }) {
await userSettings.set([['application.experimental.positronPlotsInEditorTab', 'true']]);
});

test.beforeEach(async function ({ app, interpreter }) {
await interpreter.set('R');
await app.workbench.positronLayouts.enterLayout('stacked');
await interpreter.set('R');
});

test.afterEach(async function ({ app }) {
Expand Down Expand Up @@ -274,10 +301,20 @@ test.describe('Plots', () => {
if (!headless) {
await app.workbench.positronPlots.copyCurrentPlotToClipboard();

const clipboardImageBuffer = await app.workbench.positronClipboard.getClipboardImage();
let clipboardImageBuffer = await app.workbench.positronClipboard.getClipboardImage();
expect(clipboardImageBuffer).not.toBeNull();

await app.workbench.positronClipboard.clearClipboard();
clipboardImageBuffer = await app.workbench.positronClipboard.getClipboardImage();
expect(clipboardImageBuffer).toBeNull();
}

await test.step('Verify plot can be opened in editor', async () => {
await app.workbench.positronPlots.openPlotInEditor();
await app.workbench.positronPlots.waitForPlotInEditor();
await app.workbench.quickaccess.runCommand('workbench.action.closeAllEditors');
});

await app.workbench.positronLayouts.enterLayout('fullSizedAuxBar');
await app.workbench.positronPlots.clearPlots();
await app.workbench.positronLayouts.enterLayout('stacked');
Expand Down
Loading