|
| 1 | +// @ts-check |
| 2 | +import { test, expect } from '@playwright/test'; |
| 3 | +import { ProjectPage } from "./pages/project"; |
| 4 | + |
| 5 | +test.describe('Sub dock', () => { |
| 6 | + |
| 7 | + test('Metadata layer in attribute table project', async ({ page }) => { |
| 8 | + const project = new ProjectPage(page, 'attribute_table'); |
| 9 | + await project.open(); |
| 10 | + |
| 11 | + // Display info button |
| 12 | + await expect(page.getByTestId('Les quartiers à Montpellier').locator('.icon-info-sign')).toBeHidden(); |
| 13 | + await page.getByTestId('Les quartiers à Montpellier').hover(); |
| 14 | + await expect(page.getByTestId('Les quartiers à Montpellier').locator('.icon-info-sign')).toBeVisible(); |
| 15 | + |
| 16 | + // Display sub dock metadata |
| 17 | + await expect(page.locator('#sub-dock')).toBeHidden(); |
| 18 | + await page.getByTestId('Les quartiers à Montpellier').locator('.icon-info-sign').click(); |
| 19 | + await expect(page.locator('#sub-dock')).toBeVisible(); |
| 20 | + |
| 21 | + // Check sub dock metadata content |
| 22 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 23 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(5); |
| 24 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 25 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 26 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 27 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Opacity'); |
| 28 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(4)).toHaveText('Export'); |
| 29 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dd')).toHaveCount(5); |
| 30 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dd').nth(0)).toHaveText('Les quartiers à Montpellier'); |
| 31 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dd').nth(1)).toHaveText('Layer'); |
| 32 | + |
| 33 | + //close sub dock |
| 34 | + await expect(page.locator('#hide-sub-dock')).toBeVisible(); |
| 35 | + await page.locator('#hide-sub-dock').click(); |
| 36 | + await expect(page.locator('#sub-dock')).toBeHidden(); |
| 37 | + |
| 38 | + // Display sub dock metadata for group |
| 39 | + await page.getByTestId('relation').locator('> div.group > div.node').hover(); |
| 40 | + await expect(page.getByTestId('relation').locator('> div.group > div.node .icon-info-sign')).toBeVisible(); |
| 41 | + await page.getByTestId('relation').locator('> div.group > div.node .icon-info-sign').click(); |
| 42 | + await expect(page.locator('#hide-sub-dock')).toBeVisible(); |
| 43 | + |
| 44 | + // Check sub dock metadata content |
| 45 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 46 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(4); |
| 47 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 48 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 49 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 50 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Opacity'); |
| 51 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dd')).toHaveCount(4); |
| 52 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dd').nth(0)).toHaveText('relation'); |
| 53 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dd').nth(1)).toHaveText('Group'); |
| 54 | + |
| 55 | + //close sub dock |
| 56 | + await expect(page.locator('#hide-sub-dock')).toBeVisible(); |
| 57 | + await page.locator('#hide-sub-dock').click(); |
| 58 | + await expect(page.locator('#sub-dock')).toBeHidden(); |
| 59 | + }); |
| 60 | + |
| 61 | + test('Metadata one on two layers in WFS with attribute table', async ({ page }) => { |
| 62 | + const project = new ProjectPage(page, 'permalink'); |
| 63 | + await project.open(); |
| 64 | + |
| 65 | + // Display sub dock metadata for layer in WFS with multiple styles |
| 66 | + await page.getByTestId('sousquartiers').hover(); |
| 67 | + await page.getByTestId('sousquartiers').locator('.icon-info-sign').click(); |
| 68 | + await expect(page.locator('#sub-dock')).toBeVisible(); |
| 69 | + |
| 70 | + // Check sub dock metadata content |
| 71 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 72 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(6); |
| 73 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 74 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 75 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 76 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Change layer style'); |
| 77 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(4)).toHaveText('Opacity'); |
| 78 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(5)).toHaveText('Export'); |
| 79 | + |
| 80 | + // Display sub dock metadata for layer not in WFS and no multiple styles |
| 81 | + await page.getByTestId('Les quartiers à Montpellier').hover(); |
| 82 | + await page.getByTestId('Les quartiers à Montpellier').locator('.icon-info-sign').click(); |
| 83 | + await expect(page.locator('#sub-dock')).toBeVisible(); |
| 84 | + |
| 85 | + // Check sub dock metadata content |
| 86 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 87 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(4); |
| 88 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 89 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 90 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 91 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Opacity'); |
| 92 | + }); |
| 93 | + |
| 94 | + test('Metadata one on two layers in WFS without attribute table', async ({ page }) => { |
| 95 | + // Remove attribute table config |
| 96 | + await page.route('**/service/getProjectConfig*', async route => { |
| 97 | + const response = await route.fetch(); |
| 98 | + const json = await response.json(); |
| 99 | + json.attributeLayers = {}; |
| 100 | + await route.fulfill({ response, json }); |
| 101 | + }); |
| 102 | + |
| 103 | + const project = new ProjectPage(page, 'permalink'); |
| 104 | + await project.open(); |
| 105 | + |
| 106 | + // Display sub dock metadata for layer in WFS with multiple styles |
| 107 | + await page.getByTestId('sousquartiers').hover(); |
| 108 | + await page.getByTestId('sousquartiers').locator('.icon-info-sign').click(); |
| 109 | + await expect(page.locator('#sub-dock')).toBeVisible(); |
| 110 | + |
| 111 | + // Check sub dock metadata content |
| 112 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 113 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(6); |
| 114 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 115 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 116 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 117 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Change layer style'); |
| 118 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(4)).toHaveText('Opacity'); |
| 119 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(5)).toHaveText('Export'); |
| 120 | + |
| 121 | + // Display sub dock metadata for layer not in WFS and no multiple styles |
| 122 | + await page.getByTestId('Les quartiers à Montpellier').hover(); |
| 123 | + await page.getByTestId('Les quartiers à Montpellier').locator('.icon-info-sign').click(); |
| 124 | + await expect(page.locator('#sub-dock')).toBeVisible(); |
| 125 | + |
| 126 | + // Check sub dock metadata content |
| 127 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 128 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(4); |
| 129 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 130 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 131 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 132 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Opacity'); |
| 133 | + }); |
| 134 | + |
| 135 | + test('Metadata one on two layers in WFS with export disable in attribute table', async ({ page }) => { |
| 136 | + // Remove attribute table config |
| 137 | + await page.route('**/service/getProjectConfig*', async route => { |
| 138 | + const response = await route.fetch(); |
| 139 | + const json = await response.json(); |
| 140 | + json.attributeLayers.sousquartiers.export_enabled = 'False'; |
| 141 | + await route.fulfill({ response, json }); |
| 142 | + }); |
| 143 | + |
| 144 | + const project = new ProjectPage(page, 'permalink'); |
| 145 | + await project.open(); |
| 146 | + |
| 147 | + // Display sub dock metadata for layer in WFS with multiple styles |
| 148 | + await page.getByTestId('sousquartiers').hover(); |
| 149 | + await page.getByTestId('sousquartiers').locator('.icon-info-sign').click(); |
| 150 | + await expect(page.locator('#sub-dock')).toBeVisible(); |
| 151 | + |
| 152 | + // Check sub dock metadata content |
| 153 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 154 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(5); |
| 155 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 156 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 157 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 158 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Change layer style'); |
| 159 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(4)).toHaveText('Opacity'); |
| 160 | + |
| 161 | + // Display sub dock metadata for layer not in WFS and no multiple styles |
| 162 | + await page.getByTestId('Les quartiers à Montpellier').hover(); |
| 163 | + await page.getByTestId('Les quartiers à Montpellier').locator('.icon-info-sign').click(); |
| 164 | + await expect(page.locator('#sub-dock')).toBeVisible(); |
| 165 | + |
| 166 | + // Check sub dock metadata content |
| 167 | + await expect(page.locator('#sub-dock .sub-metadata h3 .text')).toHaveText('Information'); |
| 168 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt')).toHaveCount(4); |
| 169 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(0)).toHaveText('Name'); |
| 170 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(1)).toHaveText('Type'); |
| 171 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(2)).toHaveText('Zoom to the layer extent'); |
| 172 | + await expect(page.locator('#sub-dock .sub-metadata .menu-content dt').nth(3)).toHaveText('Opacity'); |
| 173 | + }); |
| 174 | +}); |
0 commit comments