| 
									
										
										
										
											2021-06-08 16:52:31 +02:00
										 |  |  | import T from "./TestHelper"; | 
					
						
							|  |  |  | import UserDetails, {OsmConnection} from "../Logic/Osm/OsmConnection"; | 
					
						
							|  |  |  | import {UIEventSource} from "../Logic/UIEventSource"; | 
					
						
							|  |  |  | import ScriptUtils from "../scripts/ScriptUtils"; | 
					
						
							| 
									
										
										
										
											2021-09-28 17:30:48 +02:00
										 |  |  | import {AllKnownLayouts} from "../Customizations/AllKnownLayouts"; | 
					
						
							|  |  |  | import {ElementStorage} from "../Logic/ElementStorage"; | 
					
						
							|  |  |  | import {Changes} from "../Logic/Osm/Changes"; | 
					
						
							| 
									
										
										
										
											2021-06-08 16:52:31 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | export default class OsmConnectionSpec extends T { | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     /* | 
					
						
							|  |  |  |     This token gives access to the TESTING-instance of OSM. No real harm can be done with it, so it can be commited to the repo | 
					
						
							|  |  |  |      */ | 
					
						
							|  |  |  |     private static _osm_token = "LJFmv2nUicSNmBNsFeyCHx5KKx6Aiesx8pXPbX4n" | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     constructor() { | 
					
						
							| 
									
										
										
										
											2021-09-22 05:02:09 +02:00
										 |  |  |         super("osmconnection", [ | 
					
						
							| 
									
										
										
										
											2021-06-08 16:52:31 +02:00
										 |  |  |             ["login on dev", | 
					
						
							|  |  |  |                 () => { | 
					
						
							| 
									
										
										
										
											2021-09-28 17:30:48 +02:00
										 |  |  |                     const osmConn = new OsmConnection({ | 
					
						
							|  |  |  |                             osmConfiguration: "osm-test", | 
					
						
							|  |  |  |                             layoutName: "Unit test", | 
					
						
							|  |  |  |                             allElements: new ElementStorage(), | 
					
						
							|  |  |  |                             changes: new Changes(), | 
					
						
							|  |  |  |                             oauth_token: new UIEventSource<string>(OsmConnectionSpec._osm_token) | 
					
						
							|  |  |  |                         } | 
					
						
							|  |  |  |                     ); | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  |                     osmConn.userDetails.map((userdetails: UserDetails) => { | 
					
						
							|  |  |  |                         if (userdetails.loggedIn) { | 
					
						
							|  |  |  |                             console.log("Logged in with the testing account. Writing some random data to test preferences") | 
					
						
							|  |  |  |                             const data = Math.random().toString() | 
					
						
							|  |  |  |                             osmConn.GetPreference("test").setData(data) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                             osmConn.GetPreference("https://raw.githubusercontent.com/AgusQui/MapCompleteRailway/main/railway") | 
					
						
							|  |  |  |                                 .setData(data) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                         } | 
					
						
							| 
									
										
										
										
											2021-06-08 16:52:31 +02:00
										 |  |  |                     }); | 
					
						
							| 
									
										
										
										
											2021-09-09 00:05:51 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2021-06-08 16:52:31 +02:00
										 |  |  |                     ScriptUtils.sleep(1000) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |                 } | 
					
						
							|  |  |  |             ] | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         ]); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | } |