|
1 | | -/* eslint-disable cypress/no-unnecessary-waiting */ |
2 | 1 | import 'cypress-real-events' |
3 | 2 |
|
4 | 3 | describe('dataset pages', () => { |
@@ -40,6 +39,13 @@ describe('dataset pages', () => { |
40 | 39 | fixture: 'insee-rectangles_200m_menage_erbm.json', |
41 | 40 | } |
42 | 41 | ) |
| 42 | + cy.intercept( |
| 43 | + 'GET', |
| 44 | + '/geoserver/insee/ows?SERVICE=WFS&REQUEST=GetFeature&VERSION=2.0.0&TYPENAMES=insee%3Arectangles_200m_menage_erbm&OUTPUTFORMAT=csv', |
| 45 | + { |
| 46 | + fixture: 'population-millesimee-communes-francaises.csv', |
| 47 | + } |
| 48 | + ) |
43 | 49 | cy.intercept( |
44 | 50 | 'GET', |
45 | 51 | '/explore/dataset/population-millesimee-communes-francaises/download?format=csv&timezone=Europe/Berlin&use_labels_for_header=false', |
@@ -211,99 +217,102 @@ describe('dataset pages', () => { |
211 | 217 | cy.get('gn-ui-record-metadata') |
212 | 218 | .find('[id="preview"]') |
213 | 219 | .first() |
214 | | - .as('prevSection') |
| 220 | + .as('previewSection') |
215 | 221 | }) |
216 | 222 | describe('display', () => { |
217 | 223 | it('should display the tabs', () => { |
218 | | - cy.get('@prevSection') |
| 224 | + cy.get('@previewSection') |
219 | 225 | .find('.mat-mdc-tab-labels') |
220 | 226 | .children('div') |
221 | 227 | .should('have.length', 3) |
222 | 228 | }) |
223 | 229 | it('should display the dataset dropdown with at least 1 option', () => { |
224 | | - cy.get('@prevSection') |
| 230 | + cy.get('@previewSection') |
225 | 231 | .find('gn-ui-dropdown-selector') |
226 | | - .find('select') |
227 | | - .children('option') |
| 232 | + .openDropdown() |
| 233 | + .children('button') |
228 | 234 | .should('have.length.gt', 1) |
229 | 235 | }) |
230 | 236 | it('should display the map', () => { |
231 | | - cy.get('@prevSection').find('gn-ui-map').should('be.visible') |
| 237 | + cy.get('@previewSection').find('gn-ui-map').should('be.visible') |
232 | 238 | }) |
233 | 239 | it('should display the table', () => { |
234 | | - cy.get('@prevSection') |
| 240 | + cy.get('@previewSection') |
235 | 241 | .find('.mat-mdc-tab-labels') |
236 | 242 | .children('div') |
237 | 243 | .eq(1) |
238 | 244 | .click() |
239 | | - cy.wait(1000) |
240 | | - cy.get('@prevSection').find('gn-ui-table').should('be.visible') |
241 | | - cy.get('@prevSection') |
| 245 | + cy.get('@previewSection').find('gn-ui-table').should('be.visible') |
| 246 | + cy.get('@previewSection') |
242 | 247 | .find('gn-ui-table') |
243 | 248 | .find('table') |
244 | 249 | .find('tbody') |
245 | 250 | .children('tr') |
246 | 251 | .should('have.length.gt', 0) |
247 | 252 | }) |
248 | 253 | it('should display the chart & dropdowns', () => { |
249 | | - cy.get('@prevSection') |
| 254 | + cy.get('@previewSection') |
250 | 255 | .find('.mat-mdc-tab-labels') |
251 | 256 | .children('div') |
252 | 257 | .eq(2) |
253 | 258 | .click() |
254 | | - cy.get('@prevSection').find('gn-ui-chart').should('not.match', ':empty') |
255 | | - cy.get('@prevSection') |
| 259 | + cy.get('@previewSection') |
| 260 | + .find('gn-ui-chart') |
| 261 | + .should('not.match', ':empty') |
| 262 | + cy.get('@previewSection') |
256 | 263 | .find('gn-ui-chart-view') |
257 | 264 | .find('gn-ui-dropdown-selector') |
258 | 265 | .filter(':visible') |
259 | 266 | .as('drop') |
260 | 267 | cy.get('@drop').should('have.length', 4) |
261 | 268 | cy.get('@drop').each((dropdown) => { |
262 | | - cy.wrap(dropdown).find('option').should('have.length.greaterThan', 0) |
| 269 | + cy.wrap(dropdown) |
| 270 | + .openDropdown() |
| 271 | + .find('button') |
| 272 | + .should('have.length.greaterThan', 0) |
263 | 273 | }) |
264 | 274 | }) |
265 | 275 | }) |
266 | 276 | describe('features', () => { |
267 | 277 | it('MAP : should open a popup on layer click', () => { |
268 | | - cy.get('@prevSection').find('canvas').realClick() |
| 278 | + cy.get('@previewSection').find('canvas').realClick() |
269 | 279 | cy.request({ |
270 | 280 | method: 'GET', |
271 | 281 | url: ' https://www.geo2france.fr/geoserver/insee/ows?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetFeatureInfo&FORMAT=image%2Fpng&TRANSPARENT=true&QUERY_LAYERS=rectangles_200m_menage_erbm&LAYERS=rectangles_200m_menage_erbm&INFO_FORMAT=application%2Fjson&I=249&J=65&WIDTH=296&HEIGHT=296&CRS=EPSG%3A3857&STYLES=&BBOX=-24459.849051256402%2C6237261.508070382%2C337545.9169073383%2C6599267.274028977', |
272 | 282 | failOnStatusCode: false, |
273 | 283 | }) |
274 | | - cy.get('@prevSection').find('gn-ui-feature-detail') |
| 284 | + cy.get('@previewSection').find('gn-ui-feature-detail') |
275 | 285 | }) |
276 | 286 | it('TABLE : should scroll', () => { |
277 | | - cy.get('@prevSection') |
| 287 | + cy.get('@previewSection') |
278 | 288 | .find('.mat-mdc-tab-labels') |
279 | 289 | .children('div') |
280 | 290 | .eq(1) |
281 | 291 | .click() |
282 | | - cy.get('@prevSection').find('gn-ui-table').find('table').as('table') |
| 292 | + cy.get('@previewSection').find('gn-ui-table').find('table').as('table') |
283 | 293 | cy.get('@table').scrollTo('bottom', { ensureScrollable: false }) |
284 | 294 |
|
285 | 295 | cy.get('@table').find('tr:last-child').should('be.visible') |
286 | 296 | }) |
287 | 297 | it('CHART : should change the chart on options change', () => { |
288 | | - cy.get('@prevSection') |
| 298 | + cy.get('@previewSection') |
289 | 299 | .find('.mat-mdc-tab-labels') |
290 | 300 | .children('div') |
291 | 301 | .eq(2) |
292 | 302 | .click() |
293 | | - cy.get('@prevSection') |
| 303 | + cy.get('@previewSection') |
294 | 304 | .find('gn-ui-chart-view') |
295 | 305 | .find('gn-ui-dropdown-selector') |
296 | | - .find('select') |
297 | 306 | .filter(':visible') |
298 | 307 | .as('drop') |
299 | | - cy.get('@drop').eq(0).select('pie chart') |
300 | | - cy.get('@drop').eq(2).select('men') |
301 | | - cy.get('@drop').eq(3).select('average') |
302 | | - cy.get('@prevSection') |
| 308 | + cy.get('@drop').eq(0).selectDropdownOption('pie') |
| 309 | + cy.get('@drop').eq(2).selectDropdownOption('men') |
| 310 | + cy.get('@drop').eq(3).selectDropdownOption('average') |
| 311 | + cy.get('@previewSection') |
303 | 312 | .find('gn-ui-chart') |
304 | 313 | .invoke('attr', 'ng-reflect-type') |
305 | 314 | .should('include', 'pie') |
306 | | - cy.get('@prevSection') |
| 315 | + cy.get('@previewSection') |
307 | 316 | .find('gn-ui-chart') |
308 | 317 | .invoke('attr', 'ng-reflect-value-property') |
309 | 318 | .should('include', 'average(men)') |
@@ -368,7 +377,6 @@ describe('dataset pages', () => { |
368 | 377 | .find('gn-ui-download-item') |
369 | 378 | .first() |
370 | 379 | .click() |
371 | | - cy.wait(4000) |
372 | 380 | cy.exec('ls cypress/downloads').then((result) => { |
373 | 381 | const fileList = result.stdout.split('\n') |
374 | 382 |
|
@@ -417,19 +425,14 @@ describe('dataset pages', () => { |
417 | 425 | .find('button') |
418 | 426 | .first() |
419 | 427 | .click({ force: true }) |
420 | | - // eslint-disable-next-line cypress/unsafe-to-chain-command |
421 | | - cy.wait(500) |
422 | | - .get('body') |
423 | | - .focus() |
424 | | - .realClick() |
425 | | - .window() |
426 | | - .then((win) => { |
427 | | - win.navigator.clipboard.readText().then((text) => { |
428 | | - expect(text).to.eq( |
429 | | - 'https://www.geo2france.fr/geoserver/insee/ows' |
430 | | - ) |
431 | | - }) |
| 428 | + // attempt to make the whole page focused |
| 429 | + cy.get('body').focus() |
| 430 | + cy.get('body').realClick() |
| 431 | + cy.window().then((win) => { |
| 432 | + win.navigator.clipboard.readText().then((text) => { |
| 433 | + expect(text).to.eq('https://www.geo2france.fr/geoserver/insee/ows') |
432 | 434 | }) |
| 435 | + }) |
433 | 436 | }) |
434 | 437 | it('goes to dataset on click', () => { |
435 | 438 | let targetLink |
@@ -458,21 +461,21 @@ describe('record with file distributions', () => { |
458 | 461 | cy.get('gn-ui-record-metadata') |
459 | 462 | .find('[id="preview"]') |
460 | 463 | .first() |
461 | | - .as('prevSection') |
462 | | - cy.get('@prevSection') |
| 464 | + .as('previewSection') |
| 465 | + cy.get('@previewSection') |
463 | 466 | .find('.mat-mdc-tab-labels') |
464 | 467 | .children('div') |
465 | 468 | .eq(1) |
466 | 469 | .click() |
467 | 470 | }) |
468 | 471 |
|
469 | 472 | it('should display the distributions by priority', () => { |
470 | | - cy.get('@prevSection') |
| 473 | + cy.get('@previewSection') |
471 | 474 | .find('gn-ui-dropdown-selector') |
472 | 475 | .last() |
473 | | - .find('select') |
474 | | - .children('option') |
475 | | - .then((options) => options.toArray().map((el) => el.text)) |
| 476 | + .openDropdown() |
| 477 | + .children('button') |
| 478 | + .then((options) => options.toArray().map((el) => el.innerText.trim())) |
476 | 479 | .should('deep.eq', ['csv (csv)', 'json (json)', 'geojson (geojson)']) |
477 | 480 | }) |
478 | 481 | }) |
0 commit comments