@@ -3,7 +3,10 @@ import type { CompassBrowser } from '../helpers/compass-browser';
33import { beforeTests , afterTests , afterTest } from '../helpers/compass' ;
44import type { Compass } from '../helpers/compass' ;
55import * as Selectors from '../helpers/selectors' ;
6- import { createNumbersCollection } from '../helpers/insert-data' ;
6+ import {
7+ createGeospatialCollection ,
8+ createNumbersCollection ,
9+ } from '../helpers/insert-data' ;
710
811const { expect } = chai ;
912
@@ -18,8 +21,8 @@ describe('Collection schema tab', function () {
1821
1922 beforeEach ( async function ( ) {
2023 await createNumbersCollection ( ) ;
24+ await createGeospatialCollection ( ) ;
2125 await browser . connectWithConnectionString ( 'mongodb://localhost:27091/test' ) ;
22- await browser . navigateToCollectionTab ( 'test' , 'numbers' , 'Schema' ) ;
2326 } ) ;
2427
2528 after ( async function ( ) {
@@ -31,6 +34,7 @@ describe('Collection schema tab', function () {
3134 } ) ;
3235
3336 it ( 'analyzes a schema' , async function ( ) {
37+ await browser . navigateToCollectionTab ( 'test' , 'numbers' , 'Schema' ) ;
3438 await browser . clickVisible ( Selectors . AnalyzeSchemaButton ) ;
3539
3640 const element = await browser . $ ( Selectors . SchemaFieldList ) ;
@@ -60,6 +64,39 @@ describe('Collection schema tab', function () {
6064 expect ( fieldTypes ) . to . deep . equal ( [ 'objectid' , 'int32' , 'int32' ] ) ;
6165 } ) ;
6266
67+ for ( const enableMaps of [ true , false ] ) {
68+ it ( `can analyze coordinates for a schema (enableMaps = ${ enableMaps } )` , async function ( ) {
69+ await browser . setFeature ( 'enableMaps' , enableMaps ) ;
70+ await browser . navigateToCollectionTab ( 'test' , 'geospatial' , 'Schema' ) ;
71+ await browser . clickVisible ( Selectors . AnalyzeSchemaButton ) ;
72+
73+ const element = await browser . $ ( Selectors . SchemaFieldList ) ;
74+ await element . waitForDisplayed ( ) ;
75+
76+ const schemaFieldNameElement = await browser . $$ (
77+ Selectors . SchemaFieldName
78+ ) ;
79+ const fieldNames = (
80+ await Promise . all ( schemaFieldNameElement . map ( ( el ) => el . getText ( ) ) )
81+ ) . map ( ( text ) => text . trim ( ) ) ;
82+ expect ( fieldNames ) . to . deep . equal ( [ '_id' , 'location' ] ) ;
83+
84+ const schemaFieldTypeListElement = await browser . $$ (
85+ Selectors . SchemaFieldTypeList
86+ ) ;
87+ const fieldTypes = (
88+ await Promise . all ( schemaFieldTypeListElement . map ( ( el ) => el . getText ( ) ) )
89+ ) . map ( ( text ) => text . trim ( ) ) ;
90+ expect ( fieldTypes ) . to . deep . equal ( [
91+ 'objectid' ,
92+ enableMaps ? 'coordinates' : 'document' ,
93+ ] ) ;
94+ await browser
95+ . $ ( '.leaflet-container' )
96+ . waitForDisplayed ( { reverse : ! enableMaps } ) ;
97+ } ) ;
98+ }
99+
63100 it ( 'analyzes the schema with a query' ) ;
64101 it ( 'can reset the query' ) ;
65102 it ( 'can create a geoquery from a map' ) ;
0 commit comments