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

Rework tests #73

Merged
merged 1 commit into from
Jul 25, 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
44 changes: 7 additions & 37 deletions ui-tests/tests/contextmenu.spec.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,17 @@
import {
IJupyterLabPageFixture,
expect,
galata,
test
} from '@jupyterlab/galata';
import { Locator } from '@playwright/test';
import { expect, galata, test } from '@jupyterlab/galata';

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:87:7 › context menu › pressing F2 should start rename for layer

1) tests/contextmenu.spec.ts:87:7 › context menu › pressing F2 should start rename for layer ───── Test timeout of 60000ms 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:175:7 › context menu › move layer to new group

2) tests/contextmenu.spec.ts:175:7 › context menu › move layer to new group ────────────────────── Test timeout of 60000ms exceeded.
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.deleteDirectory('/testDir');
await content.uploadDirectory(
path.resolve(__dirname, '../../examples'),
'/examples'
path.resolve(__dirname, './gis-files'),
'/testDir'
);
});

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

test.afterEach(async ({ page }) => {
Expand Down Expand Up @@ -117,7 +88,7 @@
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click();

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

View workflow job for this annotation

GitHub Actions / Integration tests

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

1) tests/contextmenu.spec.ts:87:7 › context menu › pressing F2 should start rename for layer ───── Error: locator.click: Page closed =========================== logs =========================== waiting for getByLabel('Layers', { exact: true }).getByText('Open Topo Map') ============================================================ 89 | .getByLabel('Layers', { exact: true }) 90 | .getByText('Open Topo Map') > 91 | .click(); | ^ 92 | await page 93 | .getByLabel('Layers', { exact: true }) 94 | .getByText('Open Topo Map') at /home/runner/work/jupytergis/jupytergis/ui-tests/tests/contextmenu.spec.ts:91:8
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
Expand Down Expand Up @@ -160,8 +131,7 @@
.getByText('level 1 group')
.click({ button: 'right' });

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

await page.getByLabel('Layers', { exact: true }).press('Escape');
await page.getByText('level 1 group').press('F2');
await page.getByRole('textbox').fill('test name');
await page.getByRole('textbox').press('Enter');
Expand All @@ -175,7 +145,7 @@
.getByText('test name')
.click({ button: 'right' });

await page.getByLabel('Layers', { exact: true }).click();
await page.getByLabel('Layers', { exact: true }).press('Escape');
await page.getByText('test name').press('F2');
await page.getByRole('textbox').fill('level 1 group');
await page.getByRole('textbox').press('Enter');
Expand Down Expand Up @@ -206,7 +176,7 @@
await page
.getByLabel('Layers', { exact: true })
.getByText('Open Topo Map')
.click({ button: 'right' });

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

View workflow job for this annotation

GitHub Actions / Integration tests

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

2) tests/contextmenu.spec.ts:175:7 › context menu › move layer to new group ────────────────────── Error: locator.click: Page closed =========================== logs =========================== waiting for getByLabel('Layers', { exact: true }).getByText('Open Topo Map') ============================================================ 177 | .getByLabel('Layers', { exact: true }) 178 | .getByText('Open Topo Map') > 179 | .click({ button: 'right' }); | ^ 180 | 181 | await page.getByText('Move Layers to Group').hover(); 182 | await page.getByText('Move Layers to New Group').click(); at /home/runner/work/jupytergis/jupytergis/ui-tests/tests/contextmenu.spec.ts:179:8

