Skip to content

Commit

Permalink
feature: add notebook diff editor scrolling test (#1238)
Browse files Browse the repository at this point in the history
  • Loading branch information
SimonSiefke authored Aug 10, 2024
1 parent b4ed00b commit 9f548fd
Show file tree
Hide file tree
Showing 2 changed files with 231 additions and 0 deletions.
210 changes: 210 additions & 0 deletions packages/e2e/src/notebook-diff-editor.scrolling.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
export const skip = process.platform === 'darwin'

export const setup = async ({ Workspace, Explorer, Editor, DiffEditor }) => {
const notebook1 = {
cells: [
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
{
cell_type: 'code',
metadata: {},
source: ['a'],
},
],
metadata: {
language_info: {
name: 'python',
},
},
nbformat: 4,
nbformat_minor: 2,
}
const notebook2 = {
cells: [
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
{
cell_type: 'code',
metadata: {},
source: ['aa'],
},
{
cell_type: 'code',
metadata: {},
source: ['bb'],
},
],
metadata: {
language_info: {
name: 'python',
},
},
nbformat: 4,
nbformat_minor: 2,
}

await Workspace.setFiles([
{
name: 'notebook-1.ipynb',
content: JSON.stringify(notebook1, null, 2) + '\n',
},
{
name: 'notebook-2.ipynb',
content: JSON.stringify(notebook2, null, 2) + '\n',
},
])
await Editor.closeAll()
await Explorer.focus()
await Explorer.shouldHaveItem('notebook-1.ipynb')
await Explorer.shouldHaveItem('notebook-2.ipynb')
await Editor.open('notebook-1.ipynb')
await DiffEditor.open('notebook-1.ipynb', 'notebook-2.ipynb')
await DiffEditor.shouldHaveOriginalEditor('a')
await DiffEditor.shouldHaveModifiedEditor('aa')
}

export const run = async ({ DiffEditor }) => {
await DiffEditor.scrollDown()
await DiffEditor.scrollUp()
}
21 changes: 21 additions & 0 deletions packages/page-object/src/parts/DiffEditor/DiffEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,26 @@ export const create = ({ page, expect, VError }) => {
throw new VError(error, `Failed to assert modified editor contents`)
}
},
async scrollDown() {
try {
await page.waitForIdle()
const scrollContainer = page.locator('.notebook-text-diff-editor .monaco-scrollable-element')
await expect(scrollContainer).toBeVisible()
await scrollContainer.scrollDown()
} catch (error) {
throw new VError(error, `Failed to scroll down in diff editor`)
}
},
async scrollUp() {
try {
await page.waitForIdle()
const scrollContainer = page.locator('.notebook-text-diff-editor .monaco-scrollable-element')
await expect(scrollContainer).toBeVisible()
await scrollContainer.scrollUp()
await page.waitForIdle()
} catch (error) {
throw new VError(error, `Failed to scroll up in diff editor`)
}
},
}
}

0 comments on commit 9f548fd

Please sign in to comment.