forked from conveyal/analysis-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
285 lines (243 loc) · 6.91 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
/// <reference types="cypress" />
/// <reference types="leaflet" />
declare namespace Cypress {
// Entity names must be camel cased. They are used to reference JSON keys
export type Entity =
| 'analysis'
| 'bundle'
| 'opportunities'
| 'project'
| 'region'
| 'regionalAnalysis'
export type ModificationType =
| 'Add Streets'
| 'Add Trip Pattern'
| 'Adjust Dwell Time'
| 'Adjust Speed'
| 'Convert To Frequency'
| 'Modify Streets'
| 'Remove Stops'
| 'Remove Trips'
| 'Reroute'
| 'Custom'
export type NavToOption =
| 'analyze'
| 'edit modifications'
| 'network bundles'
| 'spatial datasets'
| 'projects'
| 'regions'
| 'regional analyses'
export type ProjectScenario = {
project?: string
scenario?: string
settings?: Record<string, unknown>
}
export type Stop = {
latlng: L.LatLngTuple
id: string
}
// eslint-disable-next-line
interface Chainable {
/**
* Center the map on the given coordinates.
* @example cy.centerMapOn([60, 25])
*/
centerMapOn(coord: L.LatLngTuple, zoom?: number): Chainable<L.Map>
/**
* Pan to the coordinate and click that point on the map.
*/
clickMapAtCoord(coord: L.LatLngTuple, zoom?: number): Chainable<void>
/**
* Click a stop on the map by its name.
* @example cy.clickStopOnMap(/Stop/)
*/
clickStopOnMap(name: string | RegExp): Chainable<JQuery<HTMLElement>>
/**
* Create a modification.
* @example cy.createModification('Add Trip Pattern', 'New name')
*/
createModification(type: ModificationType, name: string): Chainable<void>
/**
* Create a bundle
*/
createBundle(
name: string,
gtfsFilePath: string,
pbfFilePath: string
): Chainable<string>
/**
* Create a new opportunity dataset.
* @param name
* @param filePath
*/
createOpportunityDataset(
name: string,
filePath: string,
isFreeform?: boolean,
idField?: string
): Chainable<string>
/**
* Create a new regional analysis.
* @example cy.createRegionalAnalysis('New RA', ['default'])
*/
createRegionalAnalysis(
name: string,
opportunityDatasets: string[],
settings?: {
cutoffs?: number[]
percentiles?: number[]
timeout?: number
}
): Chainable<string>
/**
* Delete a modification by type and name.
*/
deleteModification(name: string): Chainable<void>
/**
* Delete an open modification.
*/
deleteThisModification(): Chainable<void>
/**
* Drag a marker on the map.
*/
dragMarker(
markerTitle: string,
start: L.LatLngTuple,
end: L.LatLngTuple
): Chainable<void>
/**
* Draw route geometry on an open modification
* @example cy.drawRouteGeometry([[50, -70], [51, -71]])
*/
drawRouteGeometry(coords: L.LatLngTuple[]): Chainable<void>
/**
* Set custom analysis value.
* @example cy.editPrimaryAnalysisJSON('fromLat', 51)
*/
editPrimaryAnalysisJSON(key: string, newValue: any): Chainable<void>
/**
* Edit modification JSON directly.
*/
editModificationJSON(newValues: Record<string, unknown>): Chainable<void>
/**
* While in the analysis page, fetch and wait for results.
* @example cy.fetchResults()
*/
fetchResults(): Chainable<void>
/**
* Find a button by the name
*/
findButton(name: string | RegExp): Chainable<JQuery<HTMLElement>>
/**
* Find a stop on the map by name.
*/
findStop(name: string | RegExp): Chainable<Stop>
/**
* Get a task by the title
*/
findTask(title: string): Chainable<JQuery<HTMLElement>>
/**
* Get a Toast.
*/
findToast(): Chainable<JQuery<HTMLElement>>
/**
* Get the LeafletMap.
* @example cy.getLeafletMap().then(map => {...})
*/
getLeafletMap(): Chainable<L.Map>
/**
*
* @param entity
*/
getMapDiv(): Chainable<HTMLElement>
/**
* Get the analysis settings section for primary/comparison.
*/
getPrimaryAnalysisSettings(): Chainable<JQuery<HTMLDivElement>>
getComparisonAnalysisSettings(): Chainable<JQuery<HTMLDivElement>>
/**
* Check if the values are within a tolerance of each other
* @example cy.get('#input').itsNumericValue().isWithin(7, 1)
*/
isWithin(comparison: number, tolerance?: number): Chainable<boolean>
/**
* Get the numeric value of an input.
* @example cy.get('#input').itsNumericValue().should('be', 12)
*/
itsNumericValue(): Chainable<number>
/**
* Get the text as a numberic value.
* @example cy.findByText('Opportunities').itsNumericText().should('be', 18200)
*/
itsNumericText(): Chainable<number>
/**
* Wait until the spinner is gone and loading is complete.
*/
loadingComplete(): Chainable<boolean>
/**
* Check if the map is centered on a set of coordinates.
* @example cy.mapCenteredOn([50.5, 121.2], 5)
*/
mapCenteredOn(latlng: L.LatLngTuple, tolerance: number): Chainable<boolean>
/**
* Navigate to a page via the sidebar.
* @example cy.navTo('projects')
*/
navTo(location: NavToOption): Chainable<boolean>
/**
* Wait until a manual navigation is complete.
* @example cy.navComplete()
*/
navComplete(): Chainable<boolean>
/**
* Open an existing modification.
* @example cy.openModification('New name')
*/
openModification(name: string): Chainable<void>
/**
* Merge new values into the existing analysis JSON. Must be done chained from or
* `within` one of the two analysis sections.
* @example cy.get('#Primary').patchAnalysisJSON({fromLat: 50})
*/
patchAnalysisJSON(
newValues: Record<string, unknown>
): Chainable<HTMLElement>
/**
* Select the default dataset.
*/
selectDefaultOpportunityDataset(): Chainable<void>
/**
* Select modification feed and route by name
*/
selectFeed(feedName: string): Chainable<void>
selectRoute(routeName: string): Chainable<void>
/**
* Set the analysis origin.
* @example cy.setOrigin([lat, lng])
*/
setOrigin(latlng: L.LatLngTuple): Chainable<void>
/**
* Set the project/scenario. Must be chained off a specific settings.
* @example cy.getPrimaryAnalysisSettings().setProjectScenario('project')
*/
setProjectScenario(
project: string,
scenario?: string
): Chainable<HTMLElement>
/**
* Set the time cutoff.
* @example cy.setTimeCutoff(120)
*/
setTimeCutoff(cutoff: number): Chainable<void>
/**
* Wait for the map to be ready for interactivity
* @example cy.waitForMapToLoad()
*/
waitForMapToLoad(): Chainable<L.Map>
/**
* Go to home page and wait for it to load.
*/
visitHome(): Chainable<void>
}
}