await page.getByText('Move Layers to Group').hover();
await page.getByText('Move Layers to New Group').click();
Expand Down
80 changes: 80 additions & 0 deletions ui-tests/tests/gis-files/test.jGIS
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
{
"layerTree": [
"a0044fd7-f167-445f-b3d1-620a8f94b498",
{
"layers": [
"2467576f-b527-4cb7-998d-fa1d056fb8a1",
{
"layers": [
"57ef55ef-facb-48a2-ae1d-c9c824be3e8a"
],
"name": "level 2 group"
}
],
"name": "level 1 group"
}
],
"layers": {
"2467576f-b527-4cb7-998d-fa1d056fb8a1": {
"name": "Open Street Map",
"parameters": {
"source": "699facc9-e7c4-4f38-acf1-1fd7f02d9f36"
},
"type": "RasterLayer",
"visible": true
},
"57ef55ef-facb-48a2-ae1d-c9c824be3e8a": {
"name": "Regions France",
"parameters": {
"color": "#e66100",
"opacity": 0.6,
"source": "7d082e75-69d5-447a-82d8-b05cca5945ba",
"type": "line"
},
"type": "VectorLayer",
"visible": true
},
"a0044fd7-f167-445f-b3d1-620a8f94b498": {
"name": "Open Topo Map",
"parameters": {
"source": "5fd42e3b-4681-4607-b15d-65c3a3e89b32"
},
"type": "RasterLayer",
"visible": true
}
},
"options": {
"latitude": 45.83799886047626,
"longitude": 1.195999428191726,
"zoom": 4.075821017792898
},
"sources": {
"5fd42e3b-4681-4607-b15d-65c3a3e89b32": {
"name": "Open Topo Map",
"parameters": {
"maxZoom": 24.0,
"minZoom": 0.0,
"url": "https://tile.opentopomap.org/{z}/{x}/{y}.png "
},
"type": "RasterSource"
},
"699facc9-e7c4-4f38-acf1-1fd7f02d9f36": {
"name": "Open Street Map",
"parameters": {
"maxZoom": 24.0,
"minZoom": 0.0,
"url": "https://tile.openstreetmap.org/{z}/{x}/{y}.png"
},
"type": "RasterSource"
},
"7d082e75-69d5-447a-82d8-b05cca5945ba": {
"name": "france_regions",
"parameters": {
"path": "france_regions.json",
"valid": true
},
"type": "GeoJSONSource"
}
},
"terrain": {}
}
49 changes: 9 additions & 40 deletions ui-tests/tests/left-panel.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ test.describe('#layerPanel', () => {
test.describe('with GIS document', () => {
test.beforeAll(async ({ request }) => {
const content = galata.newContentsHelper(request);
await content.deleteDirectory('/examples');
await content.deleteDirectory('/testDir');
await content.uploadDirectory(
path.resolve(__dirname, '../../examples'),
'/examples'
path.resolve(__dirname, './gis-files'),
'/testDir'
);
});
test.beforeEach(async ({ page }) => {
await page.filebrowser.open('examples/test.jGIS');
await page.filebrowser.open('testDir/test.jGIS');
});

test.afterEach(async ({ page }) => {
Expand All @@ -83,12 +83,11 @@ test.describe('#layerPanel', () => {
await expect(layerTree).not.toBeEmpty();
});

// TODO Fix this. It seems to fail since https://github.com/QuantStack/jupytergis/pull/48
// test('should restore empty layer panel', async ({ page }) => {
// const layerTree = await openLayerTree(page);
// await page.activity.closeAll();
// await expect(layerTree).toBeEmpty();
// });
test('should restore empty layer panel', async ({ page }) => {
const layerTree = await openLayerTree(page);
await page.activity.closeAll();
await expect(layerTree).toBeEmpty();
});

test('raster layer should have icons', async ({ page }) => {
const layerTree = await openLayerTree(page);
Expand Down Expand Up @@ -126,23 +125,10 @@ test.describe('#layerPanel', () => {

// Open the first level group
await layerGroup.last().click();

await expect(layer.first()).not.toHaveClass(/jp-mod-selected/);
expect(await layer.first().screenshot()).toMatchSnapshot(
'layer-not-selected.png'
);

await layer.first().hover();
expect(await layer.first().screenshot()).toMatchSnapshot(
'layer-hover.png'
);

await layer.first().click();
await layer.last().hover();
await expect(layer.first()).toHaveClass(/jp-mod-selected/);
expect(await layer.first().screenshot()).toMatchSnapshot(
'layer-selected.png'
);

await layer.last().click();
await expect(layer.first()).not.toHaveClass(/jp-mod-selected/);
Expand All @@ -157,18 +143,10 @@ test.describe('#layerPanel', () => {
await expect(hideLayerButton).toHaveCount(1);
await expect(showLayerButton).toHaveCount(0);

expect(await hideLayerButton.screenshot()).toMatchSnapshot(
'layer-visible-icon.png'
);

await hideLayerButton.click();
await expect(hideLayerButton).toHaveCount(0);
await expect(showLayerButton).toHaveCount(1);

expect(await showLayerButton.screenshot()).toMatchSnapshot(
'layer-not-visible-icon.png'
);

await showLayerButton.click();
await expect(hideLayerButton).toHaveCount(1);
await expect(showLayerButton).toHaveCount(0);
Expand Down Expand Up @@ -277,17 +255,8 @@ test.describe('#sourcePanel', () => {
const sourcePanel = await openSourcePanel(page);
const source = sourcePanel.locator('.jp-gis-source');

await source.first().hover();
expect(await source.first().screenshot()).toMatchSnapshot(
'source-hover.png'
);

await source.first().click();
await source.last().hover();
await expect(source.first()).toHaveClass(/jp-mod-selected/);
expect(await source.first().screenshot()).toMatchSnapshot(
'source-selected.png'
);

await source.last().click();
await expect(source.first()).not.toHaveClass(/jp-mod-selected/);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading