Skip to content

Commit

Permalink
Add context menu tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gjmooney committed Jul 22, 2024
1 parent 2b33ee5 commit 5cae6bb
Showing 1 changed file with 224 additions and 0 deletions.
224 changes: 224 additions & 0 deletions ui-tests/tests/contextmenu.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
import {

Check failure on line 1 in ui-tests/tests/contextmenu.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/contextmenu.spec.ts:116:7 › context menu › pressing F2 should start rename for layer

4) tests/contextmenu.spec.ts:116:7 › context menu › pressing F2 should start rename for layer ──── Test timeout of 10000ms exceeded.

Check failure on line 1 in ui-tests/tests/contextmenu.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/contextmenu.spec.ts:205:7 › context menu › move layer to new group

5) tests/contextmenu.spec.ts:205:7 › context menu › move layer to new group ────────────────────── Test timeout of 10000ms exceeded.
IJupyterLabPageFixture,
expect,
galata,
test
} from '@jupyterlab/galata';
import { Locator } from '@playwright/test';
import path from 'path';

async function openLeftPanel(page: IJupyterLabPageFixture): Promise<Locator> {
const sidePanel = page.locator('#jupytergis\\:\\:leftControlPanel');
if (!(await sidePanel.isVisible())) {
const panelIcon = page.getByTitle('JupyterGIS Control Panel');
await panelIcon.first().click();
await page.waitForCondition(async () => await sidePanel.isVisible());
}
return sidePanel;
}

async function openLayerTree(page: IJupyterLabPageFixture): Promise<Locator> {
const sidePanel = await openLeftPanel(page);
const layerTree = sidePanel.locator('.jp-gis-layerPanel');
if (!(await layerTree.isVisible())) {
const layerTitle = sidePanel.getByTitle('Layer tree');
await layerTitle.click();
await page.waitForCondition(async () => await layerTree.isVisible());
}
return layerTree;
}

test.describe('context menu', () => {
test.beforeAll(async ({ request }) => {
const content = galata.newContentsHelper(request);
await content.deleteDirectory('/examples');
await content.uploadDirectory(
path.resolve(__dirname, '../../examples'),
'/examples'
);
});

test.beforeEach(async ({ page }) => {
test.setTimeout(10000);
await page.filebrowser.open('examples/test.jGIS');
});

test.afterEach(async ({ page }) => {
await page.activity.closeAll();
});

test('right click on layer should open layer menu', async ({ page }) => {
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click({ button: 'right' });

const text = page.getByRole('menu').getByText('Remove Layer');
await expect(text).toBeVisible();
});

test('right click on group should open group menu', async ({ page }) => {
await page.getByText('level 1 group').click({ button: 'right' });

const text = page.getByRole('menu').getByText('Remove Group');
await expect(text).toBeVisible();
});

test('hover should display submenu', async ({ page }) => {
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click({ button: 'right' });

await page.getByRole('menu').hover();

const submenu = page.locator('div').filter({
hasText: 'Move to Rootlevel 1 grouplevel 2 groupMove Layers to New Group'
});

const firstItem = page.getByText('Move to Root');
await expect(firstItem).toBeVisible();
await expect(submenu).toBeVisible();
});

test('clicking remove layer should remove the layer from the tree', async ({
page
}) => {
const firstItem = page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map');

await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click({ button: 'right' });

await page.getByRole('menu').getByText('Remove Layer').click();
await expect(firstItem).not.toBeVisible();
});

test('clicking remove group should remove the group from the tree', async ({
page
}) => {
const firstItem = page
.getByLabel('Layers', { exact: true })
.getByText('level 1 group');

await page
.getByLabel('Layers', { exact: true })
.getByText('level 1 group')
.click({ button: 'right' });

await page.getByRole('menu').getByText('Remove Group').click();
await expect(firstItem).not.toBeVisible();
});

test('pressing F2 should start rename for layer', async ({ page }) => {
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click();

Check failure on line 120 in ui-tests/tests/contextmenu.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/contextmenu.spec.ts:116:7 › context menu › pressing F2 should start rename for layer

4) tests/contextmenu.spec.ts:116:7 › context menu › pressing F2 should start rename for layer ──── Error: locator.click: Target closed =========================== logs =========================== waiting for getByLabel('Layers', { exact: true }).getByText('Open Topo Map') ============================================================ 118 | .getByLabel('Layers', { exact: true }) 119 | .getByText('Open Topo Map') > 120 | .click(); | ^ 121 | await page 122 | .getByLabel('Layers', { exact: true }) 123 | .getByText('Open Topo Map') at /home/runner/work/jupytergis/jupytergis/ui-tests/tests/contextmenu.spec.ts:120:8
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.press('F2');
await page
.getByLabel('Layers', { exact: true })
.getByRole('textbox')
.fill('test name');
await page
.getByLabel('Layers', { exact: true })
.getByRole('textbox')
.press('Enter');

const newText = page.getByText('test name');

await expect(newText).toBeVisible();

// reset layer name
await page.locator('#jp-gis-layer-tree div').nth(2).click();
await page.locator('#jp-gis-layer-tree div').nth(2).press('F2');
await page
.getByLabel('Layers', { exact: true })
.getByRole('textbox')
.fill('Open Topo Map');
await page
.getByLabel('Layers', { exact: true })
.getByRole('textbox')
.press('Enter');

const restoredText = page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map');

await expect(restoredText).toBeVisible();
});

test('pressing F2 should start rename for group', async ({ page }) => {
await page
.getByLabel('Layers', { exact: true })
.getByText('level 1 group')
.click({ button: 'right' });

await page.getByLabel('Layers', { exact: true }).click();

await page.getByText('level 1 group').press('F2');
await page.getByRole('textbox').fill('test name');
await page.getByRole('textbox').press('Enter');

const newText = page.getByText('test name');

await expect(newText).toBeVisible();

await page
.getByLabel('Layers', { exact: true })
.getByText('test name')
.click({ button: 'right' });

await page.getByLabel('Layers', { exact: true }).click();
await page.getByText('test name').press('F2');
await page.getByRole('textbox').fill('level 1 group');
await page.getByRole('textbox').press('Enter');

const restoredText = page.getByText('level 1 group');

await expect(restoredText).toBeVisible();
});

test('move layer to group should move layer', async ({ page }) => {
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click({ button: 'right' });

await page.getByText('Move Layers to Group').hover();

await page.getByText('level 2 group').click();
await page.getByText('level 1 group').click();
await page.getByText('level 2 group').click();

const group = page.getByText('level 2 groupRegions FranceOpen Topo Map');

await expect(group).toHaveCount(1);
});

test('move layer to new group', async ({ page }) => {
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click({ button: 'right' });

Check failure on line 209 in ui-tests/tests/contextmenu.spec.ts

View workflow job for this annotation

GitHub Actions / Integration tests

tests/contextmenu.spec.ts:205:7 › context menu › move layer to new group

5) tests/contextmenu.spec.ts:205:7 › context menu › move layer to new group ────────────────────── Error: locator.click: Page closed =========================== logs =========================== waiting for getByLabel('Layers', { exact: true }).getByText('Open Topo Map') ============================================================ 207 | .getByLabel('Layers', { exact: true }) 208 | .getByText('Open Topo Map') > 209 | .click({ button: 'right' }); | ^ 210 | 211 | await page.getByText('Move Layers to Group').hover(); 212 | await page.getByText('Move Layers to New Group').click(); at /home/runner/work/jupytergis/jupytergis/ui-tests/tests/contextmenu.spec.ts:209:8

await page.getByText('Move Layers to Group').hover();
await page.getByText('Move Layers to New Group').click();
await page
.getByLabel('Layers', { exact: true })
.getByRole('textbox')
.fill('new group');
await page
.getByLabel('Layers', { exact: true })
.getByRole('textbox')
.press('Enter');

await expect(page.getByText('new group')).toHaveCount(1);
});
});

0 comments on commit 5cae6bb

Please sign in to comment.