mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-25 22:27:32 +00:00
Compare commits
650 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 13910464e5 | |||
| 903868c08c | |||
| 434baaf6fd | |||
| d9d901e52d | |||
| 50cb9364f6 | |||
| b6c50eb146 | |||
| c1c77d89b5 | |||
| 70af8132ef | |||
| 85182d2f52 | |||
| c65e9bf76e | |||
| 3754518d37 | |||
| eed5f75487 | |||
| f29112698e | |||
| d556d706b7 | |||
| 71673085bb | |||
| 19a01d493b | |||
| 462f08727c | |||
| 58298703e1 | |||
| 17e75947f0 | |||
| 4f1e29b02c | |||
| d1ee3ceccb | |||
| 69a976e942 | |||
| f928f4b1ca | |||
| aa79d6286a | |||
| eeff0398a7 | |||
| 7fe4fbb683 | |||
| afbeef64c2 | |||
| 293ec89db4 | |||
| 8809654a43 | |||
| f1d8995d66 | |||
| aab09afc53 | |||
| 34e28d082d | |||
| e6d682b99e | |||
| cb1d400251 | |||
| bcdcd69a64 | |||
| d18a4b2180 | |||
| 4519430610 | |||
| b3845dbdfc | |||
| e6a5ba095d | |||
| 7a643d5f75 | |||
| 4498f68cc9 | |||
| 429a2fb017 | |||
| 07eeae8486 | |||
| c8adf6e1da | |||
| 44c7026e74 | |||
| b185375762 | |||
| ea8202948d | |||
| 7065e18454 | |||
| c4326ec545 | |||
| b03597957c | |||
| 97da0c5ba6 | |||
| e1147504c2 | |||
| b2ba89fe4f | |||
| eb32eb1690 | |||
| 5588b7efbb | |||
| 20c86f3a44 | |||
| 3cef8eae5e | |||
| 6e0c2b894d | |||
| 0fe536bbd2 | |||
| 96fa7ca4e8 | |||
| 8a9f5367b1 | |||
| f6d52727f7 | |||
| 38381bc03a | |||
| af88aef35e | |||
| 0aa53b81e1 | |||
| 4b6911b51f | |||
| 907fc95b00 | |||
| 1c6bdb4129 | |||
| 503b82a149 | |||
| 8349c5066b | |||
| 5e8cc0b90a | |||
| 950942f7b9 | |||
| ac5c91bcaf | |||
| 10f0cb7d04 | |||
| 08f3a8fe0b | |||
| 091ad0f23d | |||
| 2b21407cf9 | |||
| 464d5aa902 | |||
| b9637ff90c | |||
| 918efe35fe | |||
| a0c41bce0a | |||
| 1a6639eb74 | |||
| 807c6a16b4 | |||
| 5d7d6072f7 | |||
| 4cd3f3d650 | |||
| a0d66eb898 | |||
| 8a2045c619 | |||
| 34d5fba437 | |||
| 8b9de04960 | |||
| c289541c43 | |||
| 146f46c5e3 | |||
| 8709f67ff4 | |||
| 363889b97a | |||
| 48e54d5a62 | |||
| d83841f53b | |||
| 485fb93f78 | |||
| ca367d9cfc | |||
| 9ae99b42ec | |||
| 8fb720ea49 | |||
| 1fb1b102e8 | |||
| a604f84899 | |||
| e7e3592d97 | |||
| 8e51410251 | |||
| 22c3381044 | |||
| 25ded7319a | |||
| b6006c8265 | |||
| bd215b7ec7 | |||
| 98a05fa1fd | |||
| 0e918820c3 | |||
| a701d89fb9 | |||
| 4fead3259d | |||
| 4fd8f3987f | |||
| 855ec37935 | |||
| 310e5fba8f | |||
| 8f5324c901 | |||
| 97c0d992c8 | |||
| cd32f07bf5 | |||
| 3c00544e93 | |||
| dec3058777 | |||
| e459ec6e60 | |||
| ba45dbc874 | |||
| fa8e1b68bd | |||
| 755ca865a4 | |||
| a3caa9ca1a | |||
| 344580d343 | |||
| 36ea9bdb3e | |||
| c3d60e1c43 | |||
| 769293a554 | |||
| 56ce66f666 | |||
| fd10ce2876 | |||
| 9d4e52ddfc | |||
| 52a6fbbc92 | |||
| de1c3b8ea6 | |||
| 60885627b1 | |||
| 9c454a04e1 | |||
| 6a6c403860 | |||
| e51902a03b | |||
| 3a2645a3e4 | |||
| bf8677a28c | |||
| 89da19e535 | |||
| e630e92183 | |||
| bb2b4a1f5a | |||
| 626e19c534 | |||
| 8f5988ee33 | |||
| 4cef885e12 | |||
| 303d161ecf | |||
| eaa557343e | |||
| dea903f011 | |||
| 91edf0c565 | |||
| 403b7d2f93 | |||
| 5d4cfec3b6 | |||
| b9608bf684 | |||
| 3b65da7626 | |||
| 327539df14 | |||
| 965b519f23 | |||
| 3ec7cc73b2 | |||
| 493571c559 | |||
| 4212fcdfc8 | |||
| 28f750f7c4 | |||
| 8c9cf4a80c | |||
| b33d592325 | |||
| 590b174dd1 | |||
| 2a833c4ba9 | |||
| a5de1bc52d | |||
| 1b20214a7f | |||
| 3e8496dce6 | |||
| ea1b75e639 | |||
| c0f6551cf4 | |||
| 1fdf74e7f2 | |||
| c7de823c78 | |||
| 49b9ffc77d | |||
| 7006891ce0 | |||
| 4d01439c75 | |||
| adb6a2c80d | |||
| 1824cc77ec | |||
| 9e2805fc89 | |||
| 77380ea5cf | |||
| 9956c58dd5 | |||
| 3f38621024 | |||
| 2f7b8357ce | |||
| 6861687b1f | |||
| 8fc9fe7945 | |||
| f668eee227 | |||
| 711015d5fd | |||
| 6ebd5cf0c7 | |||
| 8ab7547edf | |||
| f599892a4b | |||
| 1436cec35c | |||
| fe90502955 | |||
| 0431741ad7 | |||
| fa99940945 | |||
| 09316025c3 | |||
| 100313cfa9 | |||
| 411ec4af59 | |||
| ec7f5e0585 | |||
| 8e38749bc3 | |||
| 2c17edd74c | |||
| c5e2afc21b | |||
| 502e6916d9 | |||
| 61674cf918 | |||
| ac01925be7 | |||
| 99465d04de | |||
| 73a7c4843b | |||
| 6e919696bb | |||
| d32cfb3635 | |||
| 31c9f40550 | |||
| 7ae4dcba51 | |||
| daa4e1dfcf | |||
| 9a7bce6fd8 | |||
| 0834d4f8fe | |||
| d8c28c9998 | |||
| 76ff6e15b1 | |||
| 3e0a2ef8ed | |||
| fd35f79c36 | |||
| 294a386d23 | |||
| ee79413653 | |||
| ec08915a16 | |||
| 40f9c020bb | |||
| 684a3bf5f5 | |||
| 26122a4208 | |||
| 9dc80760f7 | |||
| 090db8519d | |||
| efc55ac700 | |||
| 85b773420c | |||
| 771dab7c35 | |||
| ca7cdcebcc | |||
| 6bc27a259b | |||
| a2d9c2416d | |||
| fd1942afab | |||
| 23eabe1499 | |||
| bcc82db7bd | |||
| 26b220470a | |||
| cdc31967b2 | |||
| 4a435df6e4 | |||
| 21f4f7d5de | |||
| e3d195896c | |||
| 911bd825c1 | |||
| 81628d78ee | |||
| 69e791206e | |||
| e66330e226 | |||
| c970245e0d | |||
| cc0fe6ce2b | |||
| 39346ceca7 | |||
| 6dfba51f21 | |||
| 3973741509 | |||
| 3eac508baf | |||
| 7f6f2eb97c | |||
| f2cfbc4041 | |||
| 636fc7d0a6 | |||
| adcda60f7d | |||
| e8f808b67f | |||
| 70108e5694 | |||
| c75fb22289 | |||
| 621b2f17df | |||
| bc6728678b | |||
| 6040b60e86 | |||
| 2edf5f807a | |||
| fd864cc441 | |||
| b004d3b88e | |||
| 9b1bd6e435 | |||
| 73f3aa8309 | |||
| 82195c7418 | |||
| 9fd77b04fa | |||
| f1ea716305 | |||
| da1a02e7a8 | |||
| 9808e113e4 | |||
| 13e81c04ab | |||
| fd42d06d55 | |||
| e6f4f7a5f3 | |||
| 9497b586b7 | |||
| 77d90be4f8 | |||
| a884539a2b | |||
| 633df91bd6 | |||
| dd98469a02 | |||
| 223a7605ed | |||
| 0e04eeaf9a | |||
| aa77e21d4b | |||
| 8c8cfb5d5d | |||
| 9eeb59997e | |||
| 8179d7d707 | |||
| f211a1c614 | |||
| f42ef5246c | |||
| e1a5864406 | |||
| 62c03d71bf | |||
| f4ce2c2bd0 | |||
| d643f8c329 | |||
| 1b270806a1 | |||
| 2d7392c4c0 | |||
| a9cdb2f91c | |||
| 2983971c8b | |||
| e6a0a39a51 | |||
| 87612c0c79 | |||
| ff57883e3d | |||
| cd1a3fd433 | |||
| 377f22972b | |||
| fff7d123f6 | |||
| bedb70c479 | |||
| 3b8270edc3 | |||
| 6137aaf716 | |||
| 97a3389409 | |||
| 95ade9cbb2 | |||
| c4c278d2f3 | |||
| 2cb1964863 | |||
| 876cc5e0f0 | |||
| caae538056 | |||
| 1cebddac0e | |||
| 78bfa8183a | |||
| 43af349391 | |||
| 9c35343d9d | |||
| b0b1986377 | |||
| f11f021e15 | |||
| 6e7336b8d7 | |||
| 927fcab67f | |||
| c51f4f78bb | |||
| 12f4a40d7c | |||
| 3a6e91e26b | |||
| 680ce7324a | |||
| f5fbd60b5e | |||
| 8c1395c8f1 | |||
| 19bfa77ace | |||
| 2fb041a428 | |||
| be1983c9a4 | |||
| 2288487fe1 | |||
| b2384892a8 | |||
| 43e30ca28e | |||
| 42f0705f07 | |||
| e97dbc89c9 | |||
| 76dfbe0a00 | |||
| 424fa538e0 | |||
| 863ff62b6c | |||
| e2b0910e28 | |||
| cf9172f9e7 | |||
| 0e911608af | |||
| 95d067ad6d | |||
| ba043cb1c0 | |||
| 3a4c523509 | |||
| 057748c47a | |||
| e4457ed9eb | |||
| f430cbe59e | |||
| 5316362e9e | |||
| 900f2bfc30 | |||
| b7c8f0629c | |||
| 45fef1077a | |||
| ddb42ecf0a | |||
| 09295781f4 | |||
| 5938609f69 | |||
| d3cd484519 | |||
| 410d2393e0 | |||
| 44b6340be5 | |||
| 2f3dc4ea79 | |||
| af861e5816 | |||
| c1bbe27ac6 | |||
| 11f4373076 | |||
| f57fb7f9de | |||
| 96f2427518 | |||
| 3f51153dcc | |||
| fc37eb95d1 | |||
| 55607ff2f9 | |||
| 1ea08dcf0a | |||
| c6f6dd2d57 | |||
| 579df97bba | |||
| aa2f7ca8b4 | |||
| 17c9c0758f | |||
| 7340087353 | |||
| 910c98b971 | |||
| b144781e9f | |||
| a26db47cb6 | |||
| 9e5379d092 | |||
| 693acd5580 | |||
| c3f6177be1 | |||
| 60642cc18b | |||
| 54b843ae29 | |||
| 633e9bcdc1 | |||
| eab501925f | |||
| 2630d7e8ec | |||
| 116ba52fbb | |||
| e5fb6d9107 | |||
| 98529bc84c | |||
| 4a3ad562a7 | |||
| 518287ff12 | |||
| 0cdfb9eb42 | |||
| 4d0067a455 | |||
| 66d4431d26 | |||
| 293a48c26a | |||
| 80fca10784 | |||
| 830cd6e3b5 | |||
| 0f338d5484 | |||
| a99cd40f4d | |||
| f3ea50b17b | |||
| 2e3762afe1 | |||
| 17b47b38b9 | |||
| 494c848ec9 | |||
| c203b0a597 | |||
| b36fefdf5d | |||
| 8611359f7c | |||
| c8e48460b6 | |||
| 5ecf3001af | |||
| 2c5beee849 | |||
| a3f6635633 | |||
| 33d074c786 | |||
| e952586f60 | |||
| 35c0cd35ef | |||
| a1d753a975 | |||
| 35dbcc2103 | |||
| 3c054fffa0 | |||
| c1bad1204c | |||
| 9890f31d10 | |||
| 04e0dc26e1 | |||
| eb56e77600 | |||
| 1a50e7f0ac | |||
| 2a134babbc | |||
| 2180175040 | |||
| 856d1e5ea5 | |||
| ea5542f8eb | |||
| 40dea84085 | |||
| 89f7908359 | |||
| f02c4c57c3 | |||
| 5b0412bc2c | |||
| aa8d041a33 | |||
| 24bc132476 | |||
| f728b568ed | |||
| c4a2a91578 | |||
| a58d0117c6 | |||
| 439736e904 | |||
| 71510a62f3 | |||
| a65342574a | |||
| 783a697d95 | |||
| b8966330e0 | |||
| cb1b5dd88c | |||
| a1f063c703 | |||
| b65a1bb65c | |||
| d1cb0a418a | |||
| 5536d29cbf | |||
| 7bbb5a9f71 | |||
| a1bf57b71a | |||
| 87bcb5a519 | |||
| c72c8dcaf7 | |||
| bac4599d64 | |||
| 535761dbd5 | |||
| 5be521199f | |||
| f71acb08bd | |||
| d6905435ae | |||
| ba562c9047 | |||
| 6bcc49fc6f | |||
| 64847e906e | |||
| 75d458b06b | |||
| a76a96ccca | |||
| bfdbf4d811 | |||
| b068e593fc | |||
| d3ec833ab7 | |||
| 5e97123bdf | |||
| 2bcef51664 | |||
| 0f42b8b8ae | |||
| c67c95201b | |||
| e6f35158c5 | |||
| d541bfa838 | |||
| ef5deada83 | |||
| e1090d5427 | |||
| 335dd9c788 | |||
| c23518dae0 | |||
| 91f8deb3f3 | |||
| a40ae60abb | |||
| 5caa890523 | |||
| a3620f9e05 | |||
| dbda2d7d7c | |||
| b6a296ffea | |||
| ae3dfa2eb7 | |||
| bab1ca9dca | |||
| e1e8c4c63d | |||
| 5f49c87f4a | |||
| 01653f81e3 | |||
| a0764b9c96 | |||
| 94ac7673a5 | |||
| 5fe3dea4cc | |||
| 608f76f32c | |||
| a2cc7af695 | |||
| dfbe23e5b8 | |||
| 6ac7bd2d96 | |||
| a67361c6bd | |||
| 7a40225852 | |||
| 29816f81a9 | |||
| 4337969c2c | |||
| 6789ee1cb6 | |||
| 7ed15a77b4 | |||
| 4806c62976 | |||
| 3957b292be | |||
| 783f679124 | |||
| 7e1de86f0b | |||
| c13c288f00 | |||
| 89b67a791f | |||
| 2ee413368b | |||
| 1aa586d829 | |||
| 53833fd212 | |||
| a7adef5353 | |||
| bd11cd347d | |||
| b19bd8e709 | |||
| 8dedab0375 | |||
| cbd1800976 | |||
| 44f669cd0e | |||
| 1d052f725f | |||
| f7bad3c5b3 | |||
| 264f352502 | |||
| 32291ce8b4 | |||
| c35f39add1 | |||
| 993ed4b472 | |||
| e7db110417 | |||
| 011cc9f11f | |||
| 844d03a9cd | |||
| 1bfaf4ea98 | |||
| 6309064f40 | |||
| 7d3ed21a03 | |||
| f319b3610a | |||
| 81d27d8e8d | |||
| de7de4b8de | |||
| 340454cfc7 | |||
| 5f600cf263 | |||
| aa84d71302 | |||
| baa906fb6b | |||
| 53ebc9d632 | |||
| 332206089b | |||
| 57d0b42726 | |||
| d01f973e62 | |||
| d557f08e28 | |||
| 5dc1de0e5b | |||
| d2b12cd3dd | |||
| 64418489e2 | |||
| 7238f8ae25 | |||
| e525e0b838 | |||
| 2d95bf6744 | |||
| 41134cc455 | |||
| 27f12c2245 | |||
| 4796615439 | |||
| 154563f34d | |||
| 3365511b10 | |||
| c2c0535d52 | |||
| d6799d1205 | |||
| 9cbf31da27 | |||
| 71cc97822a | |||
| c2ba78253d | |||
| 75aeba29ed | |||
| bd58f17ec0 | |||
| 721a610a70 | |||
| eda27f1e59 | |||
| a08d4b944e | |||
| 5137bcb86a | |||
| 7861006bf5 | |||
| 5f6594f697 | |||
| fcbb538c24 | |||
| 43a8984e4c | |||
| e958a9a2bb | |||
| 986dabf11f | |||
| 318e71aa0c | |||
| 308daec14e | |||
| 3f68c8a50e | |||
| 74af74fb5e | |||
| 924b4e0787 | |||
| d5d9428cf2 | |||
| b9231ffb53 | |||
| 489ba93c0c | |||
| 2a448722c6 | |||
| cd53d0a895 | |||
| db6bb911c2 | |||
| 69552ffeef | |||
| 1f710bd217 | |||
| 11e4fe6ae3 | |||
| 3e98938c95 | |||
| 7283b75cac | |||
| cae04e83dd | |||
| 72e8b1f8d9 | |||
| 73ac4b29ad | |||
| 208af03212 | |||
| 8401428ca7 | |||
| 12406bbbf4 | |||
| 12ae32b69e | |||
| 5176dc29d6 | |||
| 0eac3a9f49 | |||
| 64b86c2403 | |||
| 66d85729ff | |||
| e7bff6681e | |||
| c7cfa5a64f | |||
| 72fc61a016 | |||
| a70eea5bf2 | |||
| c9c419b4ad | |||
| 6759277c3b | |||
| 10d5f3ed46 | |||
| 2934319722 | |||
| d4c81bc5f2 | |||
| 35e0613986 | |||
| ccfa92f650 | |||
| fdb2095ced | |||
| d6a6b49b6b | |||
| 0855bafca7 | |||
| a39f3fe40c | |||
| f13a0aa6ee | |||
| 10d1a61614 | |||
| 2bcfc1bfcb | |||
| b6e3c9bf39 | |||
| 736dc5dda9 | |||
| ae26a6c61c | |||
| 8979bd1fcd | |||
| 74d243d8e0 | |||
| 56b9bac031 | |||
| 4983b3407c | |||
| ed1728feec | |||
| 11472c05ff | |||
| f2ac12ca4f | |||
| b53130ca0d | |||
| a3a4f7cf79 | |||
| ac7094df05 | |||
| 80130f7946 | |||
| fc648bc7e4 | |||
| 9005d6b333 | |||
| 52f0fb882f | |||
| b8ec428ad1 | |||
| a1d3ffc2ce | |||
| 46b9df54bf | |||
| 3c0c3b3f6e | |||
| 5395d53332 | |||
| ec08032e98 | |||
| cc5eca5553 | |||
| 1323183cce | |||
| 009be05d22 | |||
| 860ffc1dee | |||
| c515f95d17 | |||
| 855bf8610a | |||
| 742edc4a79 | |||
| 1975a23aab | |||
| 80c8d9c602 | |||
| 948c9ef57b | |||
| bac968c0bf | |||
| 520562ef86 | |||
| 001253c39b | |||
| 5345b50d17 | |||
| a3622e91b6 | |||
| be305c3daf | |||
| ec78cfbdd0 | |||
| 8023be452a | |||
| 5112c96c05 | |||
| 04b1fb72bb | |||
| a9d11ccb2e | |||
| 848e3f90e1 | |||
| e83b6741ad | |||
| 0a3d93b59b | |||
| 102e2141ec | |||
| 768fd6f439 | |||
| 231a610466 | |||
| 7db5ec0721 | |||
| a2b9d96e86 | |||
| e0022c12c4 | |||
| 66b8f2c906 |
@@ -1,2 +1,3 @@
|
|||||||
|
patreon: mauriceboe
|
||||||
ko_fi: mauriceboe
|
ko_fi: mauriceboe
|
||||||
buy_me_a_coffee: mauriceboe
|
buy_me_a_coffee: mauriceboe
|
||||||
|
|||||||
@@ -0,0 +1,156 @@
|
|||||||
|
name: Set up Node and the workspaces
|
||||||
|
description: >-
|
||||||
|
Node from .nvmrc, the workspace dependencies from an exact cache or npm ci,
|
||||||
|
and optionally shared/dist from a cache or a build. Runs after checkout.
|
||||||
|
|
||||||
|
# A local action, so it is versioned with the workflow that calls it and needs
|
||||||
|
# no SHA pin. scripts/ci/changed-areas.mjs counts .github/actions/ like
|
||||||
|
# test.yml: a change here runs everything.
|
||||||
|
#
|
||||||
|
# node_modules is restored only on an exact key: the runner image, the scope,
|
||||||
|
# the Node ABI, the lockfile and every workspace package.json. There are no
|
||||||
|
# restore-keys, so a hit is the tree npm ci would build and a miss is a plain
|
||||||
|
# npm ci. The package.json files are in the key because npm ci is also the
|
||||||
|
# check that they agree with the lockfile: an edited range without a fresh
|
||||||
|
# lockfile misses the cache and fails the install, as it did when every job
|
||||||
|
# ran npm ci. Only pushes to dev and main save, the npm download cache
|
||||||
|
# included, so pull requests read what their base left and cannot evict it or
|
||||||
|
# fill the repository's cache quota with entries of their own.
|
||||||
|
|
||||||
|
inputs:
|
||||||
|
scope:
|
||||||
|
description: >-
|
||||||
|
Which workspaces to install: full (npm ci), client (shared and client)
|
||||||
|
or shared (shared alone).
|
||||||
|
required: true
|
||||||
|
build-shared:
|
||||||
|
description: "'true' to restore shared/dist, or build it on a miss."
|
||||||
|
required: false
|
||||||
|
default: 'false'
|
||||||
|
|
||||||
|
runs:
|
||||||
|
using: composite
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-node@v6
|
||||||
|
with:
|
||||||
|
node-version-file: .nvmrc
|
||||||
|
|
||||||
|
# ImageOS and ImageVersion name the runner image, whose system libraries
|
||||||
|
# the native modules were built against. They live in the runner's
|
||||||
|
# environment, not in the env context, so the key is put together here. A
|
||||||
|
# job in a container has neither; the container's OS release stands in,
|
||||||
|
# and that job's tree is kept apart from the runner's.
|
||||||
|
- name: Work out the cache keys
|
||||||
|
id: keys
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SCOPE: ${{ inputs.scope }}
|
||||||
|
DEPS: ${{ hashFiles('.nvmrc', 'package-lock.json', 'package.json', 'client/package.json', 'server/package.json', 'shared/package.json') }}
|
||||||
|
SHARED: ${{ hashFiles('shared/src/**', 'shared/package.json', 'shared/tsconfig*.json', 'shared/tsdown.config.ts', 'package-lock.json') }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
case "$SCOPE" in
|
||||||
|
full | client | shared) ;;
|
||||||
|
*) echo "::error::scope must be full, client or shared, not '$SCOPE'"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
if [ -n "${ImageOS:-}" ]; then
|
||||||
|
image="$ImageOS-${ImageVersion:-unknown}"
|
||||||
|
else
|
||||||
|
image="container-$(. /etc/os-release && echo "$ID$VERSION_ID")"
|
||||||
|
fi
|
||||||
|
abi="$(node -p process.versions.modules)"
|
||||||
|
echo "nm=nm-$RUNNER_OS-$image-$SCOPE-node$abi-$DEPS" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "sd=sd-$RUNNER_OS-$SHARED" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "save=${{ github.event_name == 'push' && (github.ref == 'refs/heads/dev' || github.ref == 'refs/heads/main') }}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
- name: Restore node_modules
|
||||||
|
id: nm
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
node_modules
|
||||||
|
server/node_modules
|
||||||
|
client/node_modules
|
||||||
|
shared/node_modules
|
||||||
|
key: ${{ steps.keys.outputs.nm }}
|
||||||
|
|
||||||
|
# The npm download cache only matters when npm ci runs, so it is restored
|
||||||
|
# only then. It may fall back to an older lockfile's cache: npm ci checks
|
||||||
|
# every tarball against the lockfile's integrity hash and fetches what is
|
||||||
|
# missing, so a stale entry only costs downloads.
|
||||||
|
- name: Restore the npm download cache
|
||||||
|
id: npm
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true'
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
||||||
|
restore-keys: npm-${{ runner.os }}-
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
env:
|
||||||
|
SCOPE: ${{ inputs.scope }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
# better-sqlite3 ships no prebuilt binary and compiles on install. The
|
||||||
|
# hosted runners carry a compiler; the Playwright container of the e2e
|
||||||
|
# jobs does not, so on a cache miss there it gets one first. A hit,
|
||||||
|
# the usual case once a push to dev has saved the container's key,
|
||||||
|
# never reaches this step.
|
||||||
|
if ! command -v make >/dev/null || ! command -v g++ >/dev/null; then
|
||||||
|
export DEBIAN_FRONTEND=noninteractive
|
||||||
|
timeout 300 apt-get update -qq
|
||||||
|
timeout 300 apt-get install -y -qq --no-install-recommends make g++
|
||||||
|
fi
|
||||||
|
case "$SCOPE" in
|
||||||
|
full) npm ci ;;
|
||||||
|
# The scoped install keeps @testing-library/dom (a peer of
|
||||||
|
# @testing-library/react) in the tree.
|
||||||
|
client) npm ci --workspace shared --workspace client ;;
|
||||||
|
shared) npm ci --workspace shared ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
- name: Save node_modules
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true' && steps.keys.outputs.save == 'true'
|
||||||
|
uses: actions/cache/save@v6
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
node_modules
|
||||||
|
server/node_modules
|
||||||
|
client/node_modules
|
||||||
|
shared/node_modules
|
||||||
|
key: ${{ steps.keys.outputs.nm }}
|
||||||
|
|
||||||
|
# Only a full install saves the download cache, so the entry holds every
|
||||||
|
# tarball; a scoped job that finished first would otherwise claim the key
|
||||||
|
# with part of the tree and no later run would fill it.
|
||||||
|
- name: Save the npm download cache
|
||||||
|
if: steps.nm.outputs.cache-hit != 'true' && steps.keys.outputs.save == 'true' && steps.npm.outputs.cache-hit != 'true' && inputs.scope == 'full'
|
||||||
|
uses: actions/cache/save@v6
|
||||||
|
with:
|
||||||
|
path: ~/.npm
|
||||||
|
key: npm-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
||||||
|
|
||||||
|
# The key holds every input of the build: the sources, the package and
|
||||||
|
# build configs, and the lockfile that pins tsdown and zod.
|
||||||
|
- name: Restore shared/dist
|
||||||
|
id: sd
|
||||||
|
if: inputs.build-shared == 'true'
|
||||||
|
uses: actions/cache/restore@v6
|
||||||
|
with:
|
||||||
|
path: shared/dist
|
||||||
|
key: ${{ steps.keys.outputs.sd }}
|
||||||
|
|
||||||
|
- name: Build shared
|
||||||
|
if: inputs.build-shared == 'true' && steps.sd.outputs.cache-hit != 'true'
|
||||||
|
shell: bash
|
||||||
|
run: npm run build --workspace=shared
|
||||||
|
|
||||||
|
- name: Save shared/dist
|
||||||
|
if: inputs.build-shared == 'true' && steps.sd.outputs.cache-hit != 'true' && steps.keys.outputs.save == 'true'
|
||||||
|
uses: actions/cache/save@v6
|
||||||
|
with:
|
||||||
|
path: shared/dist
|
||||||
|
key: ${{ steps.keys.outputs.sd }}
|
||||||
+30
-1
@@ -7,8 +7,11 @@
|
|||||||
# enforce-target-branch.yml moves those onto dev.
|
# enforce-target-branch.yml moves those onto dev.
|
||||||
#
|
#
|
||||||
# Every PR runs test.yml like any other, so ci-ok decides whether it can
|
# Every PR runs test.yml like any other, so ci-ok decides whether it can
|
||||||
# merge. Dependabot runs get no Actions secrets, so s3-contract and the Sonar
|
# merge. Dependabot runs get no Actions secrets, so server-s3 and the Sonar
|
||||||
# scan skip themselves on these PRs and ci-ok counts the skip as passed.
|
# scan skip themselves on these PRs and ci-ok counts the skip as passed.
|
||||||
|
# A bump of @playwright/test also needs the Playwright container tag and
|
||||||
|
# digest in test.yml's client-e2e moved by hand; workflow-jobs.test.mjs
|
||||||
|
# fails the PR until they match.
|
||||||
version: 2
|
version: 2
|
||||||
updates:
|
updates:
|
||||||
# The root lockfile covers the client, server and shared workspaces.
|
# The root lockfile covers the client, server and shared workspaces.
|
||||||
@@ -23,8 +26,34 @@ updates:
|
|||||||
prefix: chore(deps)
|
prefix: chore(deps)
|
||||||
prefix-development: chore(deps-dev)
|
prefix-development: chore(deps-dev)
|
||||||
groups:
|
groups:
|
||||||
|
# Packages that release in lockstep move together, so a PR never pins
|
||||||
|
# half of them on one version and half on the next.
|
||||||
|
mikro-orm:
|
||||||
|
patterns: ['@mikro-orm/*']
|
||||||
|
update-types: [minor, patch]
|
||||||
|
nestjs:
|
||||||
|
patterns: ['@nestjs/*']
|
||||||
|
update-types: [minor, patch]
|
||||||
npm-minor-and-patch:
|
npm-minor-and-patch:
|
||||||
update-types: [minor, patch]
|
update-types: [minor, patch]
|
||||||
|
ignore:
|
||||||
|
# nestjs-zod, which validates every request body, does not support
|
||||||
|
# NestJS 12 yet. The framework moves by hand once it does.
|
||||||
|
- dependency-name: '@nestjs/*'
|
||||||
|
update-types: [version-update:semver-major]
|
||||||
|
# TypeScript 7 is the native compiler and has no JavaScript API yet:
|
||||||
|
# typescript-eslint, the coverage instrumenter and the Postgres probe all
|
||||||
|
# call into it (readConfigFile, ScriptTarget). It moves by hand once the
|
||||||
|
# tooling supports it.
|
||||||
|
- dependency-name: typescript
|
||||||
|
update-types: [version-update:semver-major]
|
||||||
|
# mapbox-gl 3.33 and later read the worker registry key before handling
|
||||||
|
# Set and Error, and maplibre-gl, bundled beside it, stamps that key on
|
||||||
|
# both built-ins: every vector tile then fails with "reading 'omit'".
|
||||||
|
# glWorkerRegistry.test.ts fails on a version with that order; it moves
|
||||||
|
# by hand once mapbox-gl checks the built-ins first again.
|
||||||
|
- dependency-name: mapbox-gl
|
||||||
|
versions: ['>=3.33.0']
|
||||||
|
|
||||||
# plugin-sdk is standalone with a lockfile of its own and ships to npm.
|
# plugin-sdk is standalone with a lockfile of its own and ships to npm.
|
||||||
- package-ecosystem: npm
|
- package-ecosystem: npm
|
||||||
|
|||||||
@@ -18,9 +18,16 @@ jobs:
|
|||||||
- uses: actions/setup-node@v6
|
- uses: actions/setup-node@v6
|
||||||
with:
|
with:
|
||||||
node-version-file: .nvmrc
|
node-version-file: .nvmrc
|
||||||
|
cache: npm
|
||||||
|
cache-dependency-path: package-lock.json
|
||||||
|
|
||||||
|
# shared's ESLint and Prettier plugins are its own devDependencies, and
|
||||||
|
# the format ratchet in scripts/lib/ resolves prettier from the root, so
|
||||||
|
# shared plus the root is the whole tree these checks read. npm ci
|
||||||
|
# installs exactly what the lockfile says, where npm install could
|
||||||
|
# resolve anew.
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: npm install
|
run: npm ci --workspace shared --include-workspace-root
|
||||||
|
|
||||||
- name: Run lint & format check
|
- name: Run lint & format check
|
||||||
# Both are check-only: lint used to run eslint --fix, which rewrote the
|
# Both are check-only: lint used to run eslint --fix, which rewrote the
|
||||||
|
|||||||
@@ -10,6 +10,13 @@ permissions:
|
|||||||
#
|
#
|
||||||
# Unsigned on purpose: signing and store uploads need secrets that fork PRs do
|
# Unsigned on purpose: signing and store uploads need secrets that fork PRs do
|
||||||
# not get, and belong in a release workflow of their own.
|
# not get, and belong in a release workflow of their own.
|
||||||
|
#
|
||||||
|
# package-lock.json is not a trigger: every dependency bump touches it, and a
|
||||||
|
# Mac build per bump only held the queue. The shells link nothing but the
|
||||||
|
# @capacitor/* packages, all declared in client/package.json, and a Dependabot
|
||||||
|
# bump of one of them raises the range there too, so it still runs. The client
|
||||||
|
# typecheck and the watch and widget snapshot tests run in test.yml on every
|
||||||
|
# change under client/.
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
paths:
|
paths:
|
||||||
@@ -24,7 +31,6 @@ on:
|
|||||||
- 'client/scripts/check-store-metadata.mjs'
|
- 'client/scripts/check-store-metadata.mjs'
|
||||||
- 'client/fastlane/**'
|
- 'client/fastlane/**'
|
||||||
- 'client/package.json'
|
- 'client/package.json'
|
||||||
- 'package-lock.json'
|
|
||||||
- 'shared/src/i18n/*/native.ts'
|
- 'shared/src/i18n/*/native.ts'
|
||||||
- '.github/workflows/native.yml'
|
- '.github/workflows/native.yml'
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
@@ -182,34 +188,6 @@ jobs:
|
|||||||
path: client/ios/WidgetPreviews/out
|
path: client/ios/WidgetPreviews/out
|
||||||
retention-days: 14
|
retention-days: 14
|
||||||
|
|
||||||
# The watch's half in the UI (client/src/native/watch.ts): the snapshot it
|
|
||||||
# builds and the ticks it takes back, typechecked and tested here as well,
|
|
||||||
# so a change to the bridge is checked next to the Swift that reads it.
|
|
||||||
watch-bridge:
|
|
||||||
runs-on: ubuntu-24.04
|
|
||||||
timeout-minutes: 15
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v6
|
|
||||||
|
|
||||||
- uses: actions/setup-node@v6
|
|
||||||
with:
|
|
||||||
node-version-file: .nvmrc
|
|
||||||
cache: npm
|
|
||||||
|
|
||||||
- name: Install
|
|
||||||
run: npm ci --workspace=shared --workspace=client
|
|
||||||
|
|
||||||
- name: Build shared
|
|
||||||
run: npm run build --workspace=shared
|
|
||||||
|
|
||||||
- name: Typecheck the client
|
|
||||||
working-directory: client
|
|
||||||
run: npm run typecheck
|
|
||||||
|
|
||||||
- name: Test the widget and watch snapshots
|
|
||||||
working-directory: client
|
|
||||||
run: npx vitest run src/native/watch.test.ts src/native/widgets.test.ts src/native/widgetExtras.test.ts
|
|
||||||
|
|
||||||
# The watch app on watchOS simulators in its screenshot mode (DemoMode.swift):
|
# The watch app on watchOS simulators in its screenshot mode (DemoMode.swift):
|
||||||
# every screen on the largest and the smallest watch, the main ones in every
|
# every screen on the largest and the smallest watch, the main ones in every
|
||||||
# language, and the complications, as PNGs to look at without a watch.
|
# language, and the complications, as PNGs to look at without a watch.
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ name: Security Scan
|
|||||||
# - scout scans the built image, base image packages included. It needs
|
# - scout scans the built image, base image packages included. It needs
|
||||||
# the Docker Hub login, so it runs on PRs and pushes into main only and
|
# the Docker Hub login, so it runs on PRs and pushes into main only and
|
||||||
# skips fork PRs. Whether the image builds at all is test.yml's
|
# skips fork PRs. Whether the image builds at all is test.yml's
|
||||||
# docker-image job, which a red scan cannot hide.
|
# docker job, which a red scan cannot hide.
|
||||||
on:
|
on:
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [main, dev]
|
branches: [main, dev]
|
||||||
@@ -79,7 +79,7 @@ jobs:
|
|||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- uses: docker/scout-action@e7e2a72bf1485d10a58f30696b6c513b261ce4fa # v1.29.0
|
- uses: docker/scout-action@b265cd48f8a1451d2680815b3e8dc4ed65ee16e7 # v1.30.0
|
||||||
with:
|
with:
|
||||||
command: cves
|
command: cves
|
||||||
image: trek:scan
|
image: trek:scan
|
||||||
|
|||||||
+943
-745
File diff suppressed because it is too large
Load Diff
@@ -31,6 +31,7 @@ Tests:
|
|||||||
npm run test # all workspaces
|
npm run test # all workspaces
|
||||||
npm run test --workspace=server # vitest run (server); also test:unit / test:integration / test:ws
|
npm run test --workspace=server # vitest run (server); also test:unit / test:integration / test:ws
|
||||||
npm run test:e2e # server e2e (boots Nest against a temp SQLite)
|
npm run test:e2e # server e2e (boots Nest against a temp SQLite)
|
||||||
|
npm run test:pg --workspace=server # the Postgres lane (vitest.pg.config.ts; needs TREK_TEST_DB_URL, e.g. postgres://postgres:trek@127.0.0.1:55432/postgres)
|
||||||
npm run test:cov # coverage (lcov) for all four packages incl. plugin-sdk
|
npm run test:cov # coverage (lcov) for all four packages incl. plugin-sdk
|
||||||
cd client && npm run test # client vitest run
|
cd client && npm run test # client vitest run
|
||||||
cd client && npm run e2e # Playwright (CI runs the public and app projects; the screenshot and help-media ones are local)
|
cd client && npm run e2e # Playwright (CI runs the public and app projects; the screenshot and help-media ones are local)
|
||||||
@@ -51,7 +52,9 @@ cd client && npm run lint:skips # no .only; skipped tests may
|
|||||||
cd client && npm run lint:i18n-keys # every key the client names exists in en; unused en keys may only shrink (CI gate)
|
cd client && npm run lint:i18n-keys # every key the client names exists in en; unused en keys may only shrink (CI gate)
|
||||||
cd server && npm run lint:boundaries # no new import cycles or cross-domain reach-ins (CI gate)
|
cd server && npm run lint:boundaries # no new import cycles or cross-domain reach-ins (CI gate)
|
||||||
cd server && npm run lint:dialect # SQLite-only SQL spellings may only shrink (CI gate; rules in server/CLAUDE.md)
|
cd server && npm run lint:dialect # SQLite-only SQL spellings may only shrink (CI gate; rules in server/CLAUDE.md)
|
||||||
|
cd server && npm run lint:engine-dispatch # engine checks outside src/db/dialect/ and src/db/engine/ may only shrink (CI gate)
|
||||||
cd server && npm run probe:pg # dialect helpers + the repository statements it reaches against Postgres (CI job; needs TREK_PG_PROBE_URL)
|
cd server && npm run probe:pg # dialect helpers + the repository statements it reaches against Postgres (CI job; needs TREK_PG_PROBE_URL)
|
||||||
|
cd server && npm run check:pg-baseline # the Postgres baseline in server/assets/postgres/ matches the entities and the migrations (CI gate)
|
||||||
cd server && npm run lint:tx # no new method writing twice outside one transaction (CI gate)
|
cd server && npm run lint:tx # no new method writing twice outside one transaction (CI gate)
|
||||||
cd server && npm run lint:test-sql # raw SQL fixtures in tests/ may only shrink; seed through tests/helpers/factories (CI gate)
|
cd server && npm run lint:test-sql # raw SQL fixtures in tests/ may only shrink; seed through tests/helpers/factories (CI gate)
|
||||||
cd server && npm run lint:test-mocks # vi.mock of config, realtime and db modules in tests/ may only shrink (CI gate)
|
cd server && npm run lint:test-mocks # vi.mock of config, realtime and db modules in tests/ may only shrink (CI gate)
|
||||||
@@ -134,13 +137,18 @@ These principles come out of a full-repo audit and shape all new code:
|
|||||||
|
|
||||||
## Quality gates in CI
|
## Quality gates in CI
|
||||||
|
|
||||||
`.github/workflows/test.yml` runs, per package: typecheck (server also `typecheck:tests`, client also the strict-mode ratchet `lint:strict`), lint (client and server through `lint:warnings`, which also holds the warning count per rule), `lint:pages`, `lint:rtl`, `lint:size` (client and server), the server's `lint:strict`, `lint:boundaries`, `lint:tx`, `lint:dialect`, `lint:test-sql`, `lint:test-mocks`, `lint:test-new-service`, `lint:query-api`, `lint:mcp-zod`, `lint:service-http` and `lint:response-contracts`, the client's and server's `lint:format`, `lint:layers`, `lint:offline`, `lint:dup`, `lint:pairs`, `lint:skips`, `lint:i18n-keys` and `theme:lint`, shared's `contracts:open`, the repo-wide `lint:knip` (in server-lint-checks), `check:plugin-facts`, `i18n:parity:strict` (with the untranslated-strings ratchet), the S3 contract suite, the Postgres probe (`postgres-probe`: every dialect helper on SQLite and Postgres, and the statements every repository method reaches with sample arguments against a Postgres service; the SQL errors per method and the list of methods it cannot measure are held to a baseline that only shrinks and fails while it is still unmeasured; see `server/CLAUDE.md`), the browser end-to-end flows (Chromium and WebKit), a client build with `check:gl-split`, coverage for all four packages, then a SonarCloud scan. It also builds the Docker image and boots it until `/api/health/ready` answers (`docker-image`), and lints and renders the Helm chart against the Kubernetes schemas and runs `docker compose config` on every compose file (`deploy-manifests`). `lint-prettier.yml` additionally runs `lint` + `lint:format` on `shared/`, both check-only. `plugin-sdk` has no lint script and is outside the eslint gates. **Not in CI**: the screenshot and help-media Playwright projects; run them locally. There are no git hooks; nothing runs before a commit except you. Other workflows build Docker images, scan them, and publish `trek-plugin-sdk` on `plugin-sdk-v*` tags.
|
`.github/workflows/test.yml` runs, per package: typecheck (server also `typecheck:tests`, client also the strict-mode ratchet `lint:strict`), lint (client and server through `lint:warnings`, which also holds the warning count per rule), `lint:pages`, `lint:rtl`, `lint:size` (client and server), the server's `lint:strict`, `lint:boundaries`, `lint:tx`, `lint:dialect`, `lint:engine-dispatch`, `lint:test-sql`, `lint:test-mocks`, `lint:test-new-service`, `lint:query-api`, `lint:mcp-zod`, `lint:service-http` and `lint:response-contracts`, the client's and server's `lint:format`, `lint:layers`, `lint:offline`, `lint:dup`, `lint:pairs`, `lint:skips`, `lint:i18n-keys` and `theme:lint`, shared's `contracts:open`, the repo-wide `lint:knip` (in `server-lint`), `check:plugin-facts`, `i18n:parity:strict` (with the untranslated-strings ratchet), the S3 contract suite, TREK on Postgres (`server-postgres`, once per supported major, 14 and 18, each in three slices: first the Postgres probe (in the first slice), every dialect helper on SQLite and Postgres and the statements every repository method reaches with sample arguments, its SQL errors per method and the methods it cannot measure held to a baseline that only shrinks and fails while it is still unmeasured; then the Postgres lane, every suite that boots the app on the real database module, found by `server/tests/postgres/lane.ts` rather than listed, plus PARITY-PG and the write lock; see `server/CLAUDE.md`), the browser end-to-end flows (Chromium and WebKit, in the Playwright container, in two slices), a client build with `check:gl-split`, coverage for all four packages, then a SonarCloud scan. It also builds the Docker image and boots it until `/api/health/ready` answers, on SQLite and on Postgres 18, and lints and renders the Helm chart against the Kubernetes schemas and runs `docker compose config` on every compose file (both in `docker`, each part when its area changed). `lint-prettier.yml` additionally runs `lint` + `lint:format` on `shared/`, both check-only. `plugin-sdk` has no lint script and is outside the eslint gates. **Not in CI**: the screenshot and help-media Playwright projects; run them locally. There are no git hooks; nothing runs before a commit except you. Other workflows build Docker images, scan them, and publish `trek-plugin-sdk` on `plugin-sdk-v*` tags.
|
||||||
|
|
||||||
- **Job names read "package: what"** (`Server: Types`, `Client: Tests 3/7`), and the list at the top of `test.yml` says what each job holds. A new job follows the scheme and joins that list, and the job-count note there says when a long job needs a slot freed first.
|
- **Job names read "<Area> <what>[ <variant>][ i/n]"** (`Server tests 3/10`, `Server Postgres 14 2/3`, `Docker and Helm`): the area first, one of Changes, Shared, Server, Client, Docker or Sonar, then lower case, with no colon, no parentheses and no middle dot, and a slice only at the end, so the checks list sorts by area. The workflow is named `CI`, so a check reads `CI / Server tests 3/10`. Job ids are the names in kebab-case (`server-tests`), the jobs stand in `test.yml` in area order, and the list at the top of `test.yml` says what each job holds. A new job follows the scheme and joins that list; `scripts/ci/workflow-jobs.test.mjs` fails on a name outside it. `ci-ok`, `lint` and `check-target` keep their names: the ruleset requires them by name.
|
||||||
- **Tests run beside the gates, in shards.** The client and server suites run in slices on parallel runners (`client-tests`, `server-tests`, through each package's `vitest.shard.config.ts`), and `client-coverage`/`server-coverage` merge their blob reports and check the thresholds against the whole. A red slice is usually a failing test, a red merge job usually a threshold.
|
- **What the folded jobs hold.** `Shared tests` is the plugin SDK's typecheck and coverage, run before the root install so the SDK resolves only its own dependencies, then i18n parity and shared's coverage. `Client types` is the typecheck and the strict ratchet; `Client checks` the source ratchets, then the production build with `check:gl-split`. `Docker and Helm` builds and boots the image when the image area changed and checks the chart and compose files when the deploy area changed. Inside a folded job each group of steps runs after a failure in another, so one red check shows every gate that failed; the step names say which.
|
||||||
- **`ci-ok` is the required check.** The branch ruleset requires `ci-ok` (plus `lint` and `check-target` from their own workflows), and `ci-ok` needs every job above except the scan. It fails if any of them failed or was cancelled and passes if they passed or were skipped. A new gate job counts only once it is listed in `ci-ok`'s `needs:`.
|
- **Tests run beside the gates, in shards.** The client and server suites run in ten slices each on parallel runners (`client-tests`, `server-tests`, through each package's `vitest.shard.config.ts`), the Postgres lane in three per major, and the end-to-end flows in two, and `client-coverage`/`server-coverage` merge their blob reports and check the thresholds against the whole. A red slice is usually a failing test, a red merge job usually a threshold. A sliced job states its slice count in its matrix's shard axis, the `i/n` in its name and its `--shard=i/n`; `scripts/ci/workflow-jobs.test.mjs` fails until all three agree, and on any job naming `matrix.shard` or `--shard` whose axis is not the one-line `shard: [1, ..., n]` it reads.
|
||||||
|
- **`ci-ok` is the required check.** The branch ruleset requires `ci-ok` (plus `lint` and `check-target` from their own workflows), and `ci-ok` needs every job above except the scan. It fails if any of them failed or was cancelled and passes if they passed or were skipped. A new gate job counts only once it is listed in `ci-ok`'s `needs:`, and `scripts/ci/workflow-jobs.test.mjs` (in `test:ci-scripts`) fails while a job other than the scan is missing there.
|
||||||
|
- **The release pull request mirrors the push run.** On the pull request from `dev` into `main` (head branch in this repository), `changes` sets `mirror` and turns every area off (`scripts/ci/changed-areas.mjs`), so no test, gate or scan job runs, and `ci-ok` runs `scripts/ci/mirror-push-run.mjs`: it waits for the `ci-ok` of the push run of `test.yml` on `dev` for exactly the PR's head commit and passes or fails with it. No such push run, one that ended without a verdict, or a wait past 17 minutes fails with a re-run hint, never passes. A push to `dev` lists its changes against the merge base with `main`, not against the previous push, so the run it mirrors covers every area the pull request brings in, even when an earlier push's run was cancelled or red. Testing that commit twice doubled the jobs past the 60 slots.
|
||||||
- **Guides name paths that exist**: the `changes` job runs `scripts/ci/doc-paths.mjs`, which resolves every backtick path in the CLAUDE.md files, `README.md`, `server/src/nest/README.md` and the wiki against the tracked files; the missing ones are listed in `scripts/ci/doc-paths-baseline.json`, which only shrinks (`--update` after a fix).
|
- **Guides name paths that exist**: the `changes` job runs `scripts/ci/doc-paths.mjs`, which resolves every backtick path in the CLAUDE.md files, `README.md`, `server/src/nest/README.md` and the wiki against the tracked files; the missing ones are listed in `scripts/ci/doc-paths-baseline.json`, which only shrinks (`--update` after a fix).
|
||||||
- **What runs is decided by `changes`, not by `on.paths`**: `scripts/ci/changed-areas.mjs` maps the changed files to the `code`, `image` and `deploy` areas (tests: `npm run test:ci-scripts`). A path filter on the workflow would leave `ci-ok` unreported on a docs-only PR and block it. Add a new top-level file the build reads to the right area there.
|
- **What runs is decided by `changes`, not by `on.paths`**: `scripts/ci/changed-areas.mjs` maps the changed files to the `code`, `image` and `deploy` areas (tests: `npm run test:ci-scripts`). A path filter on the workflow would leave `ci-ok` unreported on a docs-only PR and block it. Add a new top-level file the build reads to the right area there. A change to `test.yml`, to `scripts/ci/` or to a local action under `.github/actions/` runs everything.
|
||||||
|
- **Setup goes through one local action.** Every job that installs dependencies uses `.github/actions/setup/action.yml` (`scope` full, client or shared; `build-shared`) instead of its own `npm ci`; `workflow-jobs.test.mjs` fails on a job that installs on its own (plugin-sdk's own install in its directory excepted). The action restores node_modules on an exact key (runner image, scope, Node ABI, `.nvmrc`, the lockfile and every workspace `package.json`, so npm ci still refuses a `package.json` out of step with the lockfile; no restore-keys) and shared/dist on a key over shared's sources and build config, and runs `npm ci` or the shared build on a miss. Only pushes to dev and main save, the npm download cache included; pull requests only read.
|
||||||
|
- **End-to-end runs in the Playwright container**, `mcr.microsoft.com/playwright:v<version>-noble` pinned by digest, so no step installs browsers or system libraries. Dependabot bumps only the lockfile: on every Playwright PR move the tag and its digest in `client-e2e` by hand (`docker buildx imagetools inspect mcr.microsoft.com/playwright:v<version>-noble`); `workflow-jobs.test.mjs` fails until the tag names the lockfile's `@playwright/test` version.
|
||||||
|
- **Budget: `ci-ok` within ten minutes.** One code run starts at most about 35 long jobs (gates, slices, Postgres, e2e, Docker), so two PR runs fit in the organisation's 60 concurrent jobs. Every job sets `timeout-minutes` of at most 20 (15 for the long ones, 10 for the short ones), which `workflow-jobs.test.mjs` holds. A new long job, slice or shard needs a reason that outweighs its slot; the job-count note at the top of `test.yml` has the numbers.
|
||||||
- **Runners and Node**: jobs run on `ubuntu-24.04`, not `ubuntu-latest`, and every `setup-node` reads `.nvmrc`. Third-party actions (anything outside `actions/*`) are pinned by commit SHA with the tag in a comment; Dependabot keeps both current.
|
- **Runners and Node**: jobs run on `ubuntu-24.04`, not `ubuntu-latest`, and every `setup-node` reads `.nvmrc`. Third-party actions (anything outside `actions/*`) are pinned by commit SHA with the tag in a comment; Dependabot keeps both current.
|
||||||
- **Security scans are advisory.** `security.yml` runs `npm audit` (what the image installs, plus `plugin-sdk`) on every PR and push into dev and main, and Docker Scout on the built image for main. Neither is required: a newly published advisory would turn every open PR red at once. Fixes are held as floors in the root `package.json` `overrides`; npm ignores an `overrides` block in a workspace `package.json`, so never put one there.
|
- **Security scans are advisory.** `security.yml` runs `npm audit` (what the image installs, plus `plugin-sdk`) on every PR and push into dev and main, and Docker Scout on the built image for main. Neither is required: a newly published advisory would turn every open PR red at once. Fixes are held as floors in the root `package.json` `overrides`; npm ignores an `overrides` block in a workspace `package.json`, so never put one there.
|
||||||
- **Releases** are dispatched by hand and refuse a commit whose `ci-ok` is not green. `docker-dev.yml` (any branch, usually dev) is the canary: it builds the dispatched commit as the next minor or major `-pre.N` and moves only `:latest-pre` and `:<major>-pre`. `docker.yml` (main only) bumps the version, commits and tags it, builds both platforms from exactly that commit and moves `:latest`, `:<major>`, `:<major>.<minor>` and `:<version>`. Its `bump=auto` only finalizes a prerelease in flight; without one it stops and asks for patch, minor or major. Ship a release that migrates or changes a lot as a prerelease first, and as a minor, so installs pinned to `:<major>.<minor>` can wait it out.
|
- **Releases** are dispatched by hand and refuse a commit whose `ci-ok` is not green. `docker-dev.yml` (any branch, usually dev) is the canary: it builds the dispatched commit as the next minor or major `-pre.N` and moves only `:latest-pre` and `:<major>-pre`. `docker.yml` (main only) bumps the version, commits and tags it, builds both platforms from exactly that commit and moves `:latest`, `:<major>`, `:<major>.<minor>` and `:<version>`. Its `bump=auto` only finalizes a prerelease in flight; without one it stops and asks for patch, minor or major. Ship a release that migrates or changes a lot as a prerelease first, and as a minor, so installs pinned to `:<major>.<minor>` can wait it out.
|
||||||
|
|||||||
+26
-10
@@ -72,30 +72,46 @@ COPY server/package.json ./server/
|
|||||||
# package, and a telemetry ping.
|
# package, and a telemetry ping.
|
||||||
# The upgrade takes the Debian security fixes the base image was built before
|
# The upgrade takes the Debian security fixes the base image was built before
|
||||||
# (zlib, 11/2026, failed the image scan until node:24-trixie-slim caught up).
|
# (zlib, 11/2026, failed the image scan until node:24-trixie-slim caught up).
|
||||||
RUN apt-get update && \
|
#
|
||||||
|
# postgresql-client-18 brings pg_dump, pg_restore and psql to
|
||||||
|
# /usr/lib/postgresql/18/bin, which back up and restore an install on Postgres
|
||||||
|
# (TREK_DB_URL). A client handles every server up to its own major and refuses
|
||||||
|
# a newer one, so the image carries the newest major TREK supports (14 to 18).
|
||||||
|
# Debian 13 ships 17 only, so it comes from the PostgreSQL project's apt
|
||||||
|
# repository (PGDG): the `18` component lists that major's packages and no
|
||||||
|
# other, and the repository's signing key (fingerprint B97B 0AFC AA1A 47F0 44F2
|
||||||
|
# 44A0 7FCC 7D46 ACCC 4CF8) is kept beside the entrypoint instead of fetched at
|
||||||
|
# build time. Raise both together when TREK supports a newer major.
|
||||||
|
COPY server/scripts/pgdg-apt-key.asc /etc/apt/keyrings/pgdg.asc
|
||||||
|
RUN echo 'deb [signed-by=/etc/apt/keyrings/pgdg.asc] http://apt.postgresql.org/pub/repos/apt trixie-pgdg main 18' \
|
||||||
|
> /etc/apt/sources.list.d/pgdg.list && \
|
||||||
|
apt-get update && \
|
||||||
apt-get upgrade -y --no-install-recommends && \
|
apt-get upgrade -y --no-install-recommends && \
|
||||||
apt-get install -y --no-install-recommends tzdata dumb-init wget ca-certificates \
|
apt-get install -y --no-install-recommends tzdata dumb-init wget ca-certificates \
|
||||||
libkitinerary-bin libsqlite3-0 && \
|
libkitinerary-bin libsqlite3-0 postgresql-client-18 && \
|
||||||
npm ci --workspace=server --omit=dev --ignore-scripts && \
|
npm ci --workspace=server --omit=dev --ignore-scripts && \
|
||||||
{ ln -sf "$(find /usr/lib -name kitinerary-extractor -type f | head -1)" /usr/local/bin/kitinerary-extractor || true; } && \
|
{ ln -sf "$(find /usr/lib -name kitinerary-extractor -type f | head -1)" /usr/local/bin/kitinerary-extractor || true; } && \
|
||||||
rm -rf /var/lib/apt/lists/* /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx && \
|
rm -rf /var/lib/apt/lists/* /usr/local/lib/node_modules/npm /usr/local/bin/npm /usr/local/bin/npx && \
|
||||||
chown -R node:node /app
|
chown -R node:node /app
|
||||||
|
|
||||||
# gosu rebuilt with a current Go toolchain (stage 0) — the entrypoint script uses
|
# gosu rebuilt with a current Go toolchain (stage 0). The entrypoint drops to node
|
||||||
# it to drop to node.
|
# with setpriv since #3135; gosu stays in the image for anyone who calls it by hand.
|
||||||
COPY --from=gosu-build /out/gosu /usr/local/bin/gosu
|
COPY --from=gosu-build /out/gosu /usr/local/bin/gosu
|
||||||
|
|
||||||
ENV XDG_CACHE_HOME=/tmp/kf6-cache
|
ENV XDG_CACHE_HOME=/tmp/kf6-cache
|
||||||
# Prevent Qt from probing for a display in headless containers.
|
# Prevent Qt from probing for a display in headless containers.
|
||||||
ENV QT_QPA_PLATFORM=offscreen
|
ENV QT_QPA_PLATFORM=offscreen
|
||||||
|
# A UTF-8 locale, so Qt does not warn about the C locale on every extractor run.
|
||||||
|
ENV LANG=C.UTF-8
|
||||||
# Fixed path for both amd64 (static binary) and arm64 (symlink to apt binary).
|
# Fixed path for both amd64 (static binary) and arm64 (symlink to apt binary).
|
||||||
# Override with KITINERARY_EXTRACTOR_PATH if you install it elsewhere.
|
# Override with KITINERARY_EXTRACTOR_PATH if you install it elsewhere.
|
||||||
ENV KITINERARY_EXTRACTOR_PATH=/usr/local/bin/kitinerary-extractor
|
ENV KITINERARY_EXTRACTOR_PATH=/usr/local/bin/kitinerary-extractor
|
||||||
|
|
||||||
COPY --chown=node:node --from=server-builder /app/server/dist ./server/dist
|
COPY --chown=node:node --from=server-builder /app/server/dist ./server/dist
|
||||||
# Runtime data assets read from server/assets at runtime: airports.json (flight
|
# Runtime data assets read from server/assets at runtime: airports.json (flight
|
||||||
# transport search) and atlas/*.geojson.gz + atlas/admin1/*.geojson.gz (Atlas
|
# transport search), atlas/*.geojson.gz + atlas/admin1/*.geojson.gz (Atlas
|
||||||
# country/region map). The build
|
# country/region map) and postgres/baseline.* (the schema a fresh Postgres
|
||||||
|
# database starts from). The build
|
||||||
# only emits dist, so these must be copied explicitly or the features silently
|
# only emits dist, so these must be copied explicitly or the features silently
|
||||||
# degrade to empty in the image.
|
# degrade to empty in the image.
|
||||||
COPY --chown=node:node --from=server-builder /app/server/assets ./server/assets
|
COPY --chown=node:node --from=server-builder /app/server/assets ./server/assets
|
||||||
@@ -106,9 +122,9 @@ COPY --chown=node:node wiki ./wiki
|
|||||||
# tsconfig-paths/register reads this at runtime to resolve MCP SDK paths.
|
# tsconfig-paths/register reads this at runtime to resolve MCP SDK paths.
|
||||||
COPY --chown=node:node server/tsconfig.json ./server/
|
COPY --chown=node:node server/tsconfig.json ./server/
|
||||||
# Encryption-key rotation is run on demand via tsx (a prod dep) straight from the
|
# Encryption-key rotation is run on demand via tsx (a prod dep) straight from the
|
||||||
# raw .ts source — it never enters dist, so it must be copied in explicitly or
|
# raw .ts source (the command and its stores module). They never enter dist, so they must be copied in explicitly or
|
||||||
# `node --import tsx scripts/migrate-encryption.ts` fails with module-not-found.
|
# `node --import tsx scripts/migrate-encryption.ts` fails with module-not-found.
|
||||||
COPY --chown=node:node server/scripts/migrate-encryption.ts ./server/scripts/migrate-encryption.ts
|
COPY --chown=node:node server/scripts/migrate-encryption.ts server/scripts/migrate-encryption-stores.ts ./server/scripts/
|
||||||
# Admin recovery script (node server/reset-admin.js) for locked-out installs.
|
# Admin recovery script (node server/reset-admin.js) for locked-out installs.
|
||||||
COPY --chown=node:node server/reset-admin.js ./server/reset-admin.js
|
COPY --chown=node:node server/reset-admin.js ./server/reset-admin.js
|
||||||
COPY --chown=node:node --from=shared-builder /app/shared/dist ./shared/dist
|
COPY --chown=node:node --from=shared-builder /app/shared/dist ./shared/dist
|
||||||
@@ -159,8 +175,8 @@ HEALTHCHECK --interval=30s --timeout=5s --start-period=15s --retries=3 \
|
|||||||
# carrying quotes does not survive that round-trip (the container then dies with
|
# carrying quotes does not survive that round-trip (the container then dies with
|
||||||
# a shell syntax error before Node starts). A CMD of one bare token does.
|
# a shell syntax error before Node starts). A CMD of one bare token does.
|
||||||
COPY server/scripts/entrypoint.sh /usr/local/bin/trek-entrypoint
|
COPY server/scripts/entrypoint.sh /usr/local/bin/trek-entrypoint
|
||||||
# Root-owned on purpose — this is what calls gosu, so it runs before the drop to
|
# Root-owned on purpose: it runs as root and drops to node itself, with setpriv.
|
||||||
# node. chmod is explicit because a checkout on Windows carries no exec bit.
|
# chmod is explicit because a checkout on Windows carries no exec bit.
|
||||||
RUN chmod 0755 /usr/local/bin/trek-entrypoint
|
RUN chmod 0755 /usr/local/bin/trek-entrypoint
|
||||||
|
|
||||||
ENTRYPOINT ["dumb-init", "--"]
|
ENTRYPOINT ["dumb-init", "--"]
|
||||||
|
|||||||
@@ -20,7 +20,23 @@ geoBoundaries is licensed under **CC BY 4.0**
|
|||||||
The bundled files are simplified (coordinate-quantized) and re-tagged with the
|
The bundled files are simplified (coordinate-quantized) and re-tagged with the
|
||||||
property names TREK consumes. Country borders (`admin0`) derive from the geoBoundaries
|
property names TREK consumes. Country borders (`admin0`) derive from the geoBoundaries
|
||||||
CGAZ composite; sub-national regions (`admin1`) derive from the per-country open
|
CGAZ composite; sub-national regions (`admin1`) derive from the per-country open
|
||||||
(gbOpen) release.
|
(gbOpen) release, except for Ireland (below).
|
||||||
|
|
||||||
|
## Tailte Éireann — counties of Ireland
|
||||||
|
|
||||||
|
Ireland's regions in the same files (`admin1/IE.geojson.gz`, and its features in
|
||||||
|
`admin1.geojson.gz`) are the 26 counties from Tailte Éireann's *Counties - National
|
||||||
|
Statutory Boundaries - 2019 - Generalised 20m*, because geoBoundaries has no county
|
||||||
|
layer for Ireland.
|
||||||
|
|
||||||
|
Contains Tailte Éireann data, © Tailte Éireann, licensed under **CC BY 4.0**
|
||||||
|
(https://creativecommons.org/licenses/by/4.0/). Source:
|
||||||
|
https://data-osi.opendata.arcgis.com/
|
||||||
|
|
||||||
|
The outlines are simplified, coordinate-quantized and re-tagged with ISO 3166-2:IE
|
||||||
|
codes by `server/scripts/build-atlas-geo.mjs`. Tailte Éireann publishes the
|
||||||
|
generalised boundaries for reference only; they may not match the statutory
|
||||||
|
boundaries exactly.
|
||||||
|
|
||||||
## OpenStreetMap — geocoding, place details & descriptions
|
## OpenStreetMap — geocoding, place details & descriptions
|
||||||
|
|
||||||
|
|||||||
@@ -12,18 +12,20 @@ TREK has grown from a travel planner into a whole ecosystem for trips: plan toge
|
|||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
<a href="https://apps.apple.com/app/id6831237775"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/app/app-store-dark.svg" /><source media="(prefers-color-scheme: light)" srcset="docs/app/app-store-light.svg" /><img src="docs/app/app-store-light.svg" alt="Download TREK on the App Store, with a QR code" width="320" /></picture></a>
|
||||||
|
|
||||||
|
<a href="https://play.google.com/store/apps/details?id=com.liketrek.trek"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/app/google-play-dark.svg" /><source media="(prefers-color-scheme: light)" srcset="docs/app/google-play-light.svg" /><img src="docs/app/google-play-light.svg" alt="Get TREK on Google Play, with a QR code" width="320" /></picture></a>
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
<a href="https://demo.liketrek.com"><img alt="Demo" src="https://img.shields.io/badge/Demo-try-111827?style=for-the-badge" /></a>
|
<a href="https://demo.liketrek.com"><img alt="Demo" src="https://img.shields.io/badge/Demo-try-111827?style=for-the-badge" /></a>
|
||||||
|
|
||||||
<a href="https://hub.docker.com/r/mauriceboe/trek"><img alt="Docker" src="https://img.shields.io/badge/Docker-ready-2496ED?style=for-the-badge" /></a>
|
|
||||||
|
|
||||||
<a href="https://sonarcloud.io/project/overview?id=liketrek_TREK"><img alt="Sonar Quality Gate" src="https://img.shields.io/sonar/quality_gate/liketrek_TREK?server=https%3A%2F%2Fsonarcloud.io&style=for-the-badge" /></a>
|
|
||||||
|
|
||||||
<img alt="GitHub Actions Workflow Status" src="https://img.shields.io/github/actions/workflow/status/liketrek/TREK/test.yml?branch=main&style=for-the-badge">
|
|
||||||
|
|
||||||
<a href="https://discord.gg/NhZBDSd4qW"><img alt="Discord" src="https://img.shields.io/badge/Discord-join-5865F2?style=for-the-badge" /></a>
|
<a href="https://discord.gg/NhZBDSd4qW"><img alt="Discord" src="https://img.shields.io/badge/Discord-join-5865F2?style=for-the-badge" /></a>
|
||||||
|
|
||||||
<a href="https://kanban.pakulat.org/shared/I4wxF6inOOMB0C6hH6kQm3efyNxFjwyI"><img alt="Roadmap" src="https://img.shields.io/badge/Roadmap-view-0EA5E9?style=for-the-badge" /></a>
|
<a href="https://kanban.pakulat.org/shared/I4wxF6inOOMB0C6hH6kQm3efyNxFjwyI"><img alt="Roadmap" src="https://img.shields.io/badge/Roadmap-view-0EA5E9?style=for-the-badge" /></a>
|
||||||
|
|
||||||
|
<a href="https://www.patreon.com/cw/mauriceboe"><img alt="Patreon" src="https://img.shields.io/badge/Patreon-monthly-141518?style=for-the-badge" /></a>
|
||||||
|
|
||||||
<a href="https://ko-fi.com/mauriceboe"><img alt="Ko-fi" src="https://img.shields.io/badge/Ko--fi-support-FF5E5B?style=for-the-badge" /></a>
|
<a href="https://ko-fi.com/mauriceboe"><img alt="Ko-fi" src="https://img.shields.io/badge/Ko--fi-support-FF5E5B?style=for-the-badge" /></a>
|
||||||
|
|
||||||
<a href="https://www.buymeacoffee.com/mauriceboe"><img alt="BMAC" src="https://img.shields.io/badge/BMAC-support-FFDD00?style=for-the-badge" /></a>
|
<a href="https://www.buymeacoffee.com/mauriceboe"><img alt="BMAC" src="https://img.shields.io/badge/BMAC-support-FFDD00?style=for-the-badge" /></a>
|
||||||
@@ -36,7 +38,6 @@ TREK has grown from a travel planner into a whole ecosystem for trips: plan toge
|
|||||||
|
|
||||||
<a href="https://github.com/liketrek/TREK"><img alt="Stars" src="https://img.shields.io/github/stars/liketrek/trek?style=for-the-badge&label=Stars&color=6B7280" /></a>
|
<a href="https://github.com/liketrek/TREK"><img alt="Stars" src="https://img.shields.io/github/stars/liketrek/trek?style=for-the-badge&label=Stars&color=6B7280" /></a>
|
||||||
|
|
||||||
<sub>PUBLIC SERVICES PROUDLY SPONSORED BY</sub><br /><a href="https://cloud.dataforest.net/en?mtm_campaign=trek"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/sponsors/dataforest-light.svg" /><source media="(prefers-color-scheme: light)" srcset="docs/sponsors/dataforest-dark.svg" /><img src="docs/sponsors/dataforest-dark.svg" alt="dataforest cloud" height="30" /></picture></a>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
---
|
---
|
||||||
@@ -51,14 +52,8 @@ TREK has grown from a travel planner into a whole ecosystem for trips: plan toge
|
|||||||
|
|
||||||
## What you get
|
## What you get
|
||||||
|
|
||||||
<picture>
|
|
||||||
<source media="(max-width: 700px)" srcset="docs/tiles/grid-mobile.svg" />
|
|
||||||
<source media="(prefers-color-scheme: dark)" srcset="docs/tiles/grid-desktop-dark.svg" />
|
|
||||||
<img src="docs/tiles/grid-desktop.svg" alt="Plan, track, share" width="100%" />
|
|
||||||
</picture>
|
|
||||||
|
|
||||||
<details>
|
<details>
|
||||||
<summary><b>See all features</b></summary>
|
<summary><h3>See all features</h3></summary>
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
@@ -146,7 +141,7 @@ Most of what follows is an addon an admin switches on or off. Lists, Costs, Docu
|
|||||||
#### 🗺️ Atlas, Vacay and Collections
|
#### 🗺️ Atlas, Vacay and Collections
|
||||||
|
|
||||||
- **Atlas**: countries and regions visited on [geoBoundaries](https://www.geoboundaries.org/) outlines, a bucket list, travel stats, and a tour activities tab with planned against recorded totals
|
- **Atlas**: countries and regions visited on [geoBoundaries](https://www.geoboundaries.org/) outlines, a bucket list, travel stats, and a tour activities tab with planned against recorded totals
|
||||||
- **Vacay**: leave calendar with half days, public holidays from date.nager.at, school holidays for 16 European countries, company holidays, carry-over between years, and joint or read-only sharing
|
- **Vacay**: leave calendar with half days, public holidays from [nagerholidays.com](https://nagerholidays.com), school holidays for 16 European countries, company holidays, carry-over between years, and joint or read-only sharing
|
||||||
- **Collections** (off by default): a place library outside any trip with lists, labels, ratings, a status per place, cover images, GPX and file export, copy into a trip, and sharing by invite
|
- **Collections** (off by default): a place library outside any trip with lists, labels, ratings, a status per place, cover images, GPX and file export, copy into a trip, and sharing by invite
|
||||||
- **Dawarich** (off by default): link a Dawarich instance for recorded tracks, suggested stays and countries for the Atlas
|
- **Dawarich** (off by default): link a Dawarich instance for recorded tracks, suggested stays and countries for the Atlas
|
||||||
|
|
||||||
@@ -218,34 +213,12 @@ Most of what follows is an addon an admin switches on or off. Lists, Costs, Docu
|
|||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
## Powered by [dataforest cloud](https://cloud.dataforest.net/en?mtm_campaign=trek)
|
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<br />
|
<sub>POWERED BY</sub><br />
|
||||||
|
<a href="https://cloud.dataforest.net/en?mtm_campaign=trek"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/sponsors/dataforest-light.svg" /><source media="(prefers-color-scheme: light)" srcset="docs/sponsors/dataforest-dark.svg" /><img src="docs/sponsors/dataforest-dark.svg" alt="dataforest cloud" height="40" /></picture></a>
|
||||||
|
|
||||||
<a href="https://cloud.dataforest.net/en?mtm_campaign=trek">
|
The place index with 88 million places, the address search and the planet-wide routing run on <a href="https://cloud.dataforest.net/en?mtm_campaign=trek">dataforest cloud</a> in Frankfurt, free for every self-hosted TREK. Thank you! 💚
|
||||||
<picture>
|
|
||||||
<source media="(prefers-color-scheme: dark)" srcset="docs/sponsors/dataforest-light.svg" />
|
|
||||||
<source media="(prefers-color-scheme: light)" srcset="docs/sponsors/dataforest-dark.svg" />
|
|
||||||
<img src="docs/sponsors/dataforest-dark.svg" alt="dataforest cloud" height="60" />
|
|
||||||
</picture>
|
|
||||||
</a>
|
|
||||||
|
|
||||||
<br />
|
|
||||||
<br />
|
|
||||||
|
|
||||||
**Every TREK installation in the world searches through servers that [dataforest cloud](https://cloud.dataforest.net/en?mtm_campaign=trek) sponsors.**
|
|
||||||
|
|
||||||
The place index with over 88 million places, the address search in every TREK language and the planet-wide routing all run on [dataforest cloud](https://cloud.dataforest.net/en?mtm_campaign=trek) in Frankfurt, Germany, free of charge for everyone who self-hosts TREK. Without this sponsorship, these services would not exist in this form.
|
|
||||||
|
|
||||||
Thank you, [dataforest](https://cloud.dataforest.net/en?mtm_campaign=trek), for backing open source this generously. 💚
|
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<a href="https://cloud.dataforest.net/en?mtm_campaign=trek"><img alt="Visit dataforest cloud" src="https://img.shields.io/badge/Visit-dataforest_cloud-02C382?style=for-the-badge" /></a>
|
|
||||||
|
|
||||||
Looking for a server for your own TREK? [dataforest cloud](https://cloud.dataforest.net/en?mtm_campaign=trek) is where TREK's own services live.
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -253,13 +226,7 @@ Looking for a server for your own TREK? [dataforest cloud](https://cloud.datafor
|
|||||||
|
|
||||||
## AI usage
|
## AI usage
|
||||||
|
|
||||||
We use LLM-assisted coding tools across parts of this codebase. Nothing ships that a
|
We use LLM-assisted coding tools, and nothing ships that a maintainer has not read, reviewed, tested and can answer for. More in [How we use AI in TREK](https://github.com/liketrek/TREK/discussions/1851).
|
||||||
maintainer has not read and understood: every change goes through a pull request, is
|
|
||||||
reviewed and tested, and has a human who can answer for it. "The AI wrote that" is not
|
|
||||||
an answer any of us would accept from ourselves.
|
|
||||||
|
|
||||||
See [**How we use AI in TREK**](https://github.com/liketrek/TREK/discussions/1851) for
|
|
||||||
the details.
|
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
@@ -276,12 +243,14 @@ Open `http://localhost:3000`, or `http://<server-ip>:3000` from another machine.
|
|||||||
|
|
||||||
`COOKIE_SECURE=false` is only for trying TREK over plain HTTP: without it the browser drops the session cookie and the login does not stick. Once TREK sits behind HTTPS (see [Reverse Proxy](#reverse-proxy)), remove it.
|
`COOKIE_SECURE=false` is only for trying TREK over plain HTTP: without it the browser drops the session cookie and the login does not stick. Once TREK sits behind HTTPS (see [Reverse Proxy](#reverse-proxy)), remove it.
|
||||||
|
|
||||||
|
**TrueNAS SCALE:** Install TREK directly from the Community catalog. See the [TrueNAS SCALE installation guide](https://github.com/liketrek/TREK/wiki/Install-TrueNAS-SCALE).
|
||||||
|
|
||||||
> [!TIP]
|
> [!TIP]
|
||||||
> **No server yet?** TREK's own public services run on [**dataforest cloud**](https://cloud.dataforest.net/en?mtm_campaign=trek), our infrastructure sponsor. A small seed is plenty for a TREK instance and is ready within a minute.
|
> **No server yet?** TREK's own public services run on [**dataforest cloud**](https://cloud.dataforest.net/en?mtm_campaign=trek), our infrastructure sponsor. A small seed is plenty for a TREK instance and is ready within a minute.
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
<a href="#docker-compose-production">Docker Compose</a> · <a href="#helm-kubernetes">Helm / Kubernetes</a> · <a href="#install-as-app-pwa">Install as PWA</a> · <a href="#reverse-proxy">Reverse Proxy</a>
|
<a href="#docker-compose-production">Docker Compose</a> · <a href="#helm-kubernetes">Helm / Kubernetes</a> · <a href="#reverse-proxy">Reverse Proxy</a>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -319,6 +288,11 @@ docker compose up -d
|
|||||||
See [Install with Docker Compose](https://github.com/liketrek/TREK/wiki/Install-Docker-Compose)
|
See [Install with Docker Compose](https://github.com/liketrek/TREK/wiki/Install-Docker-Compose)
|
||||||
for the full walkthrough.
|
for the full walkthrough.
|
||||||
|
|
||||||
|
TREK stores its data in SQLite by default. Set `TREK_DB_URL` to run it on a PostgreSQL 14 to 18 database instead. The
|
||||||
|
[`docker-compose.postgres.yml`](docker-compose.postgres.yml) example starts one beside TREK, and the
|
||||||
|
[Postgres guide](https://github.com/liketrek/TREK/wiki/Database-Postgres) covers the requirements, the backups and
|
||||||
|
how to move an existing SQLite install to Postgres with the command TREK ships for it.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<h2 id="helm-kubernetes">Helm (Kubernetes)</h2>
|
<h2 id="helm-kubernetes">Helm (Kubernetes)</h2>
|
||||||
@@ -333,22 +307,10 @@ See [`charts/README.md`](https://github.com/liketrek/TREK/blob/main/charts/READM
|
|||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
<h2 id="install-as-app-pwa">Install as App (PWA)</h2>
|
|
||||||
|
|
||||||
TREK works as a Progressive Web App, and the TREK Travel Planner app for iPhone, iPad and Android connects to the same server ([Native Apps](https://github.com/liketrek/TREK/wiki/Native-Apps)). To install the web app instead:
|
|
||||||
|
|
||||||
1. Open TREK in the browser (HTTPS required)
|
|
||||||
2. **iOS**: Share ▸ *Add to Home Screen*
|
|
||||||
3. **Android**: Menu ▸ *Install app* (or *Add to Home Screen*)
|
|
||||||
|
|
||||||
TREK then launches fullscreen with its own icon, just like a native app.
|
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
## Updating
|
## Updating
|
||||||
|
|
||||||
See [Updating](https://github.com/liketrek/TREK/wiki/Updating) — Docker Compose,
|
See [Updating](https://github.com/liketrek/TREK/wiki/Updating) — Docker Compose,
|
||||||
Docker run, Helm, Portainer, Unraid and Proxmox, plus the encryption-key note.
|
Docker run, Helm, Portainer, Unraid, TrueNAS SCALE and Proxmox, plus the encryption-key note.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
@@ -433,12 +395,15 @@ Caddy handles TLS and WebSockets automatically.
|
|||||||
Every variable, its default and what it does: see
|
Every variable, its default and what it does: see
|
||||||
[Environment Variables](https://github.com/liketrek/TREK/wiki/Environment-Variables).
|
[Environment Variables](https://github.com/liketrek/TREK/wiki/Environment-Variables).
|
||||||
|
|
||||||
|
<br />
|
||||||
|
|
||||||
## Data sources
|
## Data sources
|
||||||
|
|
||||||
The Atlas map's country and sub-national (province/county) boundaries come from
|
The Atlas map's country and sub-national (province/county) boundaries come from
|
||||||
[**geoBoundaries**](https://www.geoboundaries.org/) (Runfola et al., 2020), licensed
|
[**geoBoundaries**](https://www.geoboundaries.org/) (Runfola et al., 2020), licensed
|
||||||
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/). See [NOTICE.md](NOTICE.md)
|
[CC BY 4.0](https://creativecommons.org/licenses/by/4.0/); Ireland's counties come from
|
||||||
for full third-party attributions.
|
[**Tailte Éireann**](https://data-osi.opendata.arcgis.com/), also CC BY 4.0. See
|
||||||
|
[NOTICE.md](NOTICE.md) for full third-party attributions.
|
||||||
|
|
||||||
<br />
|
<br />
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -43,8 +43,10 @@ See `values.yaml` for more options.
|
|||||||
## Notes
|
## Notes
|
||||||
- Ingress is off by default. Enable and configure hosts for your domain.
|
- Ingress is off by default. Enable and configure hosts for your domain.
|
||||||
- PVCs use the cluster's default StorageClass. Set `persistence.data.storageClassName` and/or `persistence.uploads.storageClassName` to bind a specific class.
|
- PVCs use the cluster's default StorageClass. Set `persistence.data.storageClassName` and/or `persistence.uploads.storageClassName` to bind a specific class.
|
||||||
- To use your own PVCs, set `persistence.data.existingClaim` and/or `persistence.uploads.existingClaim`. The other values for that volume (size, storageClassName, annotations) are then ignored.
|
- Both PVCs are `ReadWriteOnce`. Set `persistence.data.accessModes` and/or `persistence.uploads.accessModes` to override, for example `[ReadWriteMany]` so a backup pod can mount the volume. On the data volume such a pod may only read: SQLite corrupts `travel.db` when a second process writes it over a network filesystem.
|
||||||
|
- To use your own PVCs, set `persistence.data.existingClaim` and/or `persistence.uploads.existingClaim`. The other values for that volume (size, storageClassName, accessModes, annotations) are then ignored.
|
||||||
- With `persistence.enabled: false`, the data and uploads volumes use an `emptyDir` — storage is ephemeral and lost on pod restart. Intended for testing only.
|
- With `persistence.enabled: false`, the data and uploads volumes use an `emptyDir` — storage is ephemeral and lost on pod restart. Intended for testing only.
|
||||||
|
- `database.url` runs TREK on a PostgreSQL database instead of the SQLite file. The chart writes it into its Secret as `TREK_DB_URL`; `database.existingSecret` and `database.existingSecretKey` read it from a Secret you manage. Leave both empty for SQLite. Keep `replicas: 1` either way. See the wiki page `Database-Postgres`.
|
||||||
- `JWT_SECRET` is managed entirely by the server — auto-generated into the data PVC on first start and rotatable via the admin panel (Settings → Danger Zone). No Helm configuration needed.
|
- `JWT_SECRET` is managed entirely by the server — auto-generated into the data PVC on first start and rotatable via the admin panel (Settings → Danger Zone). No Helm configuration needed.
|
||||||
- `ENCRYPTION_KEY` encrypts stored secrets (API keys, MFA, SMTP, OIDC) at rest. Recommended: set via `secretEnv.ENCRYPTION_KEY` or `existingSecret`. If left empty, the server falls back automatically: existing installs use `data/.jwt_secret` (no action needed on upgrade); fresh installs auto-generate a key persisted to the data PVC.
|
- `ENCRYPTION_KEY` encrypts stored secrets (API keys, MFA, SMTP, OIDC) at rest. Recommended: set via `secretEnv.ENCRYPTION_KEY` or `existingSecret`. If left empty, the server falls back automatically: existing installs use `data/.jwt_secret` (no action needed on upgrade); fresh installs auto-generate a key persisted to the data PVC.
|
||||||
- Liveness and readiness probes are configurable under `probes`. Overrides are merged over the defaults, so `--set probes.liveness.initialDelaySeconds=60` keeps the `httpGet` handler. When switching to `exec` or `tcpSocket`, clear `httpGet` in the same override. Set `probes.liveness: null` to remove a probe.
|
- Liveness and readiness probes are configurable under `probes`. Overrides are merged over the defaults, so `--set probes.liveness.initialDelaySeconds=60` keeps the `httpGet` handler. When switching to `exec` or `tcpSocket`, clear `httpGet` in the same override. Set `probes.liveness: null` to remove a probe.
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
apiVersion: v2
|
apiVersion: v2
|
||||||
name: trek
|
name: trek
|
||||||
version: 5.1.3
|
version: 5.2.1
|
||||||
description: Minimal Helm chart for TREK app
|
description: Minimal Helm chart for TREK app
|
||||||
appVersion: "5.1.3"
|
appVersion: "5.2.1"
|
||||||
|
|||||||
@@ -1,3 +1,7 @@
|
|||||||
|
{{- $db := default dict .Values.database }}
|
||||||
|
{{- if and $db.url (not $db.existingSecret) .Values.existingSecret }}
|
||||||
|
{{- fail "database.url is written into the chart's own Secret, which existingSecret replaces. Put TREK_DB_URL in your Secret and set database.existingSecret instead." }}
|
||||||
|
{{- end }}
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
metadata:
|
metadata:
|
||||||
@@ -5,11 +9,13 @@ metadata:
|
|||||||
labels:
|
labels:
|
||||||
app: {{ include "trek.name" . }}
|
app: {{ include "trek.name" . }}
|
||||||
spec:
|
spec:
|
||||||
|
# One replica. Its rate limits, pending codes, permission cache and WebSocket
|
||||||
|
# connections live in the process's memory, so a second pod would not share them. That
|
||||||
|
# holds with database.url (PostgreSQL) too; see updateStrategy in values.yaml.
|
||||||
replicas: 1
|
replicas: 1
|
||||||
# TREK is a single-writer SQLite app on a ReadWriteOnce PVC, so the default
|
# The default RollingUpdate would start a second pod on the same ReadWriteOnce PVC
|
||||||
# RollingUpdate would start a second pod holding the same volume before the old one
|
# before the old one exits: a Multi-Attach deadlock, or two processes on one travel.db.
|
||||||
# exits — a Multi-Attach deadlock, or two processes on one travel.db. Recreate tears
|
# Recreate tears the old pod down first. Keep it, see updateStrategy in values.yaml.
|
||||||
# the old pod down first. Keep it, see updateStrategy in values.yaml.
|
|
||||||
strategy:
|
strategy:
|
||||||
type: {{ .Values.updateStrategy | default "Recreate" }}
|
type: {{ .Values.updateStrategy | default "Recreate" }}
|
||||||
selector:
|
selector:
|
||||||
@@ -61,6 +67,14 @@ spec:
|
|||||||
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) .Values.existingSecret }}
|
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) .Values.existingSecret }}
|
||||||
key: {{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}
|
key: {{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}
|
||||||
optional: true
|
optional: true
|
||||||
|
{{- if or $db.url $db.existingSecret }}
|
||||||
|
# Required when set: a missing key stops the pod rather than starting it on SQLite.
|
||||||
|
- name: TREK_DB_URL
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ default (printf "%s-secret" (include "trek.fullname" .)) $db.existingSecret }}
|
||||||
|
key: {{ if $db.existingSecret }}{{ $db.existingSecretKey | default "TREK_DB_URL" }}{{ else }}TREK_DB_URL{{ end }}
|
||||||
|
{{- end }}
|
||||||
- name: ADMIN_EMAIL
|
- name: ADMIN_EMAIL
|
||||||
valueFrom:
|
valueFrom:
|
||||||
secretKeyRef:
|
secretKeyRef:
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
{{- toYaml (.Values.persistence.data.accessModes | default (list "ReadWriteOnce")) | nindent 4 }}
|
||||||
{{- with .Values.persistence.data.storageClassName }}
|
{{- with .Values.persistence.data.storageClassName }}
|
||||||
storageClassName: {{ . | quote }}
|
storageClassName: {{ . | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -33,7 +33,7 @@ metadata:
|
|||||||
{{- end }}
|
{{- end }}
|
||||||
spec:
|
spec:
|
||||||
accessModes:
|
accessModes:
|
||||||
- ReadWriteOnce
|
{{- toYaml (.Values.persistence.uploads.accessModes | default (list "ReadWriteOnce")) | nindent 4 }}
|
||||||
{{- with .Values.persistence.uploads.storageClassName }}
|
{{- with .Values.persistence.uploads.storageClassName }}
|
||||||
storageClassName: {{ . | quote }}
|
storageClassName: {{ . | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
{{- $db := default dict .Values.database }}
|
||||||
{{- if and (not .Values.existingSecret) (not .Values.generateEncryptionKey) }}
|
{{- if and (not .Values.existingSecret) (not .Values.generateEncryptionKey) }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
@@ -8,6 +9,9 @@ metadata:
|
|||||||
type: Opaque
|
type: Opaque
|
||||||
data:
|
data:
|
||||||
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ .Values.secretEnv.ENCRYPTION_KEY | b64enc | quote }}
|
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ .Values.secretEnv.ENCRYPTION_KEY | b64enc | quote }}
|
||||||
|
{{- if $db.url }}
|
||||||
|
TREK_DB_URL: {{ $db.url | b64enc | quote }}
|
||||||
|
{{- end }}
|
||||||
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
||||||
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | b64enc | quote }}
|
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | b64enc | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
@@ -65,6 +69,9 @@ stringData:
|
|||||||
{{- else }}
|
{{- else }}
|
||||||
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ randAlphaNum 32 | quote }}
|
{{ .Values.existingSecretKey | default "ENCRYPTION_KEY" }}: {{ randAlphaNum 32 | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
{{- if $db.url }}
|
||||||
|
TREK_DB_URL: {{ $db.url | quote }}
|
||||||
|
{{- end }}
|
||||||
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
{{- if .Values.secretEnv.ADMIN_EMAIL }}
|
||||||
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | quote }}
|
ADMIN_EMAIL: {{ .Values.secretEnv.ADMIN_EMAIL | quote }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|||||||
+33
-5
@@ -4,10 +4,13 @@ image:
|
|||||||
# tag: latest
|
# tag: latest
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
|
|
||||||
# Deployment update strategy. Keep Recreate: TREK is a single-writer SQLite app, and
|
# Deployment update strategy. Keep Recreate. The new pod migrates the database when it
|
||||||
# during a RollingUpdate the new pod migrates the database while the old one still
|
# starts, and during a RollingUpdate it would do that while the old pod still writes to
|
||||||
# writes to it. A ReadWriteMany volume does not make that safe; SQLite's WAL needs both
|
# it. Recreate stops the old pod first. On SQLite two processes on one travel.db are
|
||||||
# processes on one host, which network filesystems do not provide.
|
# unsafe, and a ReadWriteOnce volume cannot be attached to both pods at once.
|
||||||
|
# With database.url the database is PostgreSQL, but the reason for one replica stays: TREK
|
||||||
|
# keeps rate limits, pending codes, the permission cache and WebSocket connections in
|
||||||
|
# memory, so a second pod would not share them. Postgres does not make more replicas safe.
|
||||||
updateStrategy: Recreate
|
updateStrategy: Recreate
|
||||||
|
|
||||||
# Pod-level security context. fsGroup gives the node user (uid/gid 1000) group access
|
# Pod-level security context. fsGroup gives the node user (uid/gid 1000) group access
|
||||||
@@ -178,6 +181,22 @@ env:
|
|||||||
# address is sent unless you set one here.
|
# address is sent unless you set one here.
|
||||||
|
|
||||||
|
|
||||||
|
# Database. Empty (the default) keeps TREK on its SQLite file in the data volume. Set url to
|
||||||
|
# run TREK on a PostgreSQL database instead (see the wiki page Database-Postgres). The URL
|
||||||
|
# carries the password, so it is never a plain env value: with url, the chart writes it into
|
||||||
|
# its own Secret as TREK_DB_URL; with existingSecret, TREK reads TREK_DB_URL from that Secret
|
||||||
|
# under existingSecretKey and the chart writes nothing. existingSecret wins over url. The
|
||||||
|
# variable is required when either is set: a missing Secret key stops the pod instead of
|
||||||
|
# starting it on SQLite. The role in the URL owns TREK's database and must not be a superuser
|
||||||
|
# (nor a member of one, nor hold a right that reaches the server's files or programs): a
|
||||||
|
# restore runs the backup's SQL as that role and refuses one that could reach the database host. The wiki page shows the
|
||||||
|
# SQL that creates such a role. PostgreSQL 14 to 18 is supported.
|
||||||
|
# url: "postgres://trek:<password>@postgres.example.internal:5432/trek?sslmode=require"
|
||||||
|
database:
|
||||||
|
url: ""
|
||||||
|
existingSecret: ""
|
||||||
|
existingSecretKey: TREK_DB_URL
|
||||||
|
|
||||||
# Secret environment variables stored in a Kubernetes Secret.
|
# Secret environment variables stored in a Kubernetes Secret.
|
||||||
# JWT_SECRET is managed entirely by the server (auto-generated into the data PVC,
|
# JWT_SECRET is managed entirely by the server (auto-generated into the data PVC,
|
||||||
# rotatable via the admin panel) — it is not configured here.
|
# rotatable via the admin panel) — it is not configured here.
|
||||||
@@ -247,12 +266,21 @@ persistence:
|
|||||||
size: 1Gi
|
size: 1Gi
|
||||||
# Leave empty to use the cluster's default StorageClass; set to bind a specific class.
|
# Leave empty to use the cluster's default StorageClass; set to bind a specific class.
|
||||||
storageClassName: ""
|
storageClassName: ""
|
||||||
# Bind an existing PVC. The other values (size, storageClassName, annotations) are then ignored.
|
# Access modes of the claim. ReadWriteMany lets another pod mount the volume, for
|
||||||
|
# example a backup sidecar, but only for reading: SQLite needs every writer on one
|
||||||
|
# host, so two pods writing travel.db over a network filesystem corrupt it.
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
|
# Bind an existing PVC. The other values (size, storageClassName, accessModes,
|
||||||
|
# annotations) are then ignored.
|
||||||
existingClaim: ""
|
existingClaim: ""
|
||||||
annotations: {}
|
annotations: {}
|
||||||
uploads:
|
uploads:
|
||||||
size: 1Gi
|
size: 1Gi
|
||||||
storageClassName: ""
|
storageClassName: ""
|
||||||
|
# Access modes of the claim; ReadWriteMany lets other pods read or add uploads.
|
||||||
|
accessModes:
|
||||||
|
- ReadWriteOnce
|
||||||
# Specify an existing PVC to bind. The other values are then ignored.
|
# Specify an existing PVC to bind. The other values are then ignored.
|
||||||
existingClaim: ""
|
existingClaim: ""
|
||||||
annotations: {}
|
annotations: {}
|
||||||
|
|||||||
+1
-1
@@ -6,7 +6,7 @@ Scope: the **`@trek/client`** workspace (React 19 + Vite + Zustand + Tailwind PW
|
|||||||
|
|
||||||
```bash
|
```bash
|
||||||
npm run dev # Vite dev server; proxies the API/ws/uploads/MCP/OAuth paths → http://localhost:3001
|
npm run dev # Vite dev server; proxies the API/ws/uploads/MCP/OAuth paths → http://localhost:3001
|
||||||
npm run build # prebuild generates PWA icons, then vite build
|
npm run build # prebuild generates PWA icons, then vite build; postbuild writes a Brotli copy beside each hashed asset for the server to hand out
|
||||||
npm run typecheck # tsc --noEmit (CI)
|
npm run typecheck # tsc --noEmit (CI)
|
||||||
npm run lint:strict # tsc over tsconfig.strict.json (strictNullChecks + noImplicitAny): errors per file may only shrink against scripts/strict-baseline.json, a new file starts at zero (CI gate; --list shows them, --update lowers it)
|
npm run lint:strict # tsc over tsconfig.strict.json (strictNullChecks + noImplicitAny): errors per file may only shrink against scripts/strict-baseline.json, a new file starts at zero (CI gate; --list shows them, --update lowers it)
|
||||||
npm run lint # eslint . (CI runs lint:warnings instead, which fails on the same errors)
|
npm run lint # eslint . (CI runs lint:warnings instead, which fails on the same errors)
|
||||||
|
|||||||
+9
@@ -36,3 +36,12 @@
|
|||||||
@android.webkit.JavascriptInterface <methods>;
|
@android.webkit.JavascriptInterface <methods>;
|
||||||
}
|
}
|
||||||
-keep public class * extends com.getcapacitor.Plugin
|
-keep public class * extends com.getcapacitor.Plugin
|
||||||
|
|
||||||
|
# The stored copy of the server's UI gets Capacitor's bridge the way the
|
||||||
|
# server's own page does (TrekOfflineShell.withBridge reads it by reflection).
|
||||||
|
-keepclassmembers class com.getcapacitor.Bridge {
|
||||||
|
private com.getcapacitor.JSInjector getJSInjector();
|
||||||
|
}
|
||||||
|
-keep class com.getcapacitor.JSInjector {
|
||||||
|
public java.io.InputStream getInjectedStream(java.io.InputStream);
|
||||||
|
}
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import androidx.glance.appwidget.GlanceRemoteViews
|
|||||||
import com.liketrek.trek.tripday.TripDayNotification
|
import com.liketrek.trek.tripday.TripDayNotification
|
||||||
import com.liketrek.trek.widget.AtlasWidget
|
import com.liketrek.trek.widget.AtlasWidget
|
||||||
import com.liketrek.trek.widget.BookingsWidget
|
import com.liketrek.trek.widget.BookingsWidget
|
||||||
|
import com.liketrek.trek.widget.FlightWidget
|
||||||
import com.liketrek.trek.widget.CollabWidget
|
import com.liketrek.trek.widget.CollabWidget
|
||||||
import com.liketrek.trek.widget.PackingWidget
|
import com.liketrek.trek.widget.PackingWidget
|
||||||
import com.liketrek.trek.widget.TodayWidget
|
import com.liketrek.trek.widget.TodayWidget
|
||||||
@@ -74,6 +75,7 @@ class WidgetGalleryActivity : Activity() {
|
|||||||
"trip" to TripWidget(),
|
"trip" to TripWidget(),
|
||||||
"today" to TodayWidget(),
|
"today" to TodayWidget(),
|
||||||
"bookings" to BookingsWidget(),
|
"bookings" to BookingsWidget(),
|
||||||
|
"flight" to FlightWidget(),
|
||||||
"todos" to TodosWidget(),
|
"todos" to TodosWidget(),
|
||||||
"packing" to PackingWidget(),
|
"packing" to PackingWidget(),
|
||||||
"atlas" to AtlasWidget(),
|
"atlas" to AtlasWidget(),
|
||||||
|
|||||||
@@ -142,6 +142,15 @@
|
|||||||
</intent-filter>
|
</intent-filter>
|
||||||
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_bookings" />
|
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_bookings" />
|
||||||
</receiver>
|
</receiver>
|
||||||
|
<receiver
|
||||||
|
android:name=".widget.FlightWidgetReceiver"
|
||||||
|
android:label="@string/widget_flight_name"
|
||||||
|
android:exported="false">
|
||||||
|
<intent-filter>
|
||||||
|
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
|
||||||
|
</intent-filter>
|
||||||
|
<meta-data android:name="android.appwidget.provider" android:resource="@xml/widget_flight" />
|
||||||
|
</receiver>
|
||||||
<receiver
|
<receiver
|
||||||
android:name=".widget.TodosWidgetReceiver"
|
android:name=".widget.TodosWidgetReceiver"
|
||||||
android:label="@string/widget_todos_name"
|
android:label="@string/widget_todos_name"
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import android.view.KeyboardShortcutGroup;
|
|||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
import android.webkit.CookieManager;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import android.widget.FrameLayout;
|
import android.widget.FrameLayout;
|
||||||
import android.widget.LinearLayout;
|
import android.widget.LinearLayout;
|
||||||
@@ -34,7 +35,19 @@ public class MainActivity extends BridgeActivity {
|
|||||||
// runs and on its own origin. BridgeActivity reads `config` while it
|
// runs and on its own origin. BridgeActivity reads `config` while it
|
||||||
// builds the bridge inside super.onCreate().
|
// builds the bridge inside super.onCreate().
|
||||||
boolean restarting = TrekServerStore.consumeRestart(this);
|
boolean restarting = TrekServerStore.consumeRestart(this);
|
||||||
TrekServerStore.recheckAfterUpdate(this);
|
// Without a network the server cannot answer: with a copy of its UI the
|
||||||
|
// app starts on that at once (TrekOfflineShell), as it does when the
|
||||||
|
// address screen found the server out of reach. The check an update asks
|
||||||
|
// for waits for a launch that can reach the server.
|
||||||
|
boolean offlineStart = TrekServerStore.consumeOfflineStart(this)
|
||||||
|
|| (!TrekOfflineShell.hasNetwork(this) && TrekOfflineShell.hasCopy(this, TrekServerStore.getUrlOrPrevious(this)));
|
||||||
|
if (offlineStart && TrekOfflineShell.hasCopy(this, TrekServerStore.getUrlOrPrevious(this))) {
|
||||||
|
TrekServerStore.restoreForOffline(this);
|
||||||
|
TrekOfflineShell.activate(TrekServerStore.getUrl(this));
|
||||||
|
} else {
|
||||||
|
TrekOfflineShell.deactivate();
|
||||||
|
TrekServerStore.recheckAfterUpdate(this);
|
||||||
|
}
|
||||||
String server = TrekServerStore.getUrl(this);
|
String server = TrekServerStore.getUrl(this);
|
||||||
boolean onServer = server != null && !TrekServerStore.consumeShellOnce(this);
|
boolean onServer = server != null && !TrekServerStore.consumeShellOnce(this);
|
||||||
config = TrekServerStore.configFor(this, onServer ? server : null, restarting);
|
config = TrekServerStore.configFor(this, onServer ? server : null, restarting);
|
||||||
@@ -47,7 +60,13 @@ public class MainActivity extends BridgeActivity {
|
|||||||
// Set before any WebView callback can run: they are posted to this thread.
|
// Set before any WebView callback can run: they are posted to this thread.
|
||||||
if (onServer) {
|
if (onServer) {
|
||||||
bridge.setWebViewClient(
|
bridge.setWebViewClient(
|
||||||
new TrekWebViewClient(bridge, this::showAddressScreen, this::showSignInBar, TrekServerStore.getSignInHosts(this))
|
new TrekWebViewClient(
|
||||||
|
bridge,
|
||||||
|
this::showAddressScreen,
|
||||||
|
this::showSignInBar,
|
||||||
|
this::showErrorPageBar,
|
||||||
|
TrekServerStore.getSignInHosts(this)
|
||||||
|
)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
TrekSharedFiles.receive(this, getIntent());
|
TrekSharedFiles.receive(this, getIntent());
|
||||||
@@ -73,6 +92,18 @@ public class MainActivity extends BridgeActivity {
|
|||||||
if (group != null) data.add(group);
|
if (group != null) data.add(group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The web view keeps new cookies in memory and writes them to disk on its
|
||||||
|
* own schedule, about half a minute later. An app Android ends in that time
|
||||||
|
* (swiped away, or reclaimed for memory) forgets the sign-in it just had, so
|
||||||
|
* the session is written down whenever the app leaves the screen.
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onPause() {
|
||||||
|
super.onPause();
|
||||||
|
CookieManager.getInstance().flush();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onNewIntent(Intent intent) {
|
public void onNewIntent(Intent intent) {
|
||||||
super.onNewIntent(intent);
|
super.onNewIntent(intent);
|
||||||
@@ -84,7 +115,10 @@ public class MainActivity extends BridgeActivity {
|
|||||||
private View signInBar;
|
private View signInBar;
|
||||||
/** Whether the page is a proxy's sign-in page, and whether the keyboard is up over it. */
|
/** Whether the page is a proxy's sign-in page, and whether the keyboard is up over it. */
|
||||||
private boolean onSignInPage;
|
private boolean onSignInPage;
|
||||||
|
/** Whether the page is an error page in place of the server's (TrekWebViewClient.onReceivedHttpError). */
|
||||||
|
private boolean onErrorPage;
|
||||||
private boolean keyboardUp;
|
private boolean keyboardUp;
|
||||||
|
private TextView signInHint;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Over a proxy's sign-in page (Pangolin, authentik, ...): the server's UI is
|
* Over a proxy's sign-in page (Pangolin, authentik, ...): the server's UI is
|
||||||
@@ -100,9 +134,22 @@ public class MainActivity extends BridgeActivity {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The same bar over an error page in place of the server's, with words for that. */
|
||||||
|
private void showErrorPageBar(boolean show) {
|
||||||
|
runOnUiThread(() -> {
|
||||||
|
onErrorPage = show;
|
||||||
|
if (show && signInBar == null) signInBar = buildSignInBar();
|
||||||
|
updateSignInBar();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/** Out of the way while the keyboard is up: the form needs the room, and the bar is there again once it closes. */
|
/** Out of the way while the keyboard is up: the form needs the room, and the bar is there again once it closes. */
|
||||||
private void updateSignInBar() {
|
private void updateSignInBar() {
|
||||||
if (signInBar != null) signInBar.setVisibility(onSignInPage && !keyboardUp ? View.VISIBLE : View.GONE);
|
if (signInBar == null) return;
|
||||||
|
if (signInHint != null) {
|
||||||
|
signInHint.setText(onSignInPage ? TrekServerStore.signInHintLabel(this) : TrekServerStore.errorPageHintLabel(this));
|
||||||
|
}
|
||||||
|
signInBar.setVisibility((onSignInPage || onErrorPage) && !keyboardUp ? View.VISIBLE : View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private View buildSignInBar() {
|
private View buildSignInBar() {
|
||||||
@@ -110,16 +157,20 @@ public class MainActivity extends BridgeActivity {
|
|||||||
LinearLayout bar = new LinearLayout(this);
|
LinearLayout bar = new LinearLayout(this);
|
||||||
bar.setOrientation(LinearLayout.HORIZONTAL);
|
bar.setOrientation(LinearLayout.HORIZONTAL);
|
||||||
bar.setGravity(Gravity.CENTER_VERTICAL);
|
bar.setGravity(Gravity.CENTER_VERTICAL);
|
||||||
bar.setPadding(Math.round(14 * dp), Math.round(10 * dp), Math.round(8 * dp), Math.round(10 * dp));
|
bar.setPaddingRelative(Math.round(16 * dp), Math.round(10 * dp), Math.round(10 * dp), Math.round(10 * dp));
|
||||||
|
// The look of the app's own first screens: a white card with a sand edge,
|
||||||
|
// warm grey text and a dark button, over whatever page the proxy shows.
|
||||||
GradientDrawable background = new GradientDrawable();
|
GradientDrawable background = new GradientDrawable();
|
||||||
background.setColor(0xF2111827);
|
background.setColor(0xF7FFFFFF);
|
||||||
background.setCornerRadius(16 * dp);
|
background.setCornerRadius(18 * dp);
|
||||||
|
background.setStroke(Math.max(1, Math.round(dp)), 0xFFEFE4D8);
|
||||||
bar.setBackground(background);
|
bar.setBackground(background);
|
||||||
bar.setElevation(6 * dp);
|
bar.setElevation(8 * dp);
|
||||||
|
|
||||||
TextView hint = new TextView(this);
|
TextView hint = new TextView(this);
|
||||||
|
signInHint = hint;
|
||||||
hint.setText(TrekServerStore.signInHintLabel(this));
|
hint.setText(TrekServerStore.signInHintLabel(this));
|
||||||
hint.setTextColor(0xFFE5E7EB);
|
hint.setTextColor(0xFF6B5F57);
|
||||||
hint.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.5f);
|
hint.setTextSize(TypedValue.COMPLEX_UNIT_SP, 12.5f);
|
||||||
bar.addView(hint, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
bar.addView(hint, new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
|
||||||
|
|
||||||
@@ -127,12 +178,21 @@ public class MainActivity extends BridgeActivity {
|
|||||||
change.setText(TrekServerStore.changeServerLabel(this));
|
change.setText(TrekServerStore.changeServerLabel(this));
|
||||||
change.setAllCaps(false);
|
change.setAllCaps(false);
|
||||||
change.setTextColor(0xFFFFFFFF);
|
change.setTextColor(0xFFFFFFFF);
|
||||||
|
GradientDrawable pill = new GradientDrawable();
|
||||||
|
pill.setColor(0xFF111827);
|
||||||
|
pill.setCornerRadius(12 * dp);
|
||||||
|
change.setBackground(pill);
|
||||||
|
change.setMinHeight(0);
|
||||||
|
change.setMinimumHeight(0);
|
||||||
|
change.setPaddingRelative(Math.round(14 * dp), Math.round(9 * dp), Math.round(14 * dp), Math.round(9 * dp));
|
||||||
|
LinearLayout.LayoutParams changeParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||||
|
changeParams.setMarginStart(Math.round(10 * dp));
|
||||||
change.setOnClickListener((v) -> {
|
change.setOnClickListener((v) -> {
|
||||||
TrekServerStore.setUrl(this, null);
|
TrekServerStore.setUrl(this, null);
|
||||||
TrekServerStore.markRestart(this);
|
TrekServerStore.markRestart(this);
|
||||||
recreate();
|
recreate();
|
||||||
});
|
});
|
||||||
bar.addView(change, new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT));
|
bar.addView(change, changeParams);
|
||||||
|
|
||||||
int margin = Math.round(12 * dp);
|
int margin = Math.round(12 * dp);
|
||||||
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.liketrek.trek;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The log line for a page of the server that came back with an error status.
|
||||||
|
* "HTTP 503" on the address screen cannot tell the server, a proxy in front of
|
||||||
|
* it and something on the phone apart, so the line names the page and the
|
||||||
|
* headers that say who answered (#3014).
|
||||||
|
*/
|
||||||
|
final class PageErrorLog {
|
||||||
|
|
||||||
|
/** The headers that name whoever answered a page, in the order they are logged. */
|
||||||
|
private static final String[] SENDER_HEADERS = { "Server", "Via", "CF-Ray", "Content-Type" };
|
||||||
|
|
||||||
|
private PageErrorLog() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* For example "Page answered HTTP 503 Service Unavailable for
|
||||||
|
* https://trek.example.com/login (server: cloudflare, cf-ray: 8f1a2b3c4d5e6f70-FRA)".
|
||||||
|
* The address goes without its query and fragment, where a sign-in page
|
||||||
|
* carries a challenge or a code. A header the answer did not have is left
|
||||||
|
* out, and an answer with none of them says so: no server sends a page
|
||||||
|
* without at least its type, so that points at something on the phone.
|
||||||
|
*/
|
||||||
|
static String describe(String url, int status, String reason, Map<String, String> headers) {
|
||||||
|
StringBuilder line = new StringBuilder("Page answered HTTP ").append(status);
|
||||||
|
if (reason != null && !reason.trim().isEmpty()) line.append(' ').append(reason.trim());
|
||||||
|
line.append(" for ").append(withoutQuery(url));
|
||||||
|
List<String> senders = new ArrayList<>();
|
||||||
|
for (String name : SENDER_HEADERS) {
|
||||||
|
String value = header(headers, name);
|
||||||
|
if (value != null && !value.trim().isEmpty()) senders.add(name.toLowerCase(Locale.ROOT) + ": " + value.trim());
|
||||||
|
}
|
||||||
|
line.append(senders.isEmpty() ? " (no server headers)" : " (" + String.join(", ", senders) + ")");
|
||||||
|
return line.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A header by name, whatever case the answer wrote it in. */
|
||||||
|
private static String header(Map<String, String> headers, String name) {
|
||||||
|
if (headers == null) return null;
|
||||||
|
for (Map.Entry<String, String> entry : headers.entrySet()) {
|
||||||
|
if (name.equalsIgnoreCase(entry.getKey())) return entry.getValue();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String withoutQuery(String url) {
|
||||||
|
if (url == null) return "";
|
||||||
|
int end = url.length();
|
||||||
|
int query = url.indexOf('?');
|
||||||
|
if (query >= 0) end = query;
|
||||||
|
int fragment = url.indexOf('#');
|
||||||
|
if (fragment >= 0 && fragment < end) end = fragment;
|
||||||
|
return url.substring(0, end);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,330 @@
|
|||||||
|
package com.liketrek.trek;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.net.ConnectivityManager;
|
||||||
|
import android.net.Network;
|
||||||
|
import android.net.NetworkCapabilities;
|
||||||
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
|
import android.webkit.WebResourceRequest;
|
||||||
|
import android.webkit.WebResourceResponse;
|
||||||
|
import com.getcapacitor.Bridge;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server's UI kept on the device, so the app starts without its server: on
|
||||||
|
* a trip without reception, or away from home with a server on the home
|
||||||
|
* network. The web view runs no service worker on a plain-http server, the
|
||||||
|
* usual address of a server at home, so the app keeps the start page and every
|
||||||
|
* file of the build itself (refreshed by native/offlineShell.ts while the
|
||||||
|
* server is reachable) and serves them under the server's own origin while it
|
||||||
|
* is not. The data comes from the UI's own offline store; the API is tried as
|
||||||
|
* usual and answers again once the server is back.
|
||||||
|
*/
|
||||||
|
final class TrekOfflineShell {
|
||||||
|
|
||||||
|
private static final String DIR = "offline-shell";
|
||||||
|
private static final String PAGE = "index.html";
|
||||||
|
private static final String STAMP = "server.txt";
|
||||||
|
private static final String FILES = "files";
|
||||||
|
/** A path of the build: no "..", no query, nothing outside the copy's folder. */
|
||||||
|
private static final Pattern SAFE_PATH = Pattern.compile("^[A-Za-z0-9._@\\-]+(?:/[A-Za-z0-9._@\\-]+)*$");
|
||||||
|
private static final Map<String, String> TYPES = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
TYPES.put("js", "text/javascript");
|
||||||
|
TYPES.put("mjs", "text/javascript");
|
||||||
|
TYPES.put("css", "text/css");
|
||||||
|
TYPES.put("json", "application/json");
|
||||||
|
TYPES.put("webmanifest", "application/manifest+json");
|
||||||
|
TYPES.put("svg", "image/svg+xml");
|
||||||
|
TYPES.put("png", "image/png");
|
||||||
|
TYPES.put("jpg", "image/jpeg");
|
||||||
|
TYPES.put("jpeg", "image/jpeg");
|
||||||
|
TYPES.put("webp", "image/webp");
|
||||||
|
TYPES.put("ico", "image/x-icon");
|
||||||
|
TYPES.put("woff", "font/woff");
|
||||||
|
TYPES.put("woff2", "font/woff2");
|
||||||
|
TYPES.put("ttf", "font/ttf");
|
||||||
|
TYPES.put("wasm", "application/wasm");
|
||||||
|
TYPES.put("html", "text/html");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The server whose copy the UI comes from in this run: it did not answer
|
||||||
|
* when the app started. Null while the UI comes from the server itself.
|
||||||
|
* Bound to the server, so a copy never answers for another one.
|
||||||
|
*/
|
||||||
|
private static volatile String activeServer;
|
||||||
|
/** Capacitor's JSInjector (package-private there) and its getInjectedStream, found once. */
|
||||||
|
private static volatile Object injector;
|
||||||
|
private static volatile Method injectMethod;
|
||||||
|
private static volatile boolean injectorLooked;
|
||||||
|
|
||||||
|
private TrekOfflineShell() {}
|
||||||
|
|
||||||
|
static boolean isActive() {
|
||||||
|
return activeServer != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void activate(String server) {
|
||||||
|
activeServer = server;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A start that goes to the server. The flag lives in the process, and
|
||||||
|
* restart() recreates the activity in that same process (another server
|
||||||
|
* picked, the address screen, a reload once the server is back), so each
|
||||||
|
* start sets it anew instead of keeping the last run's copy in front.
|
||||||
|
*/
|
||||||
|
static void deactivate() {
|
||||||
|
activeServer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the copy stands in for this server in this run. */
|
||||||
|
static boolean isActiveFor(String server) {
|
||||||
|
String current = activeServer;
|
||||||
|
return current != null && current.equals(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File root(Context context) {
|
||||||
|
return new File(context.getFilesDir(), DIR);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether there is a copy of this server's UI to start from. */
|
||||||
|
static boolean hasCopy(Context context, String server) {
|
||||||
|
return hasCopy(root(context), server);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hasCopy(File root, String server) {
|
||||||
|
if (server == null) return false;
|
||||||
|
File page = new File(root, PAGE);
|
||||||
|
return page.isFile() && server.equals(readStamp(root));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the device has a network at all; with none, the server cannot answer and the copy starts at once. */
|
||||||
|
static boolean hasNetwork(Context context) {
|
||||||
|
try {
|
||||||
|
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
|
||||||
|
if (cm == null) return true;
|
||||||
|
Network network = cm.getActiveNetwork();
|
||||||
|
if (network == null) return false;
|
||||||
|
NetworkCapabilities caps = cm.getNetworkCapabilities(network);
|
||||||
|
return caps != null && caps.hasCapability(NetworkCapabilities.NET_CAPABILITY_INTERNET);
|
||||||
|
} catch (RuntimeException e) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Before a refresh fetches the files of a build: a copy of another server
|
||||||
|
* is thrown away, one of this server stays as it is until savePage.
|
||||||
|
*/
|
||||||
|
static boolean beginRefresh(Context context, String server) {
|
||||||
|
return beginRefresh(root(context), server);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean beginRefresh(File root, String server) {
|
||||||
|
if (!server.equals(readStamp(root))) deleteTree(root);
|
||||||
|
return root.isDirectory() || root.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps the start page, and only once every file it names is stored: the
|
||||||
|
* page points at the build's files by their hashes, so a refresh cut off
|
||||||
|
* halfway (no reception, the app ended) keeps the previous page with its
|
||||||
|
* complete build instead of a new page whose scripts are missing.
|
||||||
|
*/
|
||||||
|
static boolean savePage(Context context, String server, byte[] html) {
|
||||||
|
return savePage(root(context), server, html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean savePage(File root, String server, byte[] html) {
|
||||||
|
if (!root.isDirectory() && !root.mkdirs()) return false;
|
||||||
|
return write(new File(root, STAMP), server.getBytes(StandardCharsets.UTF_8)) && write(new File(root, PAGE), html);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hasFile(Context context, String path) {
|
||||||
|
return hasFile(root(context), path);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean hasFile(File root, String path) {
|
||||||
|
File file = fileFor(root, path);
|
||||||
|
return file != null && file.isFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean saveFile(Context context, String path, byte[] data) {
|
||||||
|
return saveFile(root(context), path, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean saveFile(File root, String path, byte[] data) {
|
||||||
|
File file = fileFor(root, path);
|
||||||
|
if (file == null) return false;
|
||||||
|
File parent = file.getParentFile();
|
||||||
|
if (parent != null && !parent.isDirectory() && !parent.mkdirs()) return false;
|
||||||
|
return write(file, data);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Drops the files of older builds once the current one is complete. */
|
||||||
|
static void prune(Context context, Set<String> keep) {
|
||||||
|
prune(root(context), keep);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void prune(File root, Set<String> keep) {
|
||||||
|
File base = new File(root, FILES);
|
||||||
|
pruneDir(base, base, keep);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The copy's answer for a request of the server's UI while it is active:
|
||||||
|
* the start page for any page of the app (it routes itself), with
|
||||||
|
* Capacitor's bridge injected as into the server's own page, and a file of
|
||||||
|
* the build by its path. Null for anything else, which goes on as usual.
|
||||||
|
*/
|
||||||
|
static WebResourceResponse serve(Context context, Bridge bridge, String server, WebResourceRequest request) {
|
||||||
|
if (!isActiveFor(server) || !"GET".equalsIgnoreCase(request.getMethod())) return null;
|
||||||
|
Uri url = request.getUrl();
|
||||||
|
Uri origin = Uri.parse(server);
|
||||||
|
if (!sameOrigin(url, origin)) return null;
|
||||||
|
try {
|
||||||
|
if (request.isForMainFrame()) {
|
||||||
|
File page = new File(root(context), PAGE);
|
||||||
|
if (!page.isFile()) return null;
|
||||||
|
InputStream html = withBridge(bridge, new FileInputStream(page));
|
||||||
|
return response("text/html", html);
|
||||||
|
}
|
||||||
|
String path = url.getPath();
|
||||||
|
if (path == null) return null;
|
||||||
|
File file = fileFor(root(context), path);
|
||||||
|
if (file == null || !file.isFile()) return null;
|
||||||
|
return response(typeOf(path), new FileInputStream(file));
|
||||||
|
} catch (IOException e) {
|
||||||
|
Log.w("TrekShell", "Offline copy could not answer " + url, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static WebResourceResponse response(String type, InputStream body) {
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
headers.put("Cache-Control", "no-store");
|
||||||
|
String charset = type.startsWith("text/") || type.endsWith("json") ? "utf-8" : null;
|
||||||
|
return new WebResourceResponse(type, charset, 200, "OK", headers, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Capacitor injects its bridge into the server's page as it passes through;
|
||||||
|
* the copy gets the same script. Its builder is internal to Capacitor, hence
|
||||||
|
* the reflection on both (kept in proguard-rules.pro). Without it the UI still runs,
|
||||||
|
* as it would in a browser, just without the app's native parts.
|
||||||
|
*/
|
||||||
|
private static InputStream withBridge(Bridge bridge, InputStream html) {
|
||||||
|
if (!injectorLooked) {
|
||||||
|
injectorLooked = true;
|
||||||
|
try {
|
||||||
|
Method method = Bridge.class.getDeclaredMethod("getJSInjector");
|
||||||
|
method.setAccessible(true);
|
||||||
|
Object built = method.invoke(bridge);
|
||||||
|
if (built != null) {
|
||||||
|
Method inject = built.getClass().getDeclaredMethod("getInjectedStream", InputStream.class);
|
||||||
|
inject.setAccessible(true);
|
||||||
|
injectMethod = inject;
|
||||||
|
injector = built;
|
||||||
|
}
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
Log.w("TrekShell", "No bridge for the offline copy", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Object current = injector;
|
||||||
|
Method inject = injectMethod;
|
||||||
|
if (current == null || inject == null) return html;
|
||||||
|
try {
|
||||||
|
Object injected = inject.invoke(current, html);
|
||||||
|
return injected instanceof InputStream ? (InputStream) injected : html;
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException e) {
|
||||||
|
Log.w("TrekShell", "Bridge not injected into the offline copy", e);
|
||||||
|
return html;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean sameOrigin(Uri a, Uri b) {
|
||||||
|
if (a.getScheme() == null || b.getScheme() == null || a.getHost() == null || b.getHost() == null) return false;
|
||||||
|
return a.getScheme().equalsIgnoreCase(b.getScheme())
|
||||||
|
&& a.getHost().equalsIgnoreCase(b.getHost())
|
||||||
|
&& port(a) == port(b);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int port(Uri uri) {
|
||||||
|
if (uri.getPort() != -1) return uri.getPort();
|
||||||
|
return "https".equalsIgnoreCase(uri.getScheme()) ? 443 : 80;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File fileFor(File root, String path) {
|
||||||
|
String clean = path.startsWith("/") ? path.substring(1) : path;
|
||||||
|
if (clean.isEmpty() || clean.contains("..") || !SAFE_PATH.matcher(clean).matches()) return null;
|
||||||
|
return new File(new File(root, FILES), clean);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String typeOf(String path) {
|
||||||
|
int dot = path.lastIndexOf('.');
|
||||||
|
String ext = dot < 0 ? "" : path.substring(dot + 1).toLowerCase(Locale.ROOT);
|
||||||
|
String type = TYPES.get(ext);
|
||||||
|
return type == null ? "application/octet-stream" : type;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String readStamp(File root) {
|
||||||
|
File stamp = new File(root, STAMP);
|
||||||
|
if (!stamp.isFile()) return null;
|
||||||
|
try (FileInputStream in = new FileInputStream(stamp)) {
|
||||||
|
byte[] data = new byte[(int) Math.min(stamp.length(), 4096)];
|
||||||
|
int read = in.read(data);
|
||||||
|
return read <= 0 ? null : new String(data, 0, read, StandardCharsets.UTF_8);
|
||||||
|
} catch (IOException e) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Written beside the target and moved over it, so a cut-off write never leaves half a file. */
|
||||||
|
private static boolean write(File target, byte[] data) {
|
||||||
|
File temp = new File(target.getPath() + ".part");
|
||||||
|
try (FileOutputStream out = new FileOutputStream(temp)) {
|
||||||
|
out.write(data);
|
||||||
|
out.getFD().sync();
|
||||||
|
} catch (IOException e) {
|
||||||
|
temp.delete();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return temp.renameTo(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void pruneDir(File base, File dir, Set<String> keep) {
|
||||||
|
File[] children = dir.listFiles();
|
||||||
|
if (children == null) return;
|
||||||
|
for (File child : children) {
|
||||||
|
if (child.isDirectory()) {
|
||||||
|
pruneDir(base, child, keep);
|
||||||
|
String[] left = child.list();
|
||||||
|
if (left != null && left.length == 0) child.delete();
|
||||||
|
} else {
|
||||||
|
String relative = base.toURI().relativize(child.toURI()).getPath();
|
||||||
|
if (!keep.contains(relative)) child.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void deleteTree(File file) {
|
||||||
|
File[] children = file.listFiles();
|
||||||
|
if (children != null) for (File child : children) deleteTree(child);
|
||||||
|
file.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,6 +26,7 @@ final class TrekServerStore {
|
|||||||
private static final String KEY_SERVER_CHECK = "server_check";
|
private static final String KEY_SERVER_CHECK = "server_check";
|
||||||
private static final String KEY_LABEL_SIGN_IN_HINT = "label_sign_in_hint";
|
private static final String KEY_LABEL_SIGN_IN_HINT = "label_sign_in_hint";
|
||||||
private static final String KEY_LABEL_CHANGE_SERVER = "label_change_server";
|
private static final String KEY_LABEL_CHANGE_SERVER = "label_change_server";
|
||||||
|
private static final String KEY_LABEL_ERROR_PAGE_HINT = "label_error_page_hint";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The server API this build needs (MIN_NATIVE_API in serverAddress.ts). A
|
* The server API this build needs (MIN_NATIVE_API in serverAddress.ts). A
|
||||||
@@ -33,10 +34,11 @@ final class TrekServerStore {
|
|||||||
* launch after an update that raised it puts the address screen back up,
|
* launch after an update that raised it puts the address screen back up,
|
||||||
* filled in with that server (getPreviousUrl). Raise both together.
|
* filled in with that server (getPreviousUrl). Raise both together.
|
||||||
*/
|
*/
|
||||||
private static final int SERVER_CHECK = 2;
|
private static final int SERVER_CHECK = 3;
|
||||||
private static final String KEY_SIGN_IN_HOSTS = "sign_in_hosts";
|
private static final String KEY_SIGN_IN_HOSTS = "sign_in_hosts";
|
||||||
private static final String KEY_SHELL_ONCE = "shell_once";
|
private static final String KEY_SHELL_ONCE = "shell_once";
|
||||||
private static final String KEY_RESTART = "restart";
|
private static final String KEY_RESTART = "restart";
|
||||||
|
private static final String KEY_OFFLINE_START = "offline_start";
|
||||||
private static final String KEY_WELCOME = "welcome";
|
private static final String KEY_WELCOME = "welcome";
|
||||||
private static final String CONFIG_DIR = "trek-server-config";
|
private static final String CONFIG_DIR = "trek-server-config";
|
||||||
|
|
||||||
@@ -83,13 +85,21 @@ final class TrekServerStore {
|
|||||||
* as the address screen passed them (setServer's `labels`): the server's UI
|
* as the address screen passed them (setServer's `labels`): the server's UI
|
||||||
* is not there to say them. Null keeps the English fallback.
|
* is not there to say them. Null keeps the English fallback.
|
||||||
*/
|
*/
|
||||||
static void setLabels(Context context, String signInHint, String changeServer) {
|
static void setLabels(Context context, String signInHint, String changeServer, String errorPageHint) {
|
||||||
SharedPreferences.Editor editor = prefs(context).edit();
|
SharedPreferences.Editor editor = prefs(context).edit();
|
||||||
if (signInHint != null) editor.putString(KEY_LABEL_SIGN_IN_HINT, signInHint);
|
if (signInHint != null) editor.putString(KEY_LABEL_SIGN_IN_HINT, signInHint);
|
||||||
if (changeServer != null) editor.putString(KEY_LABEL_CHANGE_SERVER, changeServer);
|
if (changeServer != null) editor.putString(KEY_LABEL_CHANGE_SERVER, changeServer);
|
||||||
|
if (errorPageHint != null) editor.putString(KEY_LABEL_ERROR_PAGE_HINT, errorPageHint);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static String errorPageHintLabel(Context context) {
|
||||||
|
return prefs(context).getString(
|
||||||
|
KEY_LABEL_ERROR_PAGE_HINT,
|
||||||
|
"This page is not from TREK: the server or a proxy in front of it refused the app. Check your proxy or certificate, or change the server."
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
static String signInHintLabel(Context context) {
|
static String signInHintLabel(Context context) {
|
||||||
return prefs(context).getString(
|
return prefs(context).getString(
|
||||||
KEY_LABEL_SIGN_IN_HINT,
|
KEY_LABEL_SIGN_IN_HINT,
|
||||||
@@ -147,6 +157,24 @@ final class TrekServerStore {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Start the next launch on the bundled address screen, even with a server remembered. */
|
/** Start the next launch on the bundled address screen, even with a server remembered. */
|
||||||
|
private static final String KEY_FAILURE = "last_failure";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Why the server's page did not load, in the WebView's own terms
|
||||||
|
* ("net::ERR_NAME_NOT_RESOLVED (-2)", "HTTP 503"): the address screen shows
|
||||||
|
* it small under its message, so a report carries the cause.
|
||||||
|
*/
|
||||||
|
static void setFailure(Context context, String failure) {
|
||||||
|
prefs(context).edit().putString(KEY_FAILURE, failure).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The failure behind this address screen, once. */
|
||||||
|
static String takeFailure(Context context) {
|
||||||
|
String failure = prefs(context).getString(KEY_FAILURE, null);
|
||||||
|
if (failure != null) prefs(context).edit().remove(KEY_FAILURE).commit();
|
||||||
|
return failure;
|
||||||
|
}
|
||||||
|
|
||||||
static void showShellOnce(Context context) {
|
static void showShellOnce(Context context) {
|
||||||
prefs(context).edit().putBoolean(KEY_SHELL_ONCE, true).commit();
|
prefs(context).edit().putBoolean(KEY_SHELL_ONCE, true).commit();
|
||||||
}
|
}
|
||||||
@@ -164,6 +192,37 @@ final class TrekServerStore {
|
|||||||
return consume(context, KEY_RESTART);
|
return consume(context, KEY_RESTART);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The next onCreate starts on the stored copy of the server's UI (TrekOfflineShell). */
|
||||||
|
static void markOfflineStart(Context context) {
|
||||||
|
prefs(context).edit().putBoolean(KEY_OFFLINE_START, true).commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
static boolean consumeOfflineStart(Context context) {
|
||||||
|
return consume(context, KEY_OFFLINE_START);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The remembered server, or the one an update asked to check again: the
|
||||||
|
* server the stored copy of the UI belongs to.
|
||||||
|
*/
|
||||||
|
static String getUrlOrPrevious(Context context) {
|
||||||
|
String url = getUrl(context);
|
||||||
|
return url != null ? url : getPreviousUrl(context);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starting on the stored copy while the check an update asked for could not
|
||||||
|
* run: the server goes back in place, unchecked for now, and the check runs
|
||||||
|
* again on the next launch, which reaches the server.
|
||||||
|
*/
|
||||||
|
static void restoreForOffline(Context context) {
|
||||||
|
SharedPreferences prefs = prefs(context);
|
||||||
|
if (prefs.getString(KEY_URL, null) != null) return;
|
||||||
|
String previous = prefs.getString(KEY_PREVIOUS_URL, null);
|
||||||
|
if (previous == null) return;
|
||||||
|
prefs.edit().putString(KEY_URL, previous).remove(KEY_PREVIOUS_URL).putInt(KEY_SERVER_CHECK, 0).commit();
|
||||||
|
}
|
||||||
|
|
||||||
private static boolean consume(Context context, String key) {
|
private static boolean consume(Context context, String key) {
|
||||||
boolean set = prefs(context).getBoolean(key, false);
|
boolean set = prefs(context).getBoolean(key, false);
|
||||||
if (set) prefs(context).edit().remove(key).commit();
|
if (set) prefs(context).edit().remove(key).commit();
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package com.liketrek.trek;
|
|||||||
|
|
||||||
import android.Manifest;
|
import android.Manifest;
|
||||||
import android.content.ActivityNotFoundException;
|
import android.content.ActivityNotFoundException;
|
||||||
|
import android.content.Context;
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
@@ -314,6 +315,8 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
JSObject result = new JSObject();
|
JSObject result = new JSObject();
|
||||||
result.put("url", url == null ? JSONObject.NULL : url);
|
result.put("url", url == null ? JSONObject.NULL : url);
|
||||||
result.put("previousUrl", previous == null ? JSONObject.NULL : previous);
|
result.put("previousUrl", previous == null ? JSONObject.NULL : previous);
|
||||||
|
String failure = TrekServerStore.takeFailure(getContext());
|
||||||
|
result.put("failure", failure == null ? JSONObject.NULL : failure);
|
||||||
call.resolve(result);
|
call.resolve(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -328,7 +331,12 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
TrekServerStore.setServer(getContext(), url, signInHostsOf(call));
|
TrekServerStore.setServer(getContext(), url, signInHostsOf(call));
|
||||||
JSObject labels = call.getObject("labels");
|
JSObject labels = call.getObject("labels");
|
||||||
if (labels != null) {
|
if (labels != null) {
|
||||||
TrekServerStore.setLabels(getContext(), labels.getString("signInHint"), labels.getString("changeServer"));
|
TrekServerStore.setLabels(
|
||||||
|
getContext(),
|
||||||
|
labels.getString("signInHint"),
|
||||||
|
labels.getString("changeServer"),
|
||||||
|
labels.getString("errorPageHint")
|
||||||
|
);
|
||||||
}
|
}
|
||||||
// A TREK Cloud purchase: the code that signs the buyer in, opened once after the first page.
|
// A TREK Cloud purchase: the code that signs the buyer in, opened once after the first page.
|
||||||
String welcome = call.getString("welcome");
|
String welcome = call.getString("welcome");
|
||||||
@@ -428,7 +436,11 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
}
|
}
|
||||||
Uri data = intent.getData();
|
Uri data = intent.getData();
|
||||||
PluginCall call = pendingAuthCall();
|
PluginCall call = pendingAuthCall();
|
||||||
if (call == null || data == null || !authScheme.equals(data.getScheme())) return;
|
if (call == null) {
|
||||||
|
keepOrphanAuthReturn(intent);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (data == null || !authScheme.equals(data.getScheme())) return;
|
||||||
JSObject result = new JSObject();
|
JSObject result = new JSObject();
|
||||||
result.put("url", data.toString());
|
result.put("url", data.toString());
|
||||||
call.resolve(result);
|
call.resolve(result);
|
||||||
@@ -454,6 +466,48 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
}, CANCEL_GRACE_MS);
|
}, CANCEL_GRACE_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final String AUTH_PREFS = "trek_auth_return";
|
||||||
|
/** As long as the server keeps the code it carries (NATIVE_HANDOFF_CODE_TTL_MS), with room to spare. */
|
||||||
|
private static final long ORPHAN_AUTH_TTL_MS = 2 * 60 * 1000;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A return to the sign-in scheme with no call waiting for it: Android ended
|
||||||
|
* the app while the browser was in front, and the browser's return started
|
||||||
|
* it anew (the launch intent comes through here as well). Kept on disk, as
|
||||||
|
* the process may be new too, until the sign-in page takes it. The return
|
||||||
|
* is then taken off the activity's intent: Capacitor hands the launch intent
|
||||||
|
* in again whenever the activity is created, and Android does as well when
|
||||||
|
* it rebuilds the task from the recent apps.
|
||||||
|
*/
|
||||||
|
private void keepOrphanAuthReturn(Intent intent) {
|
||||||
|
Uri data = intent.getData();
|
||||||
|
if (data == null || !"auth".equals(data.getHost())) return;
|
||||||
|
if (!getContext().getString(R.string.custom_url_scheme).equals(data.getScheme())) return;
|
||||||
|
if (getActivity() != null && getActivity().getIntent() != null && getActivity().getIntent().getData() != null
|
||||||
|
&& data.equals(getActivity().getIntent().getData())) {
|
||||||
|
getActivity().setIntent(new Intent(getActivity().getIntent()).setData(null));
|
||||||
|
}
|
||||||
|
if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) != 0) return;
|
||||||
|
getContext().getSharedPreferences(AUTH_PREFS, Context.MODE_PRIVATE)
|
||||||
|
.edit()
|
||||||
|
.putString("url", data.toString())
|
||||||
|
.putLong("at", System.currentTimeMillis())
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The kept return of a sign-in (keepOrphanAuthReturn), once and while fresh; null otherwise. */
|
||||||
|
@PluginMethod
|
||||||
|
public void takeAuthCallback(PluginCall call) {
|
||||||
|
android.content.SharedPreferences prefs = getContext().getSharedPreferences(AUTH_PREFS, Context.MODE_PRIVATE);
|
||||||
|
String url = prefs.getString("url", null);
|
||||||
|
long at = prefs.getLong("at", 0);
|
||||||
|
prefs.edit().clear().commit();
|
||||||
|
boolean fresh = url != null && System.currentTimeMillis() - at <= ORPHAN_AUTH_TTL_MS;
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
result.put("url", fresh ? url : JSONObject.NULL);
|
||||||
|
call.resolve(result);
|
||||||
|
}
|
||||||
|
|
||||||
private PluginCall pendingAuthCall() {
|
private PluginCall pendingAuthCall() {
|
||||||
return authCallId == null ? null : getBridge().getSavedCall(authCallId);
|
return authCallId == null ? null : getBridge().getSavedCall(authCallId);
|
||||||
}
|
}
|
||||||
@@ -472,19 +526,108 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
authBrowserOpen = false;
|
authBrowserOpen = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** iOS only: Android keeps the service worker, which already starts TREK offline. */
|
/**
|
||||||
|
* Keeps the server's UI on the device for a start without the server
|
||||||
|
* (TrekOfflineShell): the start page, and each file of the build that
|
||||||
|
* native/offlineShell.ts lists from the server's manifest and the copy does
|
||||||
|
* not hold yet. Once all of them are there, files of older builds go. A web
|
||||||
|
* view runs no service worker on a plain-http server, the usual address of a
|
||||||
|
* server at home, so without this the app could not start away from it.
|
||||||
|
*/
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void refreshOfflineCopy(PluginCall call) {
|
public void refreshOfflineCopy(PluginCall call) {
|
||||||
JSObject result = new JSObject();
|
Context context = getContext();
|
||||||
result.put("saved", false);
|
String server = TrekServerStore.getUrl(context);
|
||||||
call.resolve(result);
|
JSArray listed = call.getArray("files");
|
||||||
|
if (server == null || TrekOfflineShell.isActive()) {
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
result.put("saved", false);
|
||||||
|
call.resolve(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
new Thread(() -> {
|
||||||
|
JSObject result = new JSObject();
|
||||||
|
byte[] page = download(server, "", "text/html");
|
||||||
|
boolean complete = page != null && TrekOfflineShell.beginRefresh(context, server);
|
||||||
|
Set<String> keep = new HashSet<>();
|
||||||
|
if (complete && listed != null) {
|
||||||
|
for (int i = 0; i < listed.length(); i++) {
|
||||||
|
String path = listed.optString(i, null);
|
||||||
|
if (path == null || path.isEmpty()) continue;
|
||||||
|
String clean = path.startsWith("/") ? path.substring(1) : path;
|
||||||
|
keep.add(clean);
|
||||||
|
if (clean.contains("/") && TrekOfflineShell.hasFile(context, clean)) continue;
|
||||||
|
byte[] data = download(server, clean, null);
|
||||||
|
if (data == null || !TrekOfflineShell.saveFile(context, clean, data)) complete = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// The new page goes in last: until all its files are there the
|
||||||
|
// stored page stays the previous one, whose build is still whole.
|
||||||
|
boolean saved = complete && TrekOfflineShell.savePage(context, server, page);
|
||||||
|
complete = saved;
|
||||||
|
if (saved && listed != null) TrekOfflineShell.prune(context, keep);
|
||||||
|
result.put("saved", saved);
|
||||||
|
result.put("complete", complete);
|
||||||
|
call.resolve(result);
|
||||||
|
}).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A file of the server's UI, or null: only a 200 from the server itself
|
||||||
|
* counts, the page only as HTML and a file only as something else.
|
||||||
|
*/
|
||||||
|
private static byte[] download(String server, String path, String wantType) {
|
||||||
|
java.net.HttpURLConnection connection = null;
|
||||||
|
try {
|
||||||
|
java.net.URL base = new java.net.URL(server.endsWith("/") ? server : server + "/");
|
||||||
|
java.net.URL url = new java.net.URL(base, path);
|
||||||
|
connection = (java.net.HttpURLConnection) url.openConnection();
|
||||||
|
connection.setConnectTimeout(15000);
|
||||||
|
connection.setReadTimeout(30000);
|
||||||
|
connection.setInstanceFollowRedirects(true);
|
||||||
|
if (wantType != null) connection.setRequestProperty("Accept", wantType);
|
||||||
|
if (connection.getResponseCode() != 200) return null;
|
||||||
|
java.net.URL landed = connection.getURL();
|
||||||
|
if (!landed.getProtocol().equals(base.getProtocol()) || !landed.getHost().equalsIgnoreCase(base.getHost()) || portOf(landed) != portOf(base)) return null;
|
||||||
|
String type = connection.getContentType();
|
||||||
|
if (wantType != null && (type == null || !type.startsWith(wantType))) return null;
|
||||||
|
if (wantType == null && type != null && type.startsWith("text/html") && !path.endsWith(".html")) return null;
|
||||||
|
try (java.io.InputStream in = connection.getInputStream()) {
|
||||||
|
java.io.ByteArrayOutputStream out = new java.io.ByteArrayOutputStream();
|
||||||
|
byte[] buffer = new byte[16384];
|
||||||
|
for (int n = in.read(buffer); n > 0; n = in.read(buffer)) out.write(buffer, 0, n);
|
||||||
|
return out.toByteArray();
|
||||||
|
}
|
||||||
|
} catch (java.io.IOException | RuntimeException e) {
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
if (connection != null) connection.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int portOf(java.net.URL url) {
|
||||||
|
return url.getPort() == -1 ? url.getDefaultPort() : url.getPort();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The address screen found the server out of reach: with a copy of its UI
|
||||||
|
* the app restarts on that instead (TrekOfflineShell), the same way it
|
||||||
|
* leaves the server for the address screen. Also for the server an update
|
||||||
|
* asked to check again, whose check then waits for the next launch.
|
||||||
|
*/
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void openOfflineCopy(PluginCall call) {
|
public void openOfflineCopy(PluginCall call) {
|
||||||
|
Context context = getContext();
|
||||||
JSObject result = new JSObject();
|
JSObject result = new JSObject();
|
||||||
result.put("opened", false);
|
if (!TrekOfflineShell.hasCopy(context, TrekServerStore.getUrlOrPrevious(context)) || getActivity() == null) {
|
||||||
|
result.put("opened", false);
|
||||||
|
call.resolve(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TrekServerStore.markOfflineStart(context);
|
||||||
|
result.put("opened", true);
|
||||||
call.resolve(result);
|
call.resolve(result);
|
||||||
|
restart();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- Widgets, shortcuts and the travel day ----
|
// ---- Widgets, shortcuts and the travel day ----
|
||||||
@@ -679,6 +822,12 @@ public class TrekShellPlugin extends Plugin {
|
|||||||
com.liketrek.trek.billing.TrekBilling.INSTANCE.restore(getContext(), call);
|
com.liketrek.trek.billing.TrekBilling.INSTANCE.restore(getContext(), call);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether this Google account already holds a delivered cloud subscription. */
|
||||||
|
@PluginMethod
|
||||||
|
public void storeHeld(PluginCall call) {
|
||||||
|
com.liketrek.trek.billing.TrekBilling.INSTANCE.held(getContext(), call);
|
||||||
|
}
|
||||||
|
|
||||||
/** A paid subscription never delivered (it cleared while the app was closed), for the shell to redeem. */
|
/** A paid subscription never delivered (it cleared while the app was closed), for the shell to redeem. */
|
||||||
@PluginMethod
|
@PluginMethod
|
||||||
public void storeUnfinished(PluginCall call) {
|
public void storeUnfinished(PluginCall call) {
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.liketrek.trek;
|
package com.liketrek.trek;
|
||||||
|
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
|
import android.util.Log;
|
||||||
import android.webkit.ClientCertRequest;
|
import android.webkit.ClientCertRequest;
|
||||||
import android.webkit.WebResourceError;
|
import android.webkit.WebResourceError;
|
||||||
import android.webkit.WebResourceRequest;
|
import android.webkit.WebResourceRequest;
|
||||||
import android.webkit.WebResourceResponse;
|
import android.webkit.WebResourceResponse;
|
||||||
import android.webkit.WebView;
|
import android.webkit.WebView;
|
||||||
|
import android.webkit.WebViewClient;
|
||||||
import com.getcapacitor.Bridge;
|
import com.getcapacitor.Bridge;
|
||||||
import com.getcapacitor.BridgeWebViewClient;
|
import com.getcapacitor.BridgeWebViewClient;
|
||||||
import com.liketrek.trek.clientcert.TrekClientIdentity;
|
import com.liketrek.trek.clientcert.TrekClientIdentity;
|
||||||
@@ -27,14 +29,31 @@ class TrekWebViewClient extends BridgeWebViewClient {
|
|||||||
private final Runnable onUnreachable;
|
private final Runnable onUnreachable;
|
||||||
/** Told whether the page now shown is a proxy's sign-in page, for the bar with the way out. */
|
/** Told whether the page now shown is a proxy's sign-in page, for the bar with the way out. */
|
||||||
private final Consumer<Boolean> onSignInPage;
|
private final Consumer<Boolean> onSignInPage;
|
||||||
|
/** Told whether the page now shown is an error page in place of the server's, for the same bar. */
|
||||||
|
private final Consumer<Boolean> onErrorPage;
|
||||||
|
/** The main-frame address that last came back as a 4xx page nobody else handled. */
|
||||||
|
private String errorPageUrl;
|
||||||
private final Set<String> signInHosts;
|
private final Set<String> signInHosts;
|
||||||
/** A page of the server has shown since launch; from then on no sign-in host is learned (SignInRedirect). */
|
/** A page of the server has shown since launch; from then on no sign-in host is learned (SignInRedirect). */
|
||||||
private boolean serverShown;
|
private boolean serverShown;
|
||||||
|
/** The page itself failed on the network once already; the next failure goes to the address screen. */
|
||||||
|
private boolean retriedMainFrame;
|
||||||
|
/** The page loaded again after a network error, until that load starts: its error page counts for nothing. */
|
||||||
|
private String retryUrl;
|
||||||
|
private final Bridge bridge;
|
||||||
|
|
||||||
TrekWebViewClient(Bridge bridge, Runnable onUnreachable, Consumer<Boolean> onSignInPage, Set<String> signInHosts) {
|
TrekWebViewClient(
|
||||||
|
Bridge bridge,
|
||||||
|
Runnable onUnreachable,
|
||||||
|
Consumer<Boolean> onSignInPage,
|
||||||
|
Consumer<Boolean> onErrorPage,
|
||||||
|
Set<String> signInHosts
|
||||||
|
) {
|
||||||
super(bridge);
|
super(bridge);
|
||||||
|
this.bridge = bridge;
|
||||||
this.onUnreachable = onUnreachable;
|
this.onUnreachable = onUnreachable;
|
||||||
this.onSignInPage = onSignInPage;
|
this.onSignInPage = onSignInPage;
|
||||||
|
this.onErrorPage = onErrorPage;
|
||||||
this.signInHosts = new HashSet<>(signInHosts);
|
this.signInHosts = new HashSet<>(signInHosts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,13 +88,22 @@ class TrekWebViewClient extends BridgeWebViewClient {
|
|||||||
@Override
|
@Override
|
||||||
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
|
public void doUpdateVisitedHistory(WebView view, String url, boolean isReload) {
|
||||||
super.doUpdateVisitedHistory(view, url, isReload);
|
super.doUpdateVisitedHistory(view, url, isReload);
|
||||||
|
if (retryUrl != null) return;
|
||||||
onSignInPage.accept(url != null && isSignInHost(Uri.parse(url)));
|
onSignInPage.accept(url != null && isSignInHost(Uri.parse(url)));
|
||||||
|
// The 4xx answer arrives before this commit or after it; either way the
|
||||||
|
// flag is read once here, so the next page clears the bar again.
|
||||||
|
boolean error = url != null && url.equals(errorPageUrl);
|
||||||
|
errorPageUrl = null;
|
||||||
|
onErrorPage.accept(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** After the server's first page, a pending welcome code opens the welcome page once (TrekServerStore.takeWelcomeUrl). */
|
/** After the server's first page, a pending welcome code opens the welcome page once (TrekServerStore.takeWelcomeUrl). */
|
||||||
@Override
|
@Override
|
||||||
public void onPageFinished(WebView view, String url) {
|
public void onPageFinished(WebView view, String url) {
|
||||||
super.onPageFinished(view, url);
|
super.onPageFinished(view, url);
|
||||||
|
// The error page of a load that is about to be retried: not the server's
|
||||||
|
// first page, so no welcome page and no learning of sign-in hosts yet.
|
||||||
|
if (retryUrl != null) return;
|
||||||
if (SignInRedirect.onServer(TrekServerStore.getUrl(view.getContext()), url)) serverShown = true;
|
if (SignInRedirect.onServer(TrekServerStore.getUrl(view.getContext()), url)) serverShown = true;
|
||||||
String welcome = TrekServerStore.takeWelcomeUrl(view.getContext());
|
String welcome = TrekServerStore.takeWelcomeUrl(view.getContext());
|
||||||
if (welcome != null) view.loadUrl(welcome);
|
if (welcome != null) view.loadUrl(welcome);
|
||||||
@@ -89,9 +117,15 @@ class TrekWebViewClient extends BridgeWebViewClient {
|
|||||||
return signInHosts.contains(key) || (url.getPort() != -1 && signInHosts.contains(key + ":" + url.getPort()));
|
return signInHosts.contains(key) || (url.getPort() != -1 && signInHosts.contains(key + ":" + url.getPort()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Mapbox's map resources go through the app's own store (tiles/TrekTileStore.kt). */
|
/**
|
||||||
|
* Mapbox's map resources go through the app's own store (tiles/TrekTileStore.kt),
|
||||||
|
* and while the server is out of reach the UI comes from its stored copy
|
||||||
|
* (TrekOfflineShell).
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) {
|
||||||
|
WebResourceResponse copy = TrekOfflineShell.serve(view.getContext(), bridge, TrekServerStore.getUrl(view.getContext()), request);
|
||||||
|
if (copy != null) return copy;
|
||||||
if (com.liketrek.trek.tiles.TrekTileStore.INSTANCE.handles(request)) {
|
if (com.liketrek.trek.tiles.TrekTileStore.INSTANCE.handles(request)) {
|
||||||
WebResourceResponse stored = com.liketrek.trek.tiles.TrekTileStore.INSTANCE.serve(request);
|
WebResourceResponse stored = com.liketrek.trek.tiles.TrekTileStore.INSTANCE.serve(request);
|
||||||
if (stored != null) return stored;
|
if (stored != null) return stored;
|
||||||
@@ -117,13 +151,44 @@ class TrekWebViewClient extends BridgeWebViewClient {
|
|||||||
String server = TrekServerStore.getUrl(view.getContext());
|
String server = TrekServerStore.getUrl(view.getContext());
|
||||||
Uri serverUri = server == null ? null : Uri.parse(server);
|
Uri serverUri = server == null ? null : Uri.parse(server);
|
||||||
if (serverUri != null && TrekClientIdentity.matches(String.valueOf(serverUri.getHost()), serverUri.getPort() > 0 ? serverUri.getPort() : 443, request.getHost(), request.getPort())) {
|
if (serverUri != null && TrekClientIdentity.matches(String.valueOf(serverUri.getHost()), serverUri.getPort() > 0 ? serverUri.getPort() : 443, request.getHost(), request.getPort())) {
|
||||||
com.liketrek.trek.clientcert.ClientCertWatch.serverAsked(view.getContext(), server, onUnreachable);
|
com.liketrek.trek.clientcert.ClientCertWatch.serverAsked(view.getContext(), server, () -> {
|
||||||
|
TrekServerStore.setFailure(view.getContext(), "client certificate requested");
|
||||||
|
onUnreachable.run();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A page that failed on the network is loaded once more before the app says
|
||||||
|
* the server is unreachable. Started from the background, as when the
|
||||||
|
* browser hands a sign-in back to an app Android had ended, a Samsung phone
|
||||||
|
* may hold its network back for a moment, and the first load fails with the
|
||||||
|
* server there all along. The error is logged, as a report has nothing else.
|
||||||
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) {
|
||||||
if (request.isForMainFrame()) {
|
if (request.isForMainFrame()) {
|
||||||
|
Log.w("TrekShell", "Page failed: " + error.getErrorCode() + " " + error.getDescription());
|
||||||
|
if (!retriedMainFrame && isNetworkError(error.getErrorCode())) {
|
||||||
|
retriedMainFrame = true;
|
||||||
|
retryUrl = request.getUrl().toString();
|
||||||
|
view.postDelayed(() -> {
|
||||||
|
String url = retryUrl;
|
||||||
|
retryUrl = null;
|
||||||
|
view.loadUrl(url);
|
||||||
|
}, 1500);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Out of reach for good (a trip without reception, a server at home):
|
||||||
|
// the stored copy of the UI takes over, with the app's own offline data.
|
||||||
|
String server = TrekServerStore.getUrl(view.getContext());
|
||||||
|
if (isNetworkError(error.getErrorCode()) && !TrekOfflineShell.isActive() && TrekOfflineShell.hasCopy(view.getContext(), server)) {
|
||||||
|
TrekOfflineShell.activate(server);
|
||||||
|
String url = request.getUrl().toString();
|
||||||
|
view.post(() -> view.loadUrl(url));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
TrekServerStore.setFailure(view.getContext(), error.getDescription() + " (" + error.getErrorCode() + ")");
|
||||||
onUnreachable.run();
|
onUnreachable.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -132,19 +197,42 @@ class TrekWebViewClient extends BridgeWebViewClient {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Only a 5xx on the page itself means the server is down (a proxy's 502 or
|
* Only a 5xx on the page itself means the server is down (a proxy's 502 or
|
||||||
* 503 while TREK restarts). A 4xx page is left alone: the server answered,
|
* 503 while TREK restarts). A 4xx page is not TREK's, which serves its UI for
|
||||||
* and TREK serves its UI for every other path. The exception is a proxy
|
* every path: a proxy that asked this page for a client certificate and got
|
||||||
* that asked this page for a client certificate and got none, as Cloudflare
|
* none, as Cloudflare does with a 403, sends the app to the address screen,
|
||||||
* does with a 403: the address screen then says so and offers to add one.
|
* which says so and offers to add one. Any other 4xx page (a proxy's block
|
||||||
|
* page, a certificate it refused) stays up with the bar and its way out, so
|
||||||
|
* the app is never stuck on a page without TREK's UI. Each one is logged
|
||||||
|
* with its address and whoever answered it (PageErrorLog).
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
public void onReceivedHttpError(WebView view, WebResourceRequest request, WebResourceResponse errorResponse) {
|
||||||
int status = errorResponse.getStatusCode();
|
int status = errorResponse.getStatusCode();
|
||||||
if (!request.isForMainFrame()) {
|
if (!request.isForMainFrame()) {
|
||||||
super.onReceivedHttpError(view, request, errorResponse);
|
super.onReceivedHttpError(view, request, errorResponse);
|
||||||
} else if (status >= 500 || (status >= 400 && wantedCertificate(request.getUrl()))) {
|
return;
|
||||||
onUnreachable.run();
|
|
||||||
}
|
}
|
||||||
|
Log.w("TrekShell", PageErrorLog.describe(
|
||||||
|
request.getUrl().toString(),
|
||||||
|
status,
|
||||||
|
errorResponse.getReasonPhrase(),
|
||||||
|
errorResponse.getResponseHeaders()
|
||||||
|
));
|
||||||
|
if (status >= 500 || (status >= 400 && wantedCertificate(request.getUrl()))) {
|
||||||
|
TrekServerStore.setFailure(view.getContext(), "HTTP " + status);
|
||||||
|
onUnreachable.run();
|
||||||
|
} else if (status >= 400) {
|
||||||
|
errorPageUrl = request.getUrl().toString();
|
||||||
|
onErrorPage.accept(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isNetworkError(int code) {
|
||||||
|
return code == WebViewClient.ERROR_HOST_LOOKUP
|
||||||
|
|| code == WebViewClient.ERROR_CONNECT
|
||||||
|
|| code == WebViewClient.ERROR_TIMEOUT
|
||||||
|
|| code == WebViewClient.ERROR_IO
|
||||||
|
|| code == WebViewClient.ERROR_UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean wantedCertificate(Uri url) {
|
private static boolean wantedCertificate(Uri url) {
|
||||||
|
|||||||
@@ -119,23 +119,38 @@ object TrekBilling {
|
|||||||
val id = call.getString("productId") ?: return call.reject("productId is required")
|
val id = call.getString("productId") ?: return call.reject("productId is required")
|
||||||
ready(activity) { ok ->
|
ready(activity) { ok ->
|
||||||
if (!ok) return@ready call.resolve(JSObject().put("kind", "failed"))
|
if (!ok) return@ready call.resolve(JSObject().put("kind", "failed"))
|
||||||
details(activity, listOf(id)) { found ->
|
// One subscription per Google account: a second plan would run beside the first.
|
||||||
val product = found.firstOrNull()
|
// A delivered one stops the purchase here; one that was paid but never set up is
|
||||||
val offer = product?.let(::baseOffer)
|
// handed back as bought, so its instance is set up now.
|
||||||
if (product == null || offer == null) return@details call.resolve(JSObject().put("kind", "failed"))
|
val params = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.SUBS).build()
|
||||||
pendingPurchase?.resolve(JSObject().put("kind", "cancelled"))
|
client(activity).queryPurchasesAsync(params) { result, purchases ->
|
||||||
pendingPurchase = call
|
val held = if (result.responseCode == BillingClient.BillingResponseCode.OK) newest(purchases, PREFIX) else null
|
||||||
pendingProduct = id
|
when {
|
||||||
val params = BillingFlowParams.newBuilder()
|
held == null -> launchPurchase(activity, call, id)
|
||||||
.setProductDetailsParamsList(
|
held.isAcknowledged -> call.resolve(JSObject().put("kind", "subscribed"))
|
||||||
listOf(BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(product).setOfferToken(offer.offerToken).build()),
|
else -> call.resolve(receipt(held).put("kind", "bought"))
|
||||||
)
|
}
|
||||||
.build()
|
}
|
||||||
activity.runOnUiThread {
|
}
|
||||||
val launch = client(activity).launchBillingFlow(activity, params)
|
}
|
||||||
if (launch.responseCode != BillingClient.BillingResponseCode.OK) {
|
|
||||||
settle(if (launch.responseCode == BillingClient.BillingResponseCode.USER_CANCELED) "cancelled" else "failed", null)
|
private fun launchPurchase(activity: Activity, call: PluginCall, id: String) {
|
||||||
}
|
details(activity, listOf(id)) { found ->
|
||||||
|
val product = found.firstOrNull()
|
||||||
|
val offer = product?.let(::baseOffer)
|
||||||
|
if (product == null || offer == null) return@details call.resolve(JSObject().put("kind", "failed"))
|
||||||
|
pendingPurchase?.resolve(JSObject().put("kind", "cancelled"))
|
||||||
|
pendingPurchase = call
|
||||||
|
pendingProduct = id
|
||||||
|
val params = BillingFlowParams.newBuilder()
|
||||||
|
.setProductDetailsParamsList(
|
||||||
|
listOf(BillingFlowParams.ProductDetailsParams.newBuilder().setProductDetails(product).setOfferToken(offer.offerToken).build()),
|
||||||
|
)
|
||||||
|
.build()
|
||||||
|
activity.runOnUiThread {
|
||||||
|
val launch = client(activity).launchBillingFlow(activity, params)
|
||||||
|
if (launch.responseCode != BillingClient.BillingResponseCode.OK) {
|
||||||
|
settle(if (launch.responseCode == BillingClient.BillingResponseCode.USER_CANCELED) "cancelled" else "failed", null)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -208,6 +223,19 @@ object TrekBilling {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Whether this Google account holds a delivered subscription under `prefix`; while one runs, the shell offers no purchase. */
|
||||||
|
fun held(context: Context, call: PluginCall) {
|
||||||
|
val prefix = call.getString("prefix") ?: PREFIX
|
||||||
|
ready(context) { ok ->
|
||||||
|
if (!ok) return@ready call.resolve(JSObject().put("held", false))
|
||||||
|
val params = QueryPurchasesParams.newBuilder().setProductType(BillingClient.ProductType.SUBS).build()
|
||||||
|
client(context).queryPurchasesAsync(params) { result, purchases ->
|
||||||
|
val found = if (result.responseCode == BillingClient.BillingResponseCode.OK) newest(purchases, prefix) else null
|
||||||
|
call.resolve(JSObject().put("held", found?.isAcknowledged == true))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** The newest active subscription under `prefix` on this Google account, if any. */
|
/** The newest active subscription under `prefix` on this Google account, if any. */
|
||||||
fun restore(context: Context, call: PluginCall) {
|
fun restore(context: Context, call: PluginCall) {
|
||||||
val prefix = call.getString("prefix") ?: "cloud."
|
val prefix = call.getString("prefix") ?: "cloud."
|
||||||
|
|||||||
@@ -32,6 +32,10 @@ class BookingsWidgetReceiver : TrekWidgetReceiver() {
|
|||||||
override val glanceAppWidget: GlanceAppWidget = BookingsWidget()
|
override val glanceAppWidget: GlanceAppWidget = BookingsWidget()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class FlightWidgetReceiver : TrekWidgetReceiver() {
|
||||||
|
override val glanceAppWidget: GlanceAppWidget = FlightWidget()
|
||||||
|
}
|
||||||
|
|
||||||
class TodosWidgetReceiver : TrekWidgetReceiver() {
|
class TodosWidgetReceiver : TrekWidgetReceiver() {
|
||||||
override val glanceAppWidget: GlanceAppWidget = TodosWidget()
|
override val glanceAppWidget: GlanceAppWidget = TodosWidget()
|
||||||
}
|
}
|
||||||
@@ -56,6 +60,7 @@ object TrekWidgetUpdater {
|
|||||||
TripWidgetReceiver::class,
|
TripWidgetReceiver::class,
|
||||||
TodayWidgetReceiver::class,
|
TodayWidgetReceiver::class,
|
||||||
BookingsWidgetReceiver::class,
|
BookingsWidgetReceiver::class,
|
||||||
|
FlightWidgetReceiver::class,
|
||||||
TodosWidgetReceiver::class,
|
TodosWidgetReceiver::class,
|
||||||
PackingWidgetReceiver::class,
|
PackingWidgetReceiver::class,
|
||||||
AtlasWidgetReceiver::class,
|
AtlasWidgetReceiver::class,
|
||||||
|
|||||||
@@ -82,10 +82,12 @@ abstract class TrekWidget : GlanceAppWidget() {
|
|||||||
// Read inside the composition: a session outlives one update, and every
|
// Read inside the composition: a session outlives one update, and every
|
||||||
// write (the dashboard's, then each trip's) must reach it.
|
// write (the dashboard's, then each trip's) must reach it.
|
||||||
val version by WidgetStore.version.collectAsState()
|
val version by WidgetStore.version.collectAsState()
|
||||||
val snapshot = remember(version) {
|
val stored = remember(version) {
|
||||||
val tripId = if (perTrip && appWidgetId >= 0) WidgetStore.tripFor(context, appWidgetId) else WidgetStore.AUTO
|
val tripId = if (perTrip && appWidgetId >= 0) WidgetStore.tripFor(context, appWidgetId) else WidgetStore.AUTO
|
||||||
WidgetStore.load(context, tripId)
|
WidgetStore.load(context, tripId)
|
||||||
}
|
}
|
||||||
|
// The day of the trip is today's on every update, not the one the app last wrote.
|
||||||
|
val snapshot = stored?.on(LocalDate.now())
|
||||||
TrekWidgetTheme.Themed { Content(snapshot) }
|
TrekWidgetTheme.Themed { Content(snapshot) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -448,6 +450,173 @@ private fun BookingRow(booking: WidgetSnapshot.Booking, labels: WidgetSnapshot.L
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ---- Flight ----
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Where a flight stands now (as FlightMoment on iOS). What the feed saw wins: a
|
||||||
|
* flight still at the gate past its planned departure is not flown along the
|
||||||
|
* arc, and it is only landed once confirmed. Only a flight the feed never heard
|
||||||
|
* of moves on by its schedule alone; a lost one stops two hours after arrival.
|
||||||
|
*/
|
||||||
|
private class FlightMoment(f: WidgetSnapshot.Flight, nowSeconds: Long) {
|
||||||
|
val start: Long = f.depActual ?: f.depExpected ?: f.dep
|
||||||
|
val end: Long = maxOf(f.arrExpected ?: f.arr, start + 60)
|
||||||
|
private val heard = f.seen != null
|
||||||
|
val landed = f.landed || (!heard && nowSeconds >= end) || nowSeconds >= end + 7200
|
||||||
|
val airborne = !landed && (f.airborne || f.depActual != null || (!heard && nowSeconds >= start))
|
||||||
|
val ready = !landed && !airborne && nowSeconds >= start
|
||||||
|
val progress: Float = when {
|
||||||
|
landed -> 1f
|
||||||
|
airborne -> ((nowSeconds - start).toFloat() / (end - start)).coerceIn(0f, 0.98f)
|
||||||
|
else -> 0f
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A duration in the app's words: "2 d 4 h", "1 h 5 min", "12 min". */
|
||||||
|
private fun durationText(seconds: Long, labels: WidgetSnapshot.Labels): String {
|
||||||
|
val minutes = ((seconds + 59) / 60).coerceAtLeast(1)
|
||||||
|
val days = minutes / 1440
|
||||||
|
val hours = (minutes % 1440) / 60
|
||||||
|
val rest = minutes % 60
|
||||||
|
return when {
|
||||||
|
days > 0 -> labels.durDaysHours.replace("{d}", "$days").replace("{h}", "$hours")
|
||||||
|
hours > 0 -> labels.durHoursMinutes.replace("{h}", "$hours").replace("{m}", "$rest")
|
||||||
|
else -> labels.durMinutes.replace("{m}", "$rest")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** "Departs in 2 h 10 min", "Lands in 1 h 5 min", "Landed". */
|
||||||
|
private fun momentText(m: FlightMoment, labels: WidgetSnapshot.Labels, nowSeconds: Long): String = when {
|
||||||
|
m.landed -> labels.flightLanded
|
||||||
|
m.ready -> labels.flightReady
|
||||||
|
m.airborne -> labels.flightLands.replace("{time}", durationText(m.end - nowSeconds, labels))
|
||||||
|
else -> labels.flightDeparts.replace("{time}", durationText(m.start - nowSeconds, labels))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The delay as a chip's text and colour; nothing to say without data. */
|
||||||
|
private fun delayChip(delay: Int?, labels: WidgetSnapshot.Labels): Pair<String, ColorProvider>? = when {
|
||||||
|
delay == null -> null
|
||||||
|
delay > 5 -> labels.flightLate.replace("{m}", "$delay") to (if (delay >= 30) TrekStatus.danger else TrekStatus.pending)
|
||||||
|
delay < -5 -> labels.flightEarly.replace("{m}", "${-delay}") to TrekStatus.confirmed
|
||||||
|
else -> labels.flightOnTime to TrekStatus.confirmed
|
||||||
|
}
|
||||||
|
|
||||||
|
private const val FLIGHT_BLUE = 0xFF4A7DDB.toInt()
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trip's next flight, or the one in the air: both airports large, the
|
||||||
|
* route as an arc with the aircraft on it, the moment in words and the delay.
|
||||||
|
* The arc and the words follow the clock each time the widget is drawn.
|
||||||
|
*/
|
||||||
|
class FlightWidget : TrekWidget() {
|
||||||
|
@Composable
|
||||||
|
override fun Content(snapshot: WidgetSnapshot?) {
|
||||||
|
val context = LocalContext.current
|
||||||
|
val size = LocalSize.current
|
||||||
|
val labels = snapshot?.labels ?: return EmptyWidget(WidgetSamples.emptyText(context))
|
||||||
|
val flight = snapshot.flight
|
||||||
|
WidgetFrame(onClick = openPath(context, flight?.path ?: snapshot.trip?.path ?: "/")) {
|
||||||
|
Column(modifier = GlanceModifier.fillMaxSize()) {
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically, modifier = GlanceModifier.fillMaxWidth()) {
|
||||||
|
Icon(Icons.Rounded.Flight, GlanceTheme.colors.primary, 14.dp)
|
||||||
|
Spacer(GlanceModifier.width(5.dp))
|
||||||
|
Eyebrow(flight?.number ?: labels.flight, GlanceTheme.colors.primary, GlanceModifier.defaultWeight())
|
||||||
|
flight?.let { f ->
|
||||||
|
delayChip(f.delay, labels)?.let { (text, color) ->
|
||||||
|
if (size.isWide || (f.delay ?: 0) > 5) Chip(text, GlanceTheme.colors.surfaceVariant, color)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (flight == null) {
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
Line(labels.noFlight, 14.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Medium, maxLines = 2)
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
} else {
|
||||||
|
FlightBody(flight, labels, size.isWide, size.isTall)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The origin stands on the right in a right-to-left layout, so the drawn arc is
|
||||||
|
* mirrored with it. Read from the locale the widget speaks, not from the
|
||||||
|
* Configuration, which a composition may not read directly.
|
||||||
|
*/
|
||||||
|
private fun isRtl(): Boolean =
|
||||||
|
android.text.TextUtils.getLayoutDirectionFromLocale(java.util.Locale.getDefault()) == android.view.View.LAYOUT_DIRECTION_RTL
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun ColumnScope.FlightBody(f: WidgetSnapshot.Flight, labels: WidgetSnapshot.Labels, wide: Boolean, tall: Boolean) {
|
||||||
|
val now = System.currentTimeMillis() / 1000
|
||||||
|
val m = FlightMoment(f, now)
|
||||||
|
val arrival = f.arrTimeExpected ?: f.arrTime
|
||||||
|
val momentColor = if (m.airborne) GlanceTheme.colors.primary else GlanceTheme.colors.onSurface
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
if (!wide) Line(momentText(m, labels, now), 13.sp, momentColor, FontWeight.Bold, maxLines = 2)
|
||||||
|
Spacer(GlanceModifier.height(6.dp))
|
||||||
|
Row(verticalAlignment = Alignment.CenterVertically, modifier = GlanceModifier.fillMaxWidth()) {
|
||||||
|
Column(modifier = GlanceModifier.defaultWeight()) {
|
||||||
|
Line(f.from, if (wide) 26.sp else 22.sp, weight = FontWeight.Bold)
|
||||||
|
if (wide) f.fromCity?.let { Line(it, 11.sp, GlanceTheme.colors.onSurfaceVariant) }
|
||||||
|
}
|
||||||
|
if (wide) {
|
||||||
|
Image(
|
||||||
|
provider = ImageProvider(WidgetArt.flightArc(m.progress, FLIGHT_BLUE, android.graphics.Color.argb(90, 120, 120, 130), rtl = isRtl())),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.Fit,
|
||||||
|
modifier = GlanceModifier.width(120.dp).height(26.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Column(modifier = GlanceModifier.defaultWeight(), horizontalAlignment = Alignment.End) {
|
||||||
|
Line(f.to, if (wide) 26.sp else 22.sp, weight = FontWeight.Bold)
|
||||||
|
if (wide) f.toCity?.let { Line(it, 11.sp, GlanceTheme.colors.onSurfaceVariant) }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!wide) {
|
||||||
|
Image(
|
||||||
|
provider = ImageProvider(WidgetArt.flightArc(m.progress, FLIGHT_BLUE, android.graphics.Color.argb(90, 120, 120, 130), rtl = isRtl())),
|
||||||
|
contentDescription = null,
|
||||||
|
contentScale = ContentScale.FillBounds,
|
||||||
|
modifier = GlanceModifier.fillMaxWidth().height(22.dp),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
Spacer(GlanceModifier.height(4.dp))
|
||||||
|
Row(modifier = GlanceModifier.fillMaxWidth()) {
|
||||||
|
Line(f.depTime, 12.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Bold, modifier = GlanceModifier.defaultWeight())
|
||||||
|
Line(arrival, 12.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Bold)
|
||||||
|
}
|
||||||
|
if (wide) {
|
||||||
|
Spacer(GlanceModifier.height(8.dp))
|
||||||
|
Line(momentText(m, labels, now), 13.sp, momentColor, FontWeight.Bold)
|
||||||
|
if (m.airborne) {
|
||||||
|
Spacer(GlanceModifier.height(5.dp))
|
||||||
|
Bar(m.progress, GlanceTheme.colors.primary, GlanceTheme.colors.surfaceVariant, 5.dp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (tall) {
|
||||||
|
Spacer(GlanceModifier.height(10.dp))
|
||||||
|
f.aircraft?.let { FlightFact(it) }
|
||||||
|
f.fromCity?.let { from -> f.toCity?.let { to -> FlightFact("$from \u2192 $to") } }
|
||||||
|
}
|
||||||
|
Spacer(GlanceModifier.defaultWeight())
|
||||||
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
private fun FlightFact(text: String) {
|
||||||
|
Row(
|
||||||
|
modifier = GlanceModifier.fillMaxWidth().background(GlanceTheme.colors.surfaceVariant).cornerRadius(12.dp)
|
||||||
|
.padding(horizontal = 10.dp, vertical = 7.dp),
|
||||||
|
verticalAlignment = Alignment.CenterVertically,
|
||||||
|
) {
|
||||||
|
Icon(Icons.Rounded.Flight, GlanceTheme.colors.primary, 13.dp)
|
||||||
|
Spacer(GlanceModifier.width(7.dp))
|
||||||
|
Line(text, 12.sp, GlanceTheme.colors.onSurfaceVariant, FontWeight.Medium)
|
||||||
|
}
|
||||||
|
Spacer(GlanceModifier.height(5.dp))
|
||||||
|
}
|
||||||
|
|
||||||
// ---- To-dos ----
|
// ---- To-dos ----
|
||||||
|
|
||||||
/** What is still open for the trip, and how far the packing has come. */
|
/** What is still open for the trip, and how far the packing has come. */
|
||||||
|
|||||||
@@ -149,4 +149,100 @@ object WidgetArt {
|
|||||||
}
|
}
|
||||||
return bitmap
|
return bitmap
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A flight's route as an arc: dashed ahead, solid where it has flown, a dot
|
||||||
|
* at either airport and an airliner riding the curve at its heading. White
|
||||||
|
* on a translucent track, like the ring; the widget tints nothing, so the
|
||||||
|
* caller passes the flight colour.
|
||||||
|
*/
|
||||||
|
fun flightArc(
|
||||||
|
progress: Float,
|
||||||
|
color: Int,
|
||||||
|
track: Int,
|
||||||
|
width: Int = 600,
|
||||||
|
height: Int = 120,
|
||||||
|
showPlane: Boolean = true,
|
||||||
|
rtl: Boolean = false,
|
||||||
|
): Bitmap {
|
||||||
|
val bitmap = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888)
|
||||||
|
val canvas = Canvas(bitmap)
|
||||||
|
// Right to left the origin stands on the right: the whole drawing is mirrored.
|
||||||
|
if (rtl) canvas.scale(-1f, 1f, width / 2f, height / 2f)
|
||||||
|
val p = progress.coerceIn(0f, 1f)
|
||||||
|
val inset = height * 0.14f
|
||||||
|
val sx = inset
|
||||||
|
val sy = height - inset
|
||||||
|
val ex = width - inset
|
||||||
|
val ey = height - inset
|
||||||
|
val cx = width / 2f
|
||||||
|
val cy = -height * 0.45f
|
||||||
|
val path = android.graphics.Path().apply {
|
||||||
|
moveTo(sx, sy)
|
||||||
|
quadTo(cx, cy, ex, ey)
|
||||||
|
}
|
||||||
|
val line = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
|
style = Paint.Style.STROKE
|
||||||
|
strokeCap = Paint.Cap.ROUND
|
||||||
|
strokeWidth = height * 0.035f
|
||||||
|
this.color = track
|
||||||
|
pathEffect = android.graphics.DashPathEffect(floatArrayOf(height * 0.02f, height * 0.07f), 0f)
|
||||||
|
}
|
||||||
|
canvas.drawPath(path, line)
|
||||||
|
val measure = android.graphics.PathMeasure(path, false)
|
||||||
|
if (p > 0f) {
|
||||||
|
val flown = android.graphics.Path()
|
||||||
|
measure.getSegment(0f, measure.length * p, flown, true)
|
||||||
|
line.pathEffect = null
|
||||||
|
line.strokeWidth = height * 0.045f
|
||||||
|
line.color = color
|
||||||
|
canvas.drawPath(flown, line)
|
||||||
|
}
|
||||||
|
val dot = Paint(Paint.ANTI_ALIAS_FLAG).apply { this.color = color }
|
||||||
|
canvas.drawCircle(sx, sy, height * 0.05f, dot)
|
||||||
|
val ring = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||||
|
style = if (p >= 1f) Paint.Style.FILL else Paint.Style.STROKE
|
||||||
|
strokeWidth = height * 0.03f
|
||||||
|
this.color = color
|
||||||
|
}
|
||||||
|
canvas.drawCircle(ex, ey, height * 0.06f, ring)
|
||||||
|
if (showPlane) {
|
||||||
|
val pos = FloatArray(2)
|
||||||
|
val tan = FloatArray(2)
|
||||||
|
measure.getPosTan(measure.length * p, pos, tan)
|
||||||
|
canvas.save()
|
||||||
|
canvas.translate(pos[0], pos[1])
|
||||||
|
canvas.rotate(Math.toDegrees(kotlin.math.atan2(tan[1].toDouble(), tan[0].toDouble())).toFloat())
|
||||||
|
val scale = height * 0.012f
|
||||||
|
canvas.scale(scale, scale)
|
||||||
|
canvas.drawCircle(0f, 0f, 13f, Paint(Paint.ANTI_ALIAS_FLAG).apply { this.color = Color.WHITE })
|
||||||
|
canvas.drawPath(airliner(), Paint(Paint.ANTI_ALIAS_FLAG).apply { this.color = color })
|
||||||
|
canvas.restore()
|
||||||
|
}
|
||||||
|
return bitmap
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An airliner seen from above, nose along +x, about 18 units long, centred. */
|
||||||
|
private fun airliner(): android.graphics.Path = android.graphics.Path().apply {
|
||||||
|
moveTo(9f, 0f)
|
||||||
|
cubicTo(9f, -0.9f, 8.3f, -1.3f, 7.4f, -1.3f)
|
||||||
|
lineTo(3.2f, -1.3f)
|
||||||
|
lineTo(-1.6f, -7.6f)
|
||||||
|
lineTo(-3.7f, -7.6f)
|
||||||
|
lineTo(-1.4f, -1.3f)
|
||||||
|
lineTo(-5.5f, -1.3f)
|
||||||
|
lineTo(-7.2f, -3.7f)
|
||||||
|
lineTo(-8.8f, -3.7f)
|
||||||
|
lineTo(-7.8f, 0f)
|
||||||
|
lineTo(-8.8f, 3.7f)
|
||||||
|
lineTo(-7.2f, 3.7f)
|
||||||
|
lineTo(-5.5f, 1.3f)
|
||||||
|
lineTo(-1.4f, 1.3f)
|
||||||
|
lineTo(-3.7f, 7.6f)
|
||||||
|
lineTo(-1.6f, 7.6f)
|
||||||
|
lineTo(3.2f, 1.3f)
|
||||||
|
lineTo(7.4f, 1.3f)
|
||||||
|
cubicTo(8.3f, 1.3f, 9f, 0.9f, 9f, 0f)
|
||||||
|
close()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,19 @@ import org.json.JSONObject
|
|||||||
* (WidgetSnapshot.sample in TrekFamily.swift).
|
* (WidgetSnapshot.sample in TrekFamily.swift).
|
||||||
*/
|
*/
|
||||||
object WidgetSamples {
|
object WidgetSamples {
|
||||||
|
/** In the air on a running trip, two days ahead before one: the same LH 716 as the iOS sample. */
|
||||||
|
private fun flightJson(running: Boolean): String {
|
||||||
|
val now = System.currentTimeMillis() / 1000
|
||||||
|
val dep = if (running) now - 4 * 3600 else now + 2 * 86_400 + 5 * 3600
|
||||||
|
val live = if (running) {
|
||||||
|
""""depActual": ${dep + 18 * 60}, "arrExpected": ${dep + 12 * 3600 + 41 * 60}, "arrTimeExpected": "08:46", "delay": 16, "aircraft": "A359 D-AIXA","""
|
||||||
|
} else {
|
||||||
|
""
|
||||||
|
}
|
||||||
|
return """{"number": "LH 716", "from": "FRA", "to": "HND", "fromCity": "Frankfurt", "toCity": "Tokyo Haneda",
|
||||||
|
"dep": $dep, "arr": ${dep + 12 * 3600 + 25 * 60}, $live "depTime": "13:05", "arrTime": "08:30", "path": "/trips/1?booking=1"}"""
|
||||||
|
}
|
||||||
|
|
||||||
fun emptyText(context: Context): String = context.getString(R.string.widget_empty)
|
fun emptyText(context: Context): String = context.getString(R.string.widget_empty)
|
||||||
|
|
||||||
fun snapshot(running: Boolean, now: LocalDate = LocalDate.now()): WidgetSnapshot = WidgetSnapshot.fromJson(JSONObject(json(running, now)))
|
fun snapshot(running: Boolean, now: LocalDate = LocalDate.now()): WidgetSnapshot = WidgetSnapshot.fromJson(JSONObject(json(running, now)))
|
||||||
@@ -37,6 +50,7 @@ object WidgetSamples {
|
|||||||
"place": "Kyoto, Japan", "dayCount": 9, "placeCount": 34, "memberCount": 3},
|
"place": "Kyoto, Japan", "dayCount": 9, "placeCount": 34, "memberCount": 3},
|
||||||
$today
|
$today
|
||||||
"weather": {"temp": 18, "high": 21, "low": 11, "main": "${if (running) "Clear" else "Clouds"}", "label": "Mostly sunny", "place": "Kyoto", "rain": 10},
|
"weather": {"temp": 18, "high": 21, "low": 11, "main": "${if (running) "Clear" else "Clouds"}", "label": "Mostly sunny", "place": "Kyoto", "rain": 10},
|
||||||
|
"flight": ${flightJson(running)},
|
||||||
"bookings": [
|
"bookings": [
|
||||||
{"title": "LH 716", "kind": "flight", "date": "${iso(if (running) 6 else 12)}", "time": "13:05", "detail": "FRA → HND", "confirmed": true, "path": "/trips/1"},
|
{"title": "LH 716", "kind": "flight", "date": "${iso(if (running) 6 else 12)}", "time": "13:05", "detail": "FRA → HND", "confirmed": true, "path": "/trips/1"},
|
||||||
{"title": "Shinkansen Nozomi 21", "kind": "train", "date": "${iso(if (running) 0 else 13)}", "time": "09:12", "detail": "Tokyo → Kyoto", "confirmed": true, "path": "/trips/1"},
|
{"title": "Shinkansen Nozomi 21", "kind": "train", "date": "${iso(if (running) 0 else 13)}", "time": "09:12", "detail": "Tokyo → Kyoto", "confirmed": true, "path": "/trips/1"},
|
||||||
|
|||||||
@@ -25,7 +25,30 @@ data class WidgetSnapshot(
|
|||||||
val atlas: Atlas?,
|
val atlas: Atlas?,
|
||||||
val collab: Collab?,
|
val collab: Collab?,
|
||||||
val labels: Labels,
|
val labels: Labels,
|
||||||
|
/** The trip's next flight or the one in the air; last and defaulted, so older callers keep compiling. */
|
||||||
|
val flight: Flight? = null,
|
||||||
|
/**
|
||||||
|
* The trip's days from the day the app wrote this on, each with its date, so
|
||||||
|
* the widget turns to the next day itself (see [on]); empty from an app
|
||||||
|
* that predates them.
|
||||||
|
*/
|
||||||
|
val days: List<Today> = emptyList(),
|
||||||
) {
|
) {
|
||||||
|
/**
|
||||||
|
* The snapshot as it reads on [date]: that date's trip day out of [days],
|
||||||
|
* none before or after the trip, and only the bookings from that date on.
|
||||||
|
* The app writes its snapshot only while it runs, so without this a widget
|
||||||
|
* showed the day it last ran. A snapshot without [days] reads as written.
|
||||||
|
*/
|
||||||
|
fun on(date: LocalDate): WidgetSnapshot {
|
||||||
|
if (days.isEmpty()) return this
|
||||||
|
val key = date.toString()
|
||||||
|
return copy(
|
||||||
|
today = if (today?.date == key) today else days.firstOrNull { it.date == key },
|
||||||
|
bookings = bookings.filter { (it.date ?: key) >= key },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
data class Trip(
|
data class Trip(
|
||||||
val title: String,
|
val title: String,
|
||||||
val start: String,
|
val start: String,
|
||||||
@@ -50,7 +73,8 @@ data class WidgetSnapshot(
|
|||||||
val symbol: String?,
|
val symbol: String?,
|
||||||
)
|
)
|
||||||
|
|
||||||
data class Today(val dayLabel: String, val stops: List<Stop>, val index: Int?, val total: Int?)
|
/** A trip day; [date] (yyyy-MM-dd) is absent from an app that predates the days ahead. */
|
||||||
|
data class Today(val dayLabel: String, val stops: List<Stop>, val index: Int?, val total: Int?, val date: String? = null)
|
||||||
|
|
||||||
data class Weather(
|
data class Weather(
|
||||||
val temp: Int,
|
val temp: Int,
|
||||||
@@ -105,6 +129,39 @@ data class WidgetSnapshot(
|
|||||||
|
|
||||||
data class Collab(val members: List<Member>, val messages: List<Message>, val poll: Poll?, val path: String)
|
data class Collab(val members: List<Member>, val messages: List<Message>, val poll: Poll?, val path: String)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The flight widget's flight. Times are epoch seconds, so the widget moves on
|
||||||
|
* with the clock between two snapshots; the clock times at either airport
|
||||||
|
* come formatted, since the widget has no zone data.
|
||||||
|
*/
|
||||||
|
data class Flight(
|
||||||
|
val number: String,
|
||||||
|
val from: String,
|
||||||
|
val to: String,
|
||||||
|
val fromCity: String?,
|
||||||
|
val toCity: String?,
|
||||||
|
val dep: Long,
|
||||||
|
val arr: Long,
|
||||||
|
/** Observed take-off. */
|
||||||
|
val depActual: Long?,
|
||||||
|
/** Before take-off: the planned departure plus the delay seen so far. */
|
||||||
|
val depExpected: Long?,
|
||||||
|
/** The feed saw the aircraft in the air when the app last looked. */
|
||||||
|
val airborne: Boolean,
|
||||||
|
/** Touchdown once landed, else the estimate while in the air. */
|
||||||
|
val arrExpected: Long?,
|
||||||
|
val landed: Boolean,
|
||||||
|
val depTime: String,
|
||||||
|
val arrTime: String,
|
||||||
|
val arrTimeExpected: String?,
|
||||||
|
/** Minutes late against the schedule, negative when early. */
|
||||||
|
val delay: Int?,
|
||||||
|
val aircraft: String?,
|
||||||
|
/** When the feed last heard the aircraft; null for a flight it never heard of. */
|
||||||
|
val seen: Long?,
|
||||||
|
val path: String,
|
||||||
|
)
|
||||||
|
|
||||||
/** The labels, translated by the app. The optional ones fall back to English. */
|
/** The labels, translated by the app. The optional ones fall back to English. */
|
||||||
data class Labels(private val raw: JSONObject) {
|
data class Labels(private val raw: JSONObject) {
|
||||||
val nextTrip get() = text("nextTrip", "Next trip")
|
val nextTrip get() = text("nextTrip", "Next trip")
|
||||||
@@ -137,6 +194,23 @@ data class WidgetSnapshot(
|
|||||||
val votes get() = text("votes", "votes")
|
val votes get() = text("votes", "votes")
|
||||||
val noMessages get() = text("noMessages", "No messages yet")
|
val noMessages get() = text("noMessages", "No messages yet")
|
||||||
val departure get() = text("departure", "Departure")
|
val departure get() = text("departure", "Departure")
|
||||||
|
val flight get() = text("flight", "Flight")
|
||||||
|
/** Contains "{time}". */
|
||||||
|
val flightDeparts get() = text("flightDeparts", "Departs in {time}")
|
||||||
|
/** Contains "{time}". */
|
||||||
|
val flightLands get() = text("flightLands", "Lands in {time}")
|
||||||
|
val flightLanded get() = text("flightLanded", "Landed")
|
||||||
|
val flightReady get() = text("flightReady", "Ready for departure")
|
||||||
|
val noFlight get() = text("noFlight", "No flight ahead")
|
||||||
|
val flightOnTime get() = text("flightOnTime", "On time")
|
||||||
|
/** Contains "{m}". */
|
||||||
|
val flightLate get() = text("flightLate", "+{m} min")
|
||||||
|
/** Contains "{m}". */
|
||||||
|
val flightEarly get() = text("flightEarly", "{m} min early")
|
||||||
|
/** Contain "{d}" and "{h}", "{h}" and "{m}", and "{m}". */
|
||||||
|
val durDaysHours get() = text("durDaysHours", "{d} d {h} h")
|
||||||
|
val durHoursMinutes get() = text("durHoursMinutes", "{h} h {m} min")
|
||||||
|
val durMinutes get() = text("durMinutes", "{m} min")
|
||||||
|
|
||||||
private fun text(key: String, fallback: String): String = raw.optString(key).ifBlank { fallback }
|
private fun text(key: String, fallback: String): String = raw.optString(key).ifBlank { fallback }
|
||||||
}
|
}
|
||||||
@@ -160,6 +234,16 @@ data class WidgetSnapshot(
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun dayOf(t: JSONObject): Today = Today(
|
||||||
|
dayLabel = t.optString("dayLabel"),
|
||||||
|
stops = t.optJSONArray("stops").objects().map {
|
||||||
|
Stop(it.str("time"), it.optString("name"), it.int("minutes"), it.str("color"), it.str("symbol"))
|
||||||
|
},
|
||||||
|
index = t.int("index"),
|
||||||
|
total = t.int("total"),
|
||||||
|
date = t.str("date"),
|
||||||
|
)
|
||||||
|
|
||||||
fun fromJson(o: JSONObject): WidgetSnapshot = WidgetSnapshot(
|
fun fromJson(o: JSONObject): WidgetSnapshot = WidgetSnapshot(
|
||||||
trip = o.optJSONObject("trip")?.let {
|
trip = o.optJSONObject("trip")?.let {
|
||||||
Trip(
|
Trip(
|
||||||
@@ -174,16 +258,8 @@ data class WidgetSnapshot(
|
|||||||
memberCount = it.int("memberCount"),
|
memberCount = it.int("memberCount"),
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
today = o.optJSONObject("today")?.let { t ->
|
today = o.optJSONObject("today")?.let(::dayOf),
|
||||||
Today(
|
days = o.optJSONArray("days").objects().map(::dayOf),
|
||||||
dayLabel = t.optString("dayLabel"),
|
|
||||||
stops = t.optJSONArray("stops").objects().map {
|
|
||||||
Stop(it.str("time"), it.optString("name"), it.int("minutes"), it.str("color"), it.str("symbol"))
|
|
||||||
},
|
|
||||||
index = t.int("index"),
|
|
||||||
total = t.int("total"),
|
|
||||||
)
|
|
||||||
},
|
|
||||||
weather = o.optJSONObject("weather")?.let {
|
weather = o.optJSONObject("weather")?.let {
|
||||||
Weather(it.optInt("temp"), it.int("high"), it.int("low"), it.optString("main"), it.optString("label"), it.str("place"), it.int("rain"))
|
Weather(it.optInt("temp"), it.int("high"), it.int("low"), it.optString("main"), it.optString("label"), it.str("place"), it.int("rain"))
|
||||||
},
|
},
|
||||||
@@ -240,6 +316,29 @@ data class WidgetSnapshot(
|
|||||||
)
|
)
|
||||||
},
|
},
|
||||||
labels = Labels(o.optJSONObject("labels") ?: JSONObject()),
|
labels = Labels(o.optJSONObject("labels") ?: JSONObject()),
|
||||||
|
flight = o.optJSONObject("flight")?.let { f ->
|
||||||
|
Flight(
|
||||||
|
number = f.optString("number"),
|
||||||
|
from = f.optString("from"),
|
||||||
|
to = f.optString("to"),
|
||||||
|
fromCity = f.str("fromCity"),
|
||||||
|
toCity = f.str("toCity"),
|
||||||
|
dep = f.optLong("dep"),
|
||||||
|
arr = f.optLong("arr"),
|
||||||
|
depActual = f.long("depActual"),
|
||||||
|
depExpected = f.long("depExpected"),
|
||||||
|
airborne = f.optBoolean("airborne"),
|
||||||
|
arrExpected = f.long("arrExpected"),
|
||||||
|
landed = f.optBoolean("landed"),
|
||||||
|
depTime = f.optString("depTime"),
|
||||||
|
arrTime = f.optString("arrTime"),
|
||||||
|
arrTimeExpected = f.str("arrTimeExpected"),
|
||||||
|
delay = f.int("delay"),
|
||||||
|
aircraft = f.str("aircraft"),
|
||||||
|
seen = f.long("seen"),
|
||||||
|
path = f.optString("path", "/"),
|
||||||
|
)
|
||||||
|
}?.takeIf { it.dep > 0 && it.arr > 0 },
|
||||||
)
|
)
|
||||||
|
|
||||||
fun day(iso: String?): LocalDate? {
|
fun day(iso: String?): LocalDate? {
|
||||||
@@ -258,6 +357,8 @@ data class WidgetSnapshot(
|
|||||||
|
|
||||||
private fun JSONObject.int(key: String): Int? = if (has(key) && !isNull(key)) optInt(key) else null
|
private fun JSONObject.int(key: String): Int? = if (has(key) && !isNull(key)) optInt(key) else null
|
||||||
|
|
||||||
|
private fun JSONObject.long(key: String): Long? = if (has(key) && !isNull(key)) optLong(key) else null
|
||||||
|
|
||||||
private fun JSONArray?.objects(): List<JSONObject> =
|
private fun JSONArray?.objects(): List<JSONObject> =
|
||||||
if (this == null) emptyList() else (0 until length()).mapNotNull { optJSONObject(it) }
|
if (this == null) emptyList() else (0 until length()).mapNotNull { optJSONObject(it) }
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">خطة اليوم كخط زمني، مع الطقس والمحطة التالية.</string>
|
<string name="widget_today_description">خطة اليوم كخط زمني، مع الطقس والمحطة التالية.</string>
|
||||||
<string name="widget_bookings_name">الحجوزات</string>
|
<string name="widget_bookings_name">الحجوزات</string>
|
||||||
<string name="widget_bookings_description">رحلاتك وقطاراتك وفنادقك وحجوزات المطاعم القادمة ومواعيدها.</string>
|
<string name="widget_bookings_description">رحلاتك وقطاراتك وفنادقك وحجوزات المطاعم القادمة ومواعيدها.</string>
|
||||||
|
<string name="widget_flight_name">الرحلة</string>
|
||||||
|
<string name="widget_flight_description">رحلتك القادمة مباشرة: عد تنازلي للإقلاع، والطائرة في طريقها، والتأخير والوصول.</string>
|
||||||
<string name="widget_todos_name">المهام</string>
|
<string name="widget_todos_name">المهام</string>
|
||||||
<string name="widget_todos_description">ما تبقى للرحلة، ومدى تقدم تجهيز الأمتعة.</string>
|
<string name="widget_todos_description">ما تبقى للرحلة، ومدى تقدم تجهيز الأمتعة.</string>
|
||||||
<string name="widget_packing_name">قائمة الأمتعة</string>
|
<string name="widget_packing_name">قائمة الأمتعة</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Günün planı zaman xətti kimi, hava və növbəti dayanacaqla.</string>
|
<string name="widget_today_description">Günün planı zaman xətti kimi, hava və növbəti dayanacaqla.</string>
|
||||||
<string name="widget_bookings_name">Bronlar</string>
|
<string name="widget_bookings_name">Bronlar</string>
|
||||||
<string name="widget_bookings_description">Növbəti uçuşlar, qatarlar, otellər və restoranlar, nə vaxt olduqları ilə.</string>
|
<string name="widget_bookings_description">Növbəti uçuşlar, qatarlar, otellər və restoranlar, nə vaxt olduqları ilə.</string>
|
||||||
|
<string name="widget_flight_name">Uçuş</string>
|
||||||
|
<string name="widget_flight_description">Növbəti uçuşun canlı: uçuşa qədər geri sayım, yolda olan təyyarə, gecikmə və gəliş.</string>
|
||||||
<string name="widget_todos_name">Tapşırıqlar</string>
|
<string name="widget_todos_name">Tapşırıqlar</string>
|
||||||
<string name="widget_todos_description">Səyahət üçün hələ nəyin qaldığı və yığışmağın nə yerdə olduğu.</string>
|
<string name="widget_todos_description">Səyahət üçün hələ nəyin qaldığı və yığışmağın nə yerdə olduğu.</string>
|
||||||
<string name="widget_packing_name">Yük siyahısı</string>
|
<string name="widget_packing_name">Yük siyahısı</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">以时间线显示今天的计划,附带天气和下一站。</string>
|
<string name="widget_today_description">以时间线显示今天的计划,附带天气和下一站。</string>
|
||||||
<string name="widget_bookings_name">预订</string>
|
<string name="widget_bookings_name">预订</string>
|
||||||
<string name="widget_bookings_description">你接下来的航班、火车、酒店和餐厅,以及时间。</string>
|
<string name="widget_bookings_description">你接下来的航班、火车、酒店和餐厅,以及时间。</string>
|
||||||
|
<string name="widget_flight_name">航班</string>
|
||||||
|
<string name="widget_flight_description">实时查看下一班航班:起飞倒计时、飞行中的飞机、延误和到达。</string>
|
||||||
<string name="widget_todos_name">待办</string>
|
<string name="widget_todos_name">待办</string>
|
||||||
<string name="widget_todos_description">旅行还剩哪些事没做,以及行李收拾到哪一步。</string>
|
<string name="widget_todos_description">旅行还剩哪些事没做,以及行李收拾到哪一步。</string>
|
||||||
<string name="widget_packing_name">行李</string>
|
<string name="widget_packing_name">行李</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">以時間軸顯示今天的計畫,附上天氣與下一站。</string>
|
<string name="widget_today_description">以時間軸顯示今天的計畫,附上天氣與下一站。</string>
|
||||||
<string name="widget_bookings_name">預訂</string>
|
<string name="widget_bookings_name">預訂</string>
|
||||||
<string name="widget_bookings_description">你接下來的航班、火車、飯店與餐廳,以及時間。</string>
|
<string name="widget_bookings_description">你接下來的航班、火車、飯店與餐廳,以及時間。</string>
|
||||||
|
<string name="widget_flight_name">航班</string>
|
||||||
|
<string name="widget_flight_description">即時查看下一班航班:起飛倒數、飛行中的飛機、延誤和抵達。</string>
|
||||||
<string name="widget_todos_name">待辦</string>
|
<string name="widget_todos_name">待辦</string>
|
||||||
<string name="widget_todos_description">旅行還剩哪些事沒做,以及行李整理到哪一步。</string>
|
<string name="widget_todos_description">旅行還剩哪些事沒做,以及行李整理到哪一步。</string>
|
||||||
<string name="widget_packing_name">行李</string>
|
<string name="widget_packing_name">行李</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">El pla del dia com a línia de temps, amb el temps i la propera parada.</string>
|
<string name="widget_today_description">El pla del dia com a línia de temps, amb el temps i la propera parada.</string>
|
||||||
<string name="widget_bookings_name">Reserves</string>
|
<string name="widget_bookings_name">Reserves</string>
|
||||||
<string name="widget_bookings_description">Els teus propers vols, trens, hotels i taules, i quan toquen.</string>
|
<string name="widget_bookings_description">Els teus propers vols, trens, hotels i taules, i quan toquen.</string>
|
||||||
|
<string name="widget_flight_name">Vol</string>
|
||||||
|
<string name="widget_flight_description">El teu proper vol en directe: compte enrere de la sortida, l’avió en camí, retard i arribada.</string>
|
||||||
<string name="widget_todos_name">Tasques</string>
|
<string name="widget_todos_name">Tasques</string>
|
||||||
<string name="widget_todos_description">El que encara queda per al viatge i com va l\'equipatge.</string>
|
<string name="widget_todos_description">El que encara queda per al viatge i com va l\'equipatge.</string>
|
||||||
<string name="widget_packing_name">Equipatge</string>
|
<string name="widget_packing_name">Equipatge</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Plán dne jako časová osa, s počasím a další zastávkou.</string>
|
<string name="widget_today_description">Plán dne jako časová osa, s počasím a další zastávkou.</string>
|
||||||
<string name="widget_bookings_name">Rezervace</string>
|
<string name="widget_bookings_name">Rezervace</string>
|
||||||
<string name="widget_bookings_description">Tvoje další lety, vlaky, hotely a stoly, a kdy tě čekají.</string>
|
<string name="widget_bookings_description">Tvoje další lety, vlaky, hotely a stoly, a kdy tě čekají.</string>
|
||||||
|
<string name="widget_flight_name">Let</string>
|
||||||
|
<string name="widget_flight_description">Tvůj další let živě: odpočet do odletu, letadlo na cestě, zpoždění a přílet.</string>
|
||||||
<string name="widget_todos_name">Úkoly</string>
|
<string name="widget_todos_name">Úkoly</string>
|
||||||
<string name="widget_todos_description">Co ještě zbývá k cestě a jak daleko je balení.</string>
|
<string name="widget_todos_description">Co ještě zbývá k cestě a jak daleko je balení.</string>
|
||||||
<string name="widget_packing_name">Balení</string>
|
<string name="widget_packing_name">Balení</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Der Tagesplan als Zeitleiste, mit dem Wetter und dem nächsten Stopp.</string>
|
<string name="widget_today_description">Der Tagesplan als Zeitleiste, mit dem Wetter und dem nächsten Stopp.</string>
|
||||||
<string name="widget_bookings_name">Buchungen</string>
|
<string name="widget_bookings_name">Buchungen</string>
|
||||||
<string name="widget_bookings_description">Deine nächsten Flüge, Züge, Hotels und Tische, und wann sie anstehen.</string>
|
<string name="widget_bookings_description">Deine nächsten Flüge, Züge, Hotels und Tische, und wann sie anstehen.</string>
|
||||||
|
<string name="widget_flight_name">Flug</string>
|
||||||
|
<string name="widget_flight_description">Dein nächster Flug live: Countdown bis zum Abflug, die Maschine unterwegs, Verspätung und Ankunft.</string>
|
||||||
<string name="widget_todos_name">To-dos</string>
|
<string name="widget_todos_name">To-dos</string>
|
||||||
<string name="widget_todos_description">Was für die Reise noch offen ist und wie weit das Packen ist.</string>
|
<string name="widget_todos_description">Was für die Reise noch offen ist und wie weit das Packen ist.</string>
|
||||||
<string name="widget_packing_name">Packliste</string>
|
<string name="widget_packing_name">Packliste</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Το πρόγραμμα της ημέρας ως χρονολόγιο, με τον καιρό και την επόμενη στάση.</string>
|
<string name="widget_today_description">Το πρόγραμμα της ημέρας ως χρονολόγιο, με τον καιρό και την επόμενη στάση.</string>
|
||||||
<string name="widget_bookings_name">Κρατήσεις</string>
|
<string name="widget_bookings_name">Κρατήσεις</string>
|
||||||
<string name="widget_bookings_description">Οι επόμενες πτήσεις, τα τρένα, τα ξενοδοχεία και τα τραπέζια σου, και πότε είναι.</string>
|
<string name="widget_bookings_description">Οι επόμενες πτήσεις, τα τρένα, τα ξενοδοχεία και τα τραπέζια σου, και πότε είναι.</string>
|
||||||
|
<string name="widget_flight_name">Πτήση</string>
|
||||||
|
<string name="widget_flight_description">Η επόμενη πτήση σου ζωντανά: αντίστροφη μέτρηση για την αναχώρηση, το αεροσκάφος καθ’ οδόν, καθυστέρηση και άφιξη.</string>
|
||||||
<string name="widget_todos_name">Εκκρεμότητες</string>
|
<string name="widget_todos_name">Εκκρεμότητες</string>
|
||||||
<string name="widget_todos_description">Τι μένει ακόμα για το ταξίδι και πόσο έχει προχωρήσει το πακετάρισμα.</string>
|
<string name="widget_todos_description">Τι μένει ακόμα για το ταξίδι και πόσο έχει προχωρήσει το πακετάρισμα.</string>
|
||||||
<string name="widget_packing_name">Αποσκευές</string>
|
<string name="widget_packing_name">Αποσκευές</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">El plan del día como línea de tiempo, con el tiempo y la próxima parada.</string>
|
<string name="widget_today_description">El plan del día como línea de tiempo, con el tiempo y la próxima parada.</string>
|
||||||
<string name="widget_bookings_name">Reservas</string>
|
<string name="widget_bookings_name">Reservas</string>
|
||||||
<string name="widget_bookings_description">Tus próximos vuelos, trenes, hoteles y mesas, y cuándo tocan.</string>
|
<string name="widget_bookings_description">Tus próximos vuelos, trenes, hoteles y mesas, y cuándo tocan.</string>
|
||||||
|
<string name="widget_flight_name">Vuelo</string>
|
||||||
|
<string name="widget_flight_description">Tu próximo vuelo en directo: cuenta atrás de la salida, el avión en camino, retraso y llegada.</string>
|
||||||
<string name="widget_todos_name">Tareas</string>
|
<string name="widget_todos_name">Tareas</string>
|
||||||
<string name="widget_todos_description">Lo que aún queda para el viaje y cómo va la maleta.</string>
|
<string name="widget_todos_description">Lo que aún queda para el viaje y cómo va la maleta.</string>
|
||||||
<string name="widget_packing_name">Equipaje</string>
|
<string name="widget_packing_name">Equipaje</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Päeva plaan ajajoonena, koos ilma ja järgmise peatusega.</string>
|
<string name="widget_today_description">Päeva plaan ajajoonena, koos ilma ja järgmise peatusega.</string>
|
||||||
<string name="widget_bookings_name">Broneeringud</string>
|
<string name="widget_bookings_name">Broneeringud</string>
|
||||||
<string name="widget_bookings_description">Sinu järgmised lennud, rongid, hotellid ja lauad ning millal need on.</string>
|
<string name="widget_bookings_description">Sinu järgmised lennud, rongid, hotellid ja lauad ning millal need on.</string>
|
||||||
|
<string name="widget_flight_name">Lend</string>
|
||||||
|
<string name="widget_flight_description">Sinu järgmine lend otse: loendus väljumiseni, lennuk teel, hilinemine ja saabumine.</string>
|
||||||
<string name="widget_todos_name">Ülesanded</string>
|
<string name="widget_todos_name">Ülesanded</string>
|
||||||
<string name="widget_todos_description">Mis reisi jaoks veel tegemata on ja kui kaugel pakkimine on.</string>
|
<string name="widget_todos_description">Mis reisi jaoks veel tegemata on ja kui kaugel pakkimine on.</string>
|
||||||
<string name="widget_packing_name">Pakkimine</string>
|
<string name="widget_packing_name">Pakkimine</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Le programme du jour en frise, avec la météo et la prochaine étape.</string>
|
<string name="widget_today_description">Le programme du jour en frise, avec la météo et la prochaine étape.</string>
|
||||||
<string name="widget_bookings_name">Réservations</string>
|
<string name="widget_bookings_name">Réservations</string>
|
||||||
<string name="widget_bookings_description">Vos prochains vols, trains, hôtels et tables, et quand ils arrivent.</string>
|
<string name="widget_bookings_description">Vos prochains vols, trains, hôtels et tables, et quand ils arrivent.</string>
|
||||||
|
<string name="widget_flight_name">Vol</string>
|
||||||
|
<string name="widget_flight_description">Votre prochain vol en direct : compte à rebours du départ, l’avion en route, retard et arrivée.</string>
|
||||||
<string name="widget_todos_name">À faire</string>
|
<string name="widget_todos_name">À faire</string>
|
||||||
<string name="widget_todos_description">Ce qui reste à faire pour le voyage et où en sont les bagages.</string>
|
<string name="widget_todos_description">Ce qui reste à faire pour le voyage et où en sont les bagages.</string>
|
||||||
<string name="widget_packing_name">Bagages</string>
|
<string name="widget_packing_name">Bagages</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">A nap terve idővonalon, az időjárással és a következő megállóval.</string>
|
<string name="widget_today_description">A nap terve idővonalon, az időjárással és a következő megállóval.</string>
|
||||||
<string name="widget_bookings_name">Foglalások</string>
|
<string name="widget_bookings_name">Foglalások</string>
|
||||||
<string name="widget_bookings_description">A következő járataid, vonataid, szállásaid és asztalfoglalásaid, és hogy mikor esedékesek.</string>
|
<string name="widget_bookings_description">A következő járataid, vonataid, szállásaid és asztalfoglalásaid, és hogy mikor esedékesek.</string>
|
||||||
|
<string name="widget_flight_name">Járat</string>
|
||||||
|
<string name="widget_flight_description">A következő járatod élőben: visszaszámlálás az indulásig, a gép útközben, késés és érkezés.</string>
|
||||||
<string name="widget_todos_name">Teendők</string>
|
<string name="widget_todos_name">Teendők</string>
|
||||||
<string name="widget_todos_description">Ami még hátravan az utazáshoz, és hol tart a csomagolás.</string>
|
<string name="widget_todos_description">Ami még hátravan az utazáshoz, és hol tart a csomagolás.</string>
|
||||||
<string name="widget_packing_name">Csomagolás</string>
|
<string name="widget_packing_name">Csomagolás</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Rencana hari ini sebagai linimasa, dengan cuaca dan perhentian berikutnya.</string>
|
<string name="widget_today_description">Rencana hari ini sebagai linimasa, dengan cuaca dan perhentian berikutnya.</string>
|
||||||
<string name="widget_bookings_name">Pemesanan</string>
|
<string name="widget_bookings_name">Pemesanan</string>
|
||||||
<string name="widget_bookings_description">Penerbangan, kereta, hotel, dan meja berikutnya, beserta waktunya.</string>
|
<string name="widget_bookings_description">Penerbangan, kereta, hotel, dan meja berikutnya, beserta waktunya.</string>
|
||||||
|
<string name="widget_flight_name">Penerbangan</string>
|
||||||
|
<string name="widget_flight_description">Penerbangan berikutnya secara langsung: hitung mundur keberangkatan, pesawat dalam perjalanan, keterlambatan, dan kedatangan.</string>
|
||||||
<string name="widget_todos_name">Tugas</string>
|
<string name="widget_todos_name">Tugas</string>
|
||||||
<string name="widget_todos_description">Yang masih tersisa untuk perjalanan dan sejauh mana persiapan barang.</string>
|
<string name="widget_todos_description">Yang masih tersisa untuk perjalanan dan sejauh mana persiapan barang.</string>
|
||||||
<string name="widget_packing_name">Barang bawaan</string>
|
<string name="widget_packing_name">Barang bawaan</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Il programma del giorno come linea del tempo, con il meteo e la prossima tappa.</string>
|
<string name="widget_today_description">Il programma del giorno come linea del tempo, con il meteo e la prossima tappa.</string>
|
||||||
<string name="widget_bookings_name">Prenotazioni</string>
|
<string name="widget_bookings_name">Prenotazioni</string>
|
||||||
<string name="widget_bookings_description">I tuoi prossimi voli, treni, hotel e tavoli, e quando sono.</string>
|
<string name="widget_bookings_description">I tuoi prossimi voli, treni, hotel e tavoli, e quando sono.</string>
|
||||||
|
<string name="widget_flight_name">Volo</string>
|
||||||
|
<string name="widget_flight_description">Il tuo prossimo volo in tempo reale: conto alla rovescia per la partenza, l’aereo in viaggio, ritardo e arrivo.</string>
|
||||||
<string name="widget_todos_name">Da fare</string>
|
<string name="widget_todos_name">Da fare</string>
|
||||||
<string name="widget_todos_description">Cosa manca ancora per il viaggio e a che punto è la valigia.</string>
|
<string name="widget_todos_description">Cosa manca ancora per il viaggio e a che punto è la valigia.</string>
|
||||||
<string name="widget_packing_name">Bagagli</string>
|
<string name="widget_packing_name">Bagagli</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">תוכנית היום כציר זמן, עם מזג האוויר והעצירה הבאה.</string>
|
<string name="widget_today_description">תוכנית היום כציר זמן, עם מזג האוויר והעצירה הבאה.</string>
|
||||||
<string name="widget_bookings_name">הזמנות</string>
|
<string name="widget_bookings_name">הזמנות</string>
|
||||||
<string name="widget_bookings_description">הטיסות, הרכבות, המלונות והשולחנות הבאים שלך, ומתי הם.</string>
|
<string name="widget_bookings_description">הטיסות, הרכבות, המלונות והשולחנות הבאים שלך, ומתי הם.</string>
|
||||||
|
<string name="widget_flight_name">טיסה</string>
|
||||||
|
<string name="widget_flight_description">הטיסה הבאה שלך בזמן אמת: ספירה לאחור עד ההמראה, המטוס בדרך, עיכוב והגעה.</string>
|
||||||
<string name="widget_todos_name">משימות</string>
|
<string name="widget_todos_name">משימות</string>
|
||||||
<string name="widget_todos_description">מה עוד פתוח לטיול וכמה התקדמה האריזה.</string>
|
<string name="widget_todos_description">מה עוד פתוח לטיול וכמה התקדמה האריזה.</string>
|
||||||
<string name="widget_packing_name">אריזה</string>
|
<string name="widget_packing_name">אריזה</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">今日の予定をタイムラインで、天気と次の予定とともに表示します。</string>
|
<string name="widget_today_description">今日の予定をタイムラインで、天気と次の予定とともに表示します。</string>
|
||||||
<string name="widget_bookings_name">予約</string>
|
<string name="widget_bookings_name">予約</string>
|
||||||
<string name="widget_bookings_description">次のフライト、列車、ホテル、レストランとその日時。</string>
|
<string name="widget_bookings_description">次のフライト、列車、ホテル、レストランとその日時。</string>
|
||||||
|
<string name="widget_flight_name">フライト</string>
|
||||||
|
<string name="widget_flight_description">次のフライトをライブで:出発までのカウントダウン、飛行中の機体、遅延と到着。</string>
|
||||||
<string name="widget_todos_name">やること</string>
|
<string name="widget_todos_name">やること</string>
|
||||||
<string name="widget_todos_description">旅行のために残っていることと、荷造りの進み具合。</string>
|
<string name="widget_todos_description">旅行のために残っていることと、荷造りの進み具合。</string>
|
||||||
<string name="widget_packing_name">持ち物</string>
|
<string name="widget_packing_name">持ち物</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">오늘 일정을 타임라인으로, 날씨와 다음 장소와 함께 보여 줍니다.</string>
|
<string name="widget_today_description">오늘 일정을 타임라인으로, 날씨와 다음 장소와 함께 보여 줍니다.</string>
|
||||||
<string name="widget_bookings_name">예약</string>
|
<string name="widget_bookings_name">예약</string>
|
||||||
<string name="widget_bookings_description">다가오는 항공편, 기차, 호텔, 식당과 그 시간.</string>
|
<string name="widget_bookings_description">다가오는 항공편, 기차, 호텔, 식당과 그 시간.</string>
|
||||||
|
<string name="widget_flight_name">항공편</string>
|
||||||
|
<string name="widget_flight_description">다음 항공편을 실시간으로: 출발 카운트다운, 비행 중인 항공기, 지연과 도착.</string>
|
||||||
<string name="widget_todos_name">할 일</string>
|
<string name="widget_todos_name">할 일</string>
|
||||||
<string name="widget_todos_description">여행을 위해 남은 일과 짐 싸기 진행 상황.</string>
|
<string name="widget_todos_description">여행을 위해 남은 일과 짐 싸기 진행 상황.</string>
|
||||||
<string name="widget_packing_name">짐 싸기</string>
|
<string name="widget_packing_name">짐 싸기</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Het dagplan als tijdlijn, met het weer en de volgende stop.</string>
|
<string name="widget_today_description">Het dagplan als tijdlijn, met het weer en de volgende stop.</string>
|
||||||
<string name="widget_bookings_name">Boekingen</string>
|
<string name="widget_bookings_name">Boekingen</string>
|
||||||
<string name="widget_bookings_description">Je volgende vluchten, treinen, hotels en tafels, en wanneer ze zijn.</string>
|
<string name="widget_bookings_description">Je volgende vluchten, treinen, hotels en tafels, en wanneer ze zijn.</string>
|
||||||
|
<string name="widget_flight_name">Vlucht</string>
|
||||||
|
<string name="widget_flight_description">Je volgende vlucht live: aftellen tot vertrek, het toestel onderweg, vertraging en aankomst.</string>
|
||||||
<string name="widget_todos_name">Taken</string>
|
<string name="widget_todos_name">Taken</string>
|
||||||
<string name="widget_todos_description">Wat er nog openstaat voor de reis en hoe ver het inpakken is.</string>
|
<string name="widget_todos_description">Wat er nog openstaat voor de reis en hoe ver het inpakken is.</string>
|
||||||
<string name="widget_packing_name">Bagage</string>
|
<string name="widget_packing_name">Bagage</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Plan dnia jako oś czasu, z pogodą i kolejnym przystankiem.</string>
|
<string name="widget_today_description">Plan dnia jako oś czasu, z pogodą i kolejnym przystankiem.</string>
|
||||||
<string name="widget_bookings_name">Rezerwacje</string>
|
<string name="widget_bookings_name">Rezerwacje</string>
|
||||||
<string name="widget_bookings_description">Twoje najbliższe loty, pociągi, hotele i stoliki oraz ich terminy.</string>
|
<string name="widget_bookings_description">Twoje najbliższe loty, pociągi, hotele i stoliki oraz ich terminy.</string>
|
||||||
|
<string name="widget_flight_name">Lot</string>
|
||||||
|
<string name="widget_flight_description">Twój następny lot na żywo: odliczanie do odlotu, samolot w drodze, opóźnienie i przylot.</string>
|
||||||
<string name="widget_todos_name">Zadania</string>
|
<string name="widget_todos_name">Zadania</string>
|
||||||
<string name="widget_todos_description">Co jeszcze zostało do zrobienia przed podróżą i jak idzie pakowanie.</string>
|
<string name="widget_todos_description">Co jeszcze zostało do zrobienia przed podróżą i jak idzie pakowanie.</string>
|
||||||
<string name="widget_packing_name">Pakowanie</string>
|
<string name="widget_packing_name">Pakowanie</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">O plano do dia como linha do tempo, com o clima e a próxima parada.</string>
|
<string name="widget_today_description">O plano do dia como linha do tempo, com o clima e a próxima parada.</string>
|
||||||
<string name="widget_bookings_name">Reservas</string>
|
<string name="widget_bookings_name">Reservas</string>
|
||||||
<string name="widget_bookings_description">Seus próximos voos, trens, hotéis e mesas, e quando acontecem.</string>
|
<string name="widget_bookings_description">Seus próximos voos, trens, hotéis e mesas, e quando acontecem.</string>
|
||||||
|
<string name="widget_flight_name">Voo</string>
|
||||||
|
<string name="widget_flight_description">Seu próximo voo ao vivo: contagem regressiva para a partida, o avião a caminho, atraso e chegada.</string>
|
||||||
<string name="widget_todos_name">Tarefas</string>
|
<string name="widget_todos_name">Tarefas</string>
|
||||||
<string name="widget_todos_description">O que ainda falta para a viagem e quanto da mala já está pronto.</string>
|
<string name="widget_todos_description">O que ainda falta para a viagem e quanto da mala já está pronto.</string>
|
||||||
<string name="widget_packing_name">Bagagem</string>
|
<string name="widget_packing_name">Bagagem</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">План дня в виде ленты времени, с погодой и следующей остановкой.</string>
|
<string name="widget_today_description">План дня в виде ленты времени, с погодой и следующей остановкой.</string>
|
||||||
<string name="widget_bookings_name">Бронирования</string>
|
<string name="widget_bookings_name">Бронирования</string>
|
||||||
<string name="widget_bookings_description">Ближайшие рейсы, поезда, отели и столики и когда они.</string>
|
<string name="widget_bookings_description">Ближайшие рейсы, поезда, отели и столики и когда они.</string>
|
||||||
|
<string name="widget_flight_name">Рейс</string>
|
||||||
|
<string name="widget_flight_description">Ваш следующий рейс в реальном времени: отсчёт до вылета, самолёт в пути, задержка и прибытие.</string>
|
||||||
<string name="widget_todos_name">Задачи</string>
|
<string name="widget_todos_name">Задачи</string>
|
||||||
<string name="widget_todos_description">Что ещё осталось сделать к поездке и как идут сборы.</string>
|
<string name="widget_todos_description">Что ещё осталось сделать к поездке и как идут сборы.</string>
|
||||||
<string name="widget_packing_name">Сборы</string>
|
<string name="widget_packing_name">Сборы</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Plán dňa ako časová os, s počasím a ďalšou zastávkou.</string>
|
<string name="widget_today_description">Plán dňa ako časová os, s počasím a ďalšou zastávkou.</string>
|
||||||
<string name="widget_bookings_name">Rezervácie</string>
|
<string name="widget_bookings_name">Rezervácie</string>
|
||||||
<string name="widget_bookings_description">Tvoje ďalšie lety, vlaky, hotely a stoly a kedy ťa čakajú.</string>
|
<string name="widget_bookings_description">Tvoje ďalšie lety, vlaky, hotely a stoly a kedy ťa čakajú.</string>
|
||||||
|
<string name="widget_flight_name">Let</string>
|
||||||
|
<string name="widget_flight_description">Tvoj ďalší let naživo: odpočet do odletu, lietadlo na ceste, meškanie a prílet.</string>
|
||||||
<string name="widget_todos_name">Úlohy</string>
|
<string name="widget_todos_name">Úlohy</string>
|
||||||
<string name="widget_todos_description">Čo ešte zostáva na cestu a ako ďaleko je balenie.</string>
|
<string name="widget_todos_description">Čo ešte zostáva na cestu a ako ďaleko je balenie.</string>
|
||||||
<string name="widget_packing_name">Balenie</string>
|
<string name="widget_packing_name">Balenie</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Dagens plan som tidslinje, med vädret och nästa stopp.</string>
|
<string name="widget_today_description">Dagens plan som tidslinje, med vädret och nästa stopp.</string>
|
||||||
<string name="widget_bookings_name">Bokningar</string>
|
<string name="widget_bookings_name">Bokningar</string>
|
||||||
<string name="widget_bookings_description">Dina nästa flyg, tåg, hotell och bord, och när de är.</string>
|
<string name="widget_bookings_description">Dina nästa flyg, tåg, hotell och bord, och när de är.</string>
|
||||||
|
<string name="widget_flight_name">Flyg</string>
|
||||||
|
<string name="widget_flight_description">Ditt nästa flyg live: nedräkning till avgång, planet på väg, försening och ankomst.</string>
|
||||||
<string name="widget_todos_name">Att göra</string>
|
<string name="widget_todos_name">Att göra</string>
|
||||||
<string name="widget_todos_description">Vad som återstår inför resan och hur långt packningen har kommit.</string>
|
<string name="widget_todos_description">Vad som återstår inför resan och hur långt packningen har kommit.</string>
|
||||||
<string name="widget_packing_name">Packning</string>
|
<string name="widget_packing_name">Packning</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">แผนของวันนี้เป็นไทม์ไลน์ พร้อมสภาพอากาศและจุดหมายถัดไป</string>
|
<string name="widget_today_description">แผนของวันนี้เป็นไทม์ไลน์ พร้อมสภาพอากาศและจุดหมายถัดไป</string>
|
||||||
<string name="widget_bookings_name">การจอง</string>
|
<string name="widget_bookings_name">การจอง</string>
|
||||||
<string name="widget_bookings_description">เที่ยวบิน รถไฟ โรงแรม และร้านอาหารถัดไปของคุณ และเวลาของแต่ละรายการ</string>
|
<string name="widget_bookings_description">เที่ยวบิน รถไฟ โรงแรม และร้านอาหารถัดไปของคุณ และเวลาของแต่ละรายการ</string>
|
||||||
|
<string name="widget_flight_name">เที่ยวบิน</string>
|
||||||
|
<string name="widget_flight_description">เที่ยวบินถัดไปแบบสด: นับถอยหลังถึงเวลาออกเดินทาง เครื่องบินระหว่างทาง ความล่าช้า และเวลาถึง</string>
|
||||||
<string name="widget_todos_name">สิ่งที่ต้องทำ</string>
|
<string name="widget_todos_name">สิ่งที่ต้องทำ</string>
|
||||||
<string name="widget_todos_description">สิ่งที่ยังค้างอยู่สำหรับทริป และความคืบหน้าการจัดกระเป๋า</string>
|
<string name="widget_todos_description">สิ่งที่ยังค้างอยู่สำหรับทริป และความคืบหน้าการจัดกระเป๋า</string>
|
||||||
<string name="widget_packing_name">จัดกระเป๋า</string>
|
<string name="widget_packing_name">จัดกระเป๋า</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Günün planı zaman çizelgesi olarak, hava durumu ve sonraki durakla.</string>
|
<string name="widget_today_description">Günün planı zaman çizelgesi olarak, hava durumu ve sonraki durakla.</string>
|
||||||
<string name="widget_bookings_name">Rezervasyonlar</string>
|
<string name="widget_bookings_name">Rezervasyonlar</string>
|
||||||
<string name="widget_bookings_description">Sıradaki uçuşların, trenlerin, otellerin ve masaların, ne zaman oldukları ile.</string>
|
<string name="widget_bookings_description">Sıradaki uçuşların, trenlerin, otellerin ve masaların, ne zaman oldukları ile.</string>
|
||||||
|
<string name="widget_flight_name">Uçuş</string>
|
||||||
|
<string name="widget_flight_description">Bir sonraki uçuşun canlı: kalkışa geri sayım, yoldaki uçak, gecikme ve varış.</string>
|
||||||
<string name="widget_todos_name">Yapılacaklar</string>
|
<string name="widget_todos_name">Yapılacaklar</string>
|
||||||
<string name="widget_todos_description">Seyahat için hâlâ açık olanlar ve bavulun ne durumda olduğu.</string>
|
<string name="widget_todos_description">Seyahat için hâlâ açık olanlar ve bavulun ne durumda olduğu.</string>
|
||||||
<string name="widget_packing_name">Bavul</string>
|
<string name="widget_packing_name">Bavul</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">План дня у вигляді стрічки часу, з погодою і наступною зупинкою.</string>
|
<string name="widget_today_description">План дня у вигляді стрічки часу, з погодою і наступною зупинкою.</string>
|
||||||
<string name="widget_bookings_name">Бронювання</string>
|
<string name="widget_bookings_name">Бронювання</string>
|
||||||
<string name="widget_bookings_description">Найближчі рейси, поїзди, готелі й столики та коли вони.</string>
|
<string name="widget_bookings_description">Найближчі рейси, поїзди, готелі й столики та коли вони.</string>
|
||||||
|
<string name="widget_flight_name">Рейс</string>
|
||||||
|
<string name="widget_flight_description">Ваш наступний рейс наживо: відлік до вильоту, літак у дорозі, затримка й прибуття.</string>
|
||||||
<string name="widget_todos_name">Завдання</string>
|
<string name="widget_todos_name">Завдання</string>
|
||||||
<string name="widget_todos_description">Що ще лишилося зробити до подорожі і як просувається пакування.</string>
|
<string name="widget_todos_description">Що ще лишилося зробити до подорожі і як просувається пакування.</string>
|
||||||
<string name="widget_packing_name">Пакування</string>
|
<string name="widget_packing_name">Пакування</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Kế hoạch hôm nay dạng dòng thời gian, kèm thời tiết và điểm dừng tiếp theo.</string>
|
<string name="widget_today_description">Kế hoạch hôm nay dạng dòng thời gian, kèm thời tiết và điểm dừng tiếp theo.</string>
|
||||||
<string name="widget_bookings_name">Đặt chỗ</string>
|
<string name="widget_bookings_name">Đặt chỗ</string>
|
||||||
<string name="widget_bookings_description">Các chuyến bay, tàu, khách sạn và bàn sắp tới của bạn, cùng thời gian.</string>
|
<string name="widget_bookings_description">Các chuyến bay, tàu, khách sạn và bàn sắp tới của bạn, cùng thời gian.</string>
|
||||||
|
<string name="widget_flight_name">Chuyến bay</string>
|
||||||
|
<string name="widget_flight_description">Chuyến bay tiếp theo trực tiếp: đếm ngược giờ khởi hành, máy bay đang bay, độ trễ và giờ đến.</string>
|
||||||
<string name="widget_todos_name">Việc cần làm</string>
|
<string name="widget_todos_name">Việc cần làm</string>
|
||||||
<string name="widget_todos_description">Những gì còn lại cho chuyến đi và việc soạn hành lý đã tới đâu.</string>
|
<string name="widget_todos_description">Những gì còn lại cho chuyến đi và việc soạn hành lý đã tới đâu.</string>
|
||||||
<string name="widget_packing_name">Hành lý</string>
|
<string name="widget_packing_name">Hành lý</string>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
<string name="widget_today_description">Today\'s plan as a timeline, with the weather and what is next.</string>
|
<string name="widget_today_description">Today\'s plan as a timeline, with the weather and what is next.</string>
|
||||||
<string name="widget_bookings_name">Bookings</string>
|
<string name="widget_bookings_name">Bookings</string>
|
||||||
<string name="widget_bookings_description">Your next flights, trains, hotels and tables, and when they are due.</string>
|
<string name="widget_bookings_description">Your next flights, trains, hotels and tables, and when they are due.</string>
|
||||||
|
<string name="widget_flight_name">Flight</string>
|
||||||
|
<string name="widget_flight_description">Your next flight live: departure countdown, the aircraft on its way, delay and arrival.</string>
|
||||||
<string name="widget_todos_name">To-dos</string>
|
<string name="widget_todos_name">To-dos</string>
|
||||||
<string name="widget_todos_description">What is still open for the trip, and how far the packing has come.</string>
|
<string name="widget_todos_description">What is still open for the trip, and how far the packing has come.</string>
|
||||||
<string name="widget_packing_name">Packing</string>
|
<string name="widget_packing_name">Packing</string>
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- The flight widget (widget/TrekWidgets.kt). Sizes in cells for Android 12+, dp before.
|
||||||
|
No previewImage: Glance draws the picker preview from the sample trip (providePreview). -->
|
||||||
|
<appwidget-provider xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:description="@string/widget_flight_description"
|
||||||
|
android:initialLayout="@layout/glance_default_loading_layout"
|
||||||
|
android:minWidth="110dp"
|
||||||
|
android:minHeight="110dp"
|
||||||
|
android:minResizeWidth="110dp"
|
||||||
|
android:minResizeHeight="110dp"
|
||||||
|
android:maxResizeWidth="530dp"
|
||||||
|
android:maxResizeHeight="450dp"
|
||||||
|
android:targetCellWidth="4"
|
||||||
|
android:targetCellHeight="2"
|
||||||
|
android:resizeMode="horizontal|vertical"
|
||||||
|
android:updatePeriodMillis="1800000"
|
||||||
|
android:widgetCategory="home_screen"
|
||||||
|
android:configure="com.liketrek.trek.widget.WidgetConfigActivity"
|
||||||
|
android:widgetFeatures="reconfigurable|configuration_optional" />
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.liketrek.trek
|
||||||
|
|
||||||
|
import org.junit.Assert.assertEquals
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
/** The log line for a page that came back with an error status (#3014). */
|
||||||
|
class PageErrorLogTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun namesThePageItsStatusAndWhoAnswered() {
|
||||||
|
val line = PageErrorLog.describe(
|
||||||
|
"https://trek.example.com/login?redirect=%2F#top",
|
||||||
|
503,
|
||||||
|
"Service Unavailable",
|
||||||
|
mapOf(
|
||||||
|
"server" to "cloudflare",
|
||||||
|
"CF-RAY" to "8f1a2b3c4d5e6f70-FRA",
|
||||||
|
"content-type" to "text/html; charset=UTF-8",
|
||||||
|
"Set-Cookie" to "session=secret",
|
||||||
|
),
|
||||||
|
)
|
||||||
|
|
||||||
|
// Any case of a header name is read, only the naming headers are logged,
|
||||||
|
// and the query with its sign-in state is left off.
|
||||||
|
assertEquals(
|
||||||
|
"Page answered HTTP 503 Service Unavailable for https://trek.example.com/login " +
|
||||||
|
"(server: cloudflare, cf-ray: 8f1a2b3c4d5e6f70-FRA, content-type: text/html; charset=UTF-8)",
|
||||||
|
line,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun anAnswerWithoutHeadersSaysSo() {
|
||||||
|
assertEquals(
|
||||||
|
"Page answered HTTP 503 for https://trek.example.com/ (no server headers)",
|
||||||
|
PageErrorLog.describe("https://trek.example.com/", 503, null, emptyMap()),
|
||||||
|
)
|
||||||
|
assertEquals(
|
||||||
|
"Page answered HTTP 502 Bad Gateway for (no server headers)",
|
||||||
|
PageErrorLog.describe(null, 502, "Bad Gateway", null),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aFragmentBeforeAQuestionMarkEndsTheAddressThere() {
|
||||||
|
assertEquals(
|
||||||
|
"Page answered HTTP 500 for https://trek.example.com/trips/4 (via: 1.1 proxy)",
|
||||||
|
PageErrorLog.describe("https://trek.example.com/trips/4#a?b", 500, " ", mapOf("Via" to "1.1 proxy")),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,91 @@
|
|||||||
|
package com.liketrek.trek
|
||||||
|
|
||||||
|
import java.io.File
|
||||||
|
import java.nio.file.Files
|
||||||
|
import org.junit.After
|
||||||
|
import org.junit.Assert.assertArrayEquals
|
||||||
|
import org.junit.Assert.assertFalse
|
||||||
|
import org.junit.Assert.assertTrue
|
||||||
|
import org.junit.Test
|
||||||
|
|
||||||
|
/** The stored copy of the server's UI (TrekOfflineShell), on a plain folder. */
|
||||||
|
class TrekOfflineShellTest {
|
||||||
|
private val root: File = Files.createTempDirectory("offline-shell").toFile()
|
||||||
|
|
||||||
|
@After
|
||||||
|
fun cleanUp() {
|
||||||
|
TrekOfflineShell.deactivate()
|
||||||
|
root.deleteRecursively()
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun theCopyAnswersOnlyForTheServerItWasStartedFor() {
|
||||||
|
TrekOfflineShell.activate("https://a.example.com")
|
||||||
|
assertTrue(TrekOfflineShell.isActive())
|
||||||
|
assertTrue(TrekOfflineShell.isActiveFor("https://a.example.com"))
|
||||||
|
// Another server picked in the same process: its pages come from the server.
|
||||||
|
assertFalse(TrekOfflineShell.isActiveFor("https://b.example.com"))
|
||||||
|
assertFalse(TrekOfflineShell.isActiveFor(null))
|
||||||
|
// A start that reaches the server leaves the copy behind.
|
||||||
|
TrekOfflineShell.deactivate()
|
||||||
|
assertFalse(TrekOfflineShell.isActive())
|
||||||
|
assertFalse(TrekOfflineShell.isActiveFor("https://a.example.com"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aRefreshCutOffHalfwayKeepsThePreviousBuildWhole() {
|
||||||
|
val server = "https://a.example.com"
|
||||||
|
val oldPage = "<script src=/assets/index-old.js>".toByteArray()
|
||||||
|
assertTrue(TrekOfflineShell.beginRefresh(root, server))
|
||||||
|
assertTrue(TrekOfflineShell.saveFile(root, "assets/index-old.js", byteArrayOf(1)))
|
||||||
|
assertTrue(TrekOfflineShell.savePage(root, server, oldPage))
|
||||||
|
assertTrue(TrekOfflineShell.hasCopy(root, server))
|
||||||
|
|
||||||
|
// The next build: one file arrives, then the connection drops before the page is taken over.
|
||||||
|
assertTrue(TrekOfflineShell.beginRefresh(root, server))
|
||||||
|
assertTrue(TrekOfflineShell.saveFile(root, "assets/index-new.js", byteArrayOf(2)))
|
||||||
|
|
||||||
|
assertTrue(TrekOfflineShell.hasCopy(root, server))
|
||||||
|
assertArrayEquals(oldPage, File(root, "index.html").readBytes())
|
||||||
|
assertTrue(TrekOfflineShell.hasFile(root, "assets/index-old.js"))
|
||||||
|
// The file already fetched stays for the next try.
|
||||||
|
assertTrue(TrekOfflineShell.hasFile(root, "assets/index-new.js"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aCompleteRefreshTakesTheNewPageAndDropsTheOldBuild() {
|
||||||
|
val server = "https://a.example.com"
|
||||||
|
TrekOfflineShell.beginRefresh(root, server)
|
||||||
|
TrekOfflineShell.saveFile(root, "assets/index-old.js", byteArrayOf(1))
|
||||||
|
TrekOfflineShell.savePage(root, server, "old".toByteArray())
|
||||||
|
|
||||||
|
TrekOfflineShell.beginRefresh(root, server)
|
||||||
|
TrekOfflineShell.saveFile(root, "assets/index-new.js", byteArrayOf(2))
|
||||||
|
assertTrue(TrekOfflineShell.savePage(root, server, "new".toByteArray()))
|
||||||
|
TrekOfflineShell.prune(root, setOf("assets/index-new.js"))
|
||||||
|
|
||||||
|
assertArrayEquals("new".toByteArray(), File(root, "index.html").readBytes())
|
||||||
|
assertTrue(TrekOfflineShell.hasFile(root, "assets/index-new.js"))
|
||||||
|
assertFalse(TrekOfflineShell.hasFile(root, "assets/index-old.js"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aRefreshForAnotherServerThrowsTheOldCopyAwayFirst() {
|
||||||
|
TrekOfflineShell.beginRefresh(root, "https://a.example.com")
|
||||||
|
TrekOfflineShell.saveFile(root, "assets/index-a.js", byteArrayOf(1))
|
||||||
|
TrekOfflineShell.savePage(root, "https://a.example.com", "a".toByteArray())
|
||||||
|
|
||||||
|
assertTrue(TrekOfflineShell.beginRefresh(root, "https://b.example.com"))
|
||||||
|
|
||||||
|
assertFalse(TrekOfflineShell.hasCopy(root, "https://a.example.com"))
|
||||||
|
assertFalse(TrekOfflineShell.hasCopy(root, "https://b.example.com"))
|
||||||
|
assertFalse(TrekOfflineShell.hasFile(root, "assets/index-a.js"))
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun pathsOutsideTheCopyAreRefused() {
|
||||||
|
assertFalse(TrekOfflineShell.saveFile(root, "../escape.js", byteArrayOf(1)))
|
||||||
|
assertFalse(TrekOfflineShell.saveFile(root, "assets/index.js?v=1", byteArrayOf(1)))
|
||||||
|
assertFalse(TrekOfflineShell.hasFile(root, ""))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -99,4 +99,49 @@ class WidgetSnapshotTest {
|
|||||||
assertEquals("ferry.fill", TrekIcons.booking("cruise").first)
|
assertEquals("ferry.fill", TrekIcons.booking("cruise").first)
|
||||||
assertEquals("bookmark.fill", TrekIcons.booking("something").first)
|
assertEquals("bookmark.fill", TrekIcons.booking("something").first)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun turnsToTheDayOfTheDateItIsReadOn() {
|
||||||
|
val json = """{"trip":{"title":"T","start":"2026-11-06","end":"2026-11-08","path":"/trips/1"},
|
||||||
|
"today":{"date":"2026-11-06","dayLabel":"Day 1 of 3","stops":[{"time":"09:00","name":"Museum","minutes":540}]},
|
||||||
|
"days":[
|
||||||
|
{"date":"2026-11-06","dayLabel":"Day 1 of 3","stops":[{"time":"09:00","name":"Museum","minutes":540}]},
|
||||||
|
{"date":"2026-11-07","dayLabel":"Day 2 of 3","stops":[{"time":"10:00","name":"Harbour","minutes":600}]}
|
||||||
|
],
|
||||||
|
"bookings":[
|
||||||
|
{"title":"Hotel","kind":"hotel","date":"2026-11-06","confirmed":true,"path":"/trips/1"},
|
||||||
|
{"title":"Train","kind":"train","date":"2026-11-07","confirmed":true,"path":"/trips/1"}
|
||||||
|
],
|
||||||
|
"labels":{}}"""
|
||||||
|
val snapshot = WidgetSnapshot.parse(json)!!
|
||||||
|
assertEquals("Day 1 of 3", snapshot.on(LocalDate.of(2026, 11, 6)).today!!.dayLabel)
|
||||||
|
val second = snapshot.on(LocalDate.of(2026, 11, 7))
|
||||||
|
assertEquals("Day 2 of 3", second.today!!.dayLabel)
|
||||||
|
assertEquals("Harbour", second.today!!.stops.single().name)
|
||||||
|
assertEquals(listOf("Train"), second.bookings.map { it.title })
|
||||||
|
// A day the app wrote nothing for (the trip is over) shows no day.
|
||||||
|
assertNull(snapshot.on(LocalDate.of(2026, 11, 9)).today)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun keepsEveryStopOfTheDayItWasWrittenOn() {
|
||||||
|
val json = """{"trip":{"title":"T","start":"2026-11-06","end":"2026-11-07","path":"/trips/1"},
|
||||||
|
"today":{"date":"2026-11-06","dayLabel":"Day 1 of 2","stops":[
|
||||||
|
{"time":"09:00","name":"Museum","minutes":540},{"time":"21:00","name":"Concert","minutes":1260}]},
|
||||||
|
"days":[
|
||||||
|
{"date":"2026-11-06","dayLabel":"Day 1 of 2","stops":[{"time":"09:00","name":"Museum","minutes":540}]},
|
||||||
|
{"date":"2026-11-07","dayLabel":"Day 2 of 2","stops":[{"time":"10:00","name":"Harbour","minutes":600}]}
|
||||||
|
],
|
||||||
|
"labels":{}}"""
|
||||||
|
val snapshot = WidgetSnapshot.parse(json)!!
|
||||||
|
assertEquals(listOf("Museum", "Concert"), snapshot.on(LocalDate.of(2026, 11, 6)).today!!.stops.map { it.name })
|
||||||
|
assertEquals("Day 2 of 2", snapshot.on(LocalDate.of(2026, 11, 7)).today!!.dayLabel)
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun aSnapshotWithoutDaysReadsAsWritten() {
|
||||||
|
val snapshot = WidgetSnapshot.parse(WidgetSamples.json(running = true, now = today))!!
|
||||||
|
assertTrue(snapshot.days.isEmpty())
|
||||||
|
assertEquals(snapshot, snapshot.on(today.plusDays(3)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -117,6 +117,15 @@ so look at three or four pictures from a subset run before starting it.
|
|||||||
each run rebuilds it under the servers of the others. Give each run its own
|
each run rebuilds it under the servers of the others. Give each run its own
|
||||||
`TREK_PLUGINS_DIR` and `TREK_PLUGINS_DATA_DIR` as well (the seed installs a
|
`TREK_PLUGINS_DIR` and `TREK_PLUGINS_DATA_DIR` as well (the seed installs a
|
||||||
plugin), and its own Vite `cacheDir` when it starts a Vite of its own.
|
plugin), and its own Vite `cacheDir` when it starts a Vite of its own.
|
||||||
|
- More than three or four runs at once: build the client once (`npm run build`)
|
||||||
|
and set `E2E_WEB_PREVIEW=1` as well, so each run serves `dist/` with
|
||||||
|
`vite preview` instead of a dev server of its own. A dozen dev servers compiling
|
||||||
|
the app at the same time take the whole machine, and the login of the setup
|
||||||
|
step times out after 45 s. The pictures do not change: the guides drive the
|
||||||
|
same app.
|
||||||
|
- A mocked outside service (a photo library, an AI provider) is answered with
|
||||||
|
`page.context().route`, not `page.route`: once the service worker of the built
|
||||||
|
app controls the page, its requests no longer pass a page route.
|
||||||
- A plugin installed by a run lives in `server/data/plugins/`; the dev server
|
- A plugin installed by a run lives in `server/data/plugins/`; the dev server
|
||||||
imports it on its next restart. Guides that install one uninstall it in `cleanup`.
|
imports it on its next restart. Guides that install one uninstall it in `cleanup`.
|
||||||
- The trip's last day is the run day by construction (`e2e/dates.ts`: every
|
- The trip's last day is the run day by construction (`e2e/dates.ts`: every
|
||||||
|
|||||||
+290
-78
@@ -2,8 +2,9 @@ import { test, expect, type Page, type Locator } from '@playwright/test'
|
|||||||
import { clearNotices } from '../screenshots/shot'
|
import { clearNotices } from '../screenshots/shot'
|
||||||
import { captureGuide, captureHero, dismissReleaseNotice, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
import { captureGuide, captureHero, dismissReleaseNotice, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
||||||
import { ensureAdminFixtures, pluginPackage } from './fixtures'
|
import { ensureAdminFixtures, pluginPackage } from './fixtures'
|
||||||
import { deleteUser, resetDefaults } from './fixtures-admin'
|
import { clearOidc, configureOidc, deleteUser, putAppSettings, resetDefaults } from './fixtures-admin'
|
||||||
import { toggleAddon } from './external'
|
import { toggleAddon } from './external'
|
||||||
|
import { mockInstanceConnection, AI_KEY } from './fixtures-assistant'
|
||||||
import { adminContext, adminTabContexts, adminGuides } from '../../src/help/contexts/admin'
|
import { adminContext, adminTabContexts, adminGuides } from '../../src/help/contexts/admin'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
|
|
||||||
@@ -16,14 +17,15 @@ import type { HelpGuide } from '../../src/help/types'
|
|||||||
|
|
||||||
const TAB_OF: Record<string, string> = {
|
const TAB_OF: Record<string, string> = {
|
||||||
'admin-users': 'Users',
|
'admin-users': 'Users',
|
||||||
'admin-defaults': 'User Defaults',
|
'admin-defaults': 'Defaults',
|
||||||
'admin-config': 'Personalization',
|
'admin-config': 'Personalization',
|
||||||
'admin-settings': 'Settings',
|
// One help screen for the two tabs the old Settings tab became; the hero shows Security.
|
||||||
|
'admin-settings': 'Security',
|
||||||
'admin-addons': 'Addons',
|
'admin-addons': 'Addons',
|
||||||
'admin-plugins': 'Plugins',
|
'admin-plugins': 'Plugins',
|
||||||
'admin-storage': 'Storage',
|
'admin-storage': 'Storage',
|
||||||
'admin-notifications': 'Notifications',
|
'admin-notifications': 'Notifications',
|
||||||
'admin-mcp-tokens': 'MCP Access',
|
'admin-mcp-tokens': 'MCP',
|
||||||
'admin-github': 'GitHub',
|
'admin-github': 'GitHub',
|
||||||
'admin-backup': 'Backup',
|
'admin-backup': 'Backup',
|
||||||
'admin-audit': 'Audit',
|
'admin-audit': 'Audit',
|
||||||
@@ -35,24 +37,30 @@ const guide = (id: string): HelpGuide => {
|
|||||||
return g
|
return g
|
||||||
}
|
}
|
||||||
|
|
||||||
const sidebar = (page: Page) => page.locator('nav').filter({ has: page.getByRole('button', { name: 'User Defaults' }) }).first()
|
const sidebar = (page: Page) => page.locator('nav').filter({ has: page.getByRole('button', { name: 'Personalization' }) }).first()
|
||||||
/** The nearest card around an element: the admin cards are rounded-xl or rounded-2xl boxes, or a <section>. */
|
/** The nearest card around an element: the admin cards are rounded-xl or rounded-2xl boxes, or a <section>. */
|
||||||
const cardOf = (el: Locator) => el.locator('xpath=ancestor::*[contains(@class,"rounded-xl") or contains(@class,"rounded-2xl") or self::section][1]')
|
const cardOf = (el: Locator) => el.locator('xpath=ancestor::*[contains(@class,"rounded-xl") or contains(@class,"rounded-2xl") or self::section][1]')
|
||||||
/** An admin card by the text of its h2. */
|
/** An admin card by the text of its h2. */
|
||||||
const section = (page: Page, title: string | RegExp) => cardOf(page.locator('h2').filter({ hasText: title }).first())
|
const section = (page: Page, title: string | RegExp) => cardOf(page.locator('h2').filter({ hasText: title }).first())
|
||||||
/** A provider block under Settings, a <section> headed by an h3. */
|
/** A block inside a card (a provider, a nested section), a <section> headed by an h3. */
|
||||||
const block = (page: Page, title: string) => page.locator('h3').filter({ hasText: new RegExp(`^${title}$`) }).first().locator('xpath=ancestor::section[1]')
|
const block = (page: Page, title: string) => page.locator('h3').filter({ hasText: new RegExp(`^${title.replace(/[()]/g, '\\$&')}$`) }).first().locator('xpath=ancestor::section[1]')
|
||||||
|
/** One settings row (label, hint, control) by its label. */
|
||||||
|
const row = (scope: Locator, label: string) =>
|
||||||
|
scope.locator('label').filter({ hasText: new RegExp(`^${label}$`) }).first()
|
||||||
|
.locator('xpath=ancestor::div[contains(@class,"px-4") and contains(@class,"py-3")][1]')
|
||||||
const modal = (page: Page) => page.locator('.trek-modal-backdrop').last()
|
const modal = (page: Page) => page.locator('.trek-modal-backdrop').last()
|
||||||
|
const dialogPanel = (page: Page) => modal(page).locator('> [role="presentation"], > div').first()
|
||||||
/** A row of the user table by its username. */
|
/** A row of the user table by its username. */
|
||||||
const userRow = (page: Page, username: string) => page.locator('table tbody tr').filter({ hasText: username }).first()
|
const userRow = (page: Page, username: string) => page.locator('table tbody tr').filter({ hasText: username }).first()
|
||||||
/** A labelled field of the Map card on User Defaults: its label and everything under it. */
|
/** A labelled field of the Map card on Defaults: its label and everything under it. */
|
||||||
const mapField = (page: Page, label: string) => section(page, /^Map$/).locator('label').filter({ hasText: label }).first().locator('xpath=..')
|
const mapField = (page: Page, label: string) => section(page, /^Map$/).locator('label').filter({ hasText: label }).first().locator('xpath=..')
|
||||||
/** The Map engine row's label, which also holds its reset link once the engine is set. */
|
/** The Map engine row's label, which also holds its reset link once the engine is set. */
|
||||||
const engineLabel = (page: Page) => section(page, /^Map$/).locator('label').filter({ hasText: 'Map engine' }).first()
|
const engineLabel = (page: Page) => section(page, /^Map$/).locator('label').filter({ hasText: 'Map engine' }).first()
|
||||||
/** The TREK Places API card at the top of API Keys, found by its pill. */
|
/** The TREK API block at the top of Place search and routing, found by its pill. */
|
||||||
const trekApiCard = (page: Page) => page.getByText('Recommended default', { exact: true }).first().locator('xpath=ancestor::div[contains(@class,"rounded-[14px]")][1]')
|
const trekApiCard = (page: Page) => page.getByText('Recommended default', { exact: true }).first().locator('xpath=ancestor::section[1]')
|
||||||
/** An addon tile by the addon's name. */
|
/** An addon row by the addon's name. */
|
||||||
const tile = (page: Page, name: string) => page.locator('h4').filter({ hasText: new RegExp(`^${name}$`) }).first().locator('xpath=ancestor::article[1]')
|
const tile = (page: Page, name: string) => page.locator('h4').filter({ hasText: new RegExp(`^${name}$`) }).first().locator('xpath=ancestor::article[1]')
|
||||||
|
const authCard = (page: Page) => section(page, 'Authentication Methods')
|
||||||
|
|
||||||
async function openAdmin(page: Page, tab: string): Promise<void> {
|
async function openAdmin(page: Page, tab: string): Promise<void> {
|
||||||
await page.goto('/admin')
|
await page.goto('/admin')
|
||||||
@@ -68,8 +76,29 @@ async function openAdmin(page: Page, tab: string): Promise<void> {
|
|||||||
await settle(page)
|
await settle(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
const opener = (contextId: string) => (page: Page) => openAdmin(page, TAB_OF[contextId])
|
/**
|
||||||
|
* The release list comes from GitHub through the server, which gives up after
|
||||||
|
* eight seconds; a slow answer leaves "Failed to load releases" in the picture,
|
||||||
|
* so the tab is opened again until the list is there.
|
||||||
|
*/
|
||||||
|
async function openGithub(page: Page): Promise<void> {
|
||||||
|
for (let attempt = 0; attempt < 4; attempt++) {
|
||||||
|
await openAdmin(page, 'GitHub')
|
||||||
|
const details = section(page, 'Release History').getByRole('button', { name: 'Show details' }).first()
|
||||||
|
const failed = page.getByText('Failed to load releases', { exact: true })
|
||||||
|
await expect(details.or(failed).first()).toBeVisible({ timeout: 30_000 })
|
||||||
|
if (await details.isVisible()) return settle(page)
|
||||||
|
}
|
||||||
|
throw new Error('GitHub did not answer with the release list')
|
||||||
|
}
|
||||||
|
|
||||||
|
const opener = (contextId: string) => (page: Page) => contextId === 'admin-github' ? openGithub(page) : openAdmin(page, TAB_OF[contextId])
|
||||||
|
const services = (page: Page) => openAdmin(page, 'Services')
|
||||||
const only = (target: (p: Page) => Locator) => ({ target })
|
const only = (target: (p: Page) => Locator) => ({ target })
|
||||||
|
/** The AI tile's settings dialog, named by its title. */
|
||||||
|
const aiDialog = (page: Page) => page.getByRole('dialog').filter({ hasText: 'Set up AI' }).last()
|
||||||
|
/** The admin's AI settings as the run found them, put back after the AI guide. */
|
||||||
|
let aiSettingsBefore: unknown = null
|
||||||
|
|
||||||
const SCRIPTS: Record<string, GuideScript> = {
|
const SCRIPTS: Record<string, GuideScript> = {
|
||||||
// ── Users ────────────────────────────────────────────────────────────────
|
// ── Users ────────────────────────────────────────────────────────────────
|
||||||
@@ -92,7 +121,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await typeInto(p, modal(p).getByPlaceholder('Password'), 'Lena12345!')
|
await typeInto(p, modal(p).getByPlaceholder('Password'), 'Lena12345!')
|
||||||
await beat(p, 300)
|
await beat(p, 300)
|
||||||
},
|
},
|
||||||
target: p => modal(p).locator('> [role="presentation"], > div').first(),
|
target: p => dialogPanel(p),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => modal(p).getByRole('button', { name: 'Create User' }),
|
target: p => modal(p).getByRole('button', { name: 'Create User' }),
|
||||||
@@ -120,7 +149,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => modal(p).locator('> [role="presentation"], > div').first(),
|
target: p => dialogPanel(p),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
||||||
await expect(modal(p)).toHaveCount(0)
|
await expect(modal(p)).toHaveCount(0)
|
||||||
@@ -146,7 +175,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await modal(p).getByRole('button', { name: '14d', exact: true }).click()
|
await modal(p).getByRole('button', { name: '14d', exact: true }).click()
|
||||||
await beat(p, 300)
|
await beat(p, 300)
|
||||||
},
|
},
|
||||||
target: p => modal(p).locator('> [role="presentation"], > div').first(),
|
target: p => dialogPanel(p),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: 'Create & Copy' }).click()
|
await modal(p).getByRole('button', { name: 'Create & Copy' }).click()
|
||||||
await expect(modal(p)).toHaveCount(0)
|
await expect(modal(p)).toHaveCount(0)
|
||||||
@@ -169,14 +198,14 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
const row = section(p, 'Permission Settings').getByText('Delete trips', { exact: true }).locator('xpath=../..')
|
const permRow = row(section(p, 'Permission Settings'), 'Delete trips')
|
||||||
// The select's trigger is the row's only button; its options are buttons too.
|
// The select's trigger is the row's only button; its options are buttons too.
|
||||||
await row.locator('button').first().click()
|
await permRow.locator('button').first().click()
|
||||||
await p.getByRole('button', { name: 'Admin only', exact: true }).last().click()
|
await p.getByRole('button', { name: 'Admin only', exact: true }).last().click()
|
||||||
await expect(row.getByText('customized')).toBeVisible({ timeout: 10_000 })
|
await expect(permRow.getByText('customized')).toBeVisible({ timeout: 10_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: p => section(p, 'Permission Settings').getByText('Delete trips', { exact: true }).locator('xpath=../..'),
|
target: p => row(section(p, 'Permission Settings'), 'Delete trips'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => section(p, 'Permission Settings').getByRole('button', { name: 'Save', exact: true }),
|
target: p => section(p, 'Permission Settings').getByRole('button', { name: 'Save', exact: true }),
|
||||||
@@ -189,7 +218,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── User Defaults ────────────────────────────────────────────────────────
|
// ── Defaults ─────────────────────────────────────────────────────────────
|
||||||
'default-user-settings': {
|
'default-user-settings': {
|
||||||
guide: guide('default-user-settings'),
|
guide: guide('default-user-settings'),
|
||||||
start: opener('admin-defaults'),
|
start: opener('admin-defaults'),
|
||||||
@@ -203,7 +232,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await expect(section(p, 'Default User Settings').locator('button').filter({ hasText: /^reset$/ })).toBeVisible({ timeout: 10_000 })
|
await expect(section(p, 'Default User Settings').locator('button').filter({ hasText: /^reset$/ })).toBeVisible({ timeout: 10_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: p => section(p, 'Default User Settings').locator('label').filter({ hasText: 'Color Mode' }).locator('xpath=..'),
|
// The whole row: its name with the reset link, and the choice on the right.
|
||||||
|
target: p => section(p, 'Default User Settings').locator('label').filter({ hasText: 'Color Mode' }).first()
|
||||||
|
.locator('xpath=ancestor::div[contains(@class,"px-4") and contains(@class,"py-3")][1]'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await section(p, 'Default User Settings').locator('button').filter({ hasText: /^reset$/ }).first().click()
|
await section(p, 'Default User Settings').locator('button').filter({ hasText: /^reset$/ }).first().click()
|
||||||
await expect(section(p, 'Default User Settings').locator('button').filter({ hasText: /^reset$/ })).toHaveCount(0, { timeout: 10_000 })
|
await expect(section(p, 'Default User Settings').locator('button').filter({ hasText: /^reset$/ })).toHaveCount(0, { timeout: 10_000 })
|
||||||
@@ -249,6 +280,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// Typed, never committed: the field saves on blur only when the value changed,
|
// Typed, never committed: the field saves on blur only when the value changed,
|
||||||
// and emptying it first leaves the saved value (none) as it was.
|
// and emptying it first leaves the saved value (none) as it was.
|
||||||
steps: [
|
steps: [
|
||||||
|
only(p => section(p, /^Routing$/)),
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await typeInto(p, p.getByLabel('Own routing engine', { exact: true }), 'https://osrm.example.org')
|
await typeInto(p, p.getByLabel('Own routing engine', { exact: true }), 'https://osrm.example.org')
|
||||||
@@ -319,7 +351,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
// The new category opens in a dialog, its name in the dialog's head.
|
// The new category opens in a dialog, its name in the dialog's head.
|
||||||
target: p => modal(p).locator('> [role="presentation"], > div').first(),
|
target: p => dialogPanel(p),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
||||||
await expect(p.getByPlaceholder('Category name')).toHaveCount(0)
|
await expect(p.getByPlaceholder('Category name')).toHaveCount(0)
|
||||||
@@ -358,7 +390,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await expect(modal(p).getByRole('textbox', { name: 'Holiday name' }).first()).toHaveValue('Autumn break', { timeout: 10_000 })
|
await expect(modal(p).getByRole('textbox', { name: 'Holiday name' }).first()).toHaveValue('Autumn break', { timeout: 10_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: p => modal(p).locator('> [role="presentation"], > div').first(),
|
target: p => dialogPanel(p),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
||||||
await expect(modal(p)).toHaveCount(0)
|
await expect(modal(p)).toHaveCount(0)
|
||||||
@@ -367,23 +399,29 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── Settings ─────────────────────────────────────────────────────────────
|
// ── Security ─────────────────────────────────────────────────────────────
|
||||||
'auth-methods': {
|
'auth-methods': {
|
||||||
guide: guide('auth-methods'),
|
guide: guide('auth-methods'),
|
||||||
start: opener('admin-settings'),
|
// The SSO rows exist only once OIDC is configured, so the guide sets an
|
||||||
|
// issuer and a client id up front and takes them away again afterwards.
|
||||||
|
start: async p => {
|
||||||
|
await configureOidc(p.request)
|
||||||
|
await openAdmin(p, 'Security')
|
||||||
|
await expect(row(authCard(p), 'SSO Login')).toBeVisible({ timeout: 10_000 })
|
||||||
|
},
|
||||||
steps: [
|
steps: [
|
||||||
only(p => section(p, 'Authentication Methods').getByText('Password Login', { exact: true }).locator('xpath=../..')),
|
only(p => row(authCard(p), 'Password Login')),
|
||||||
// The SSO rows exist only once OIDC is configured; the run shows where that happens.
|
only(p => row(authCard(p), 'SSO Auto-Provisioning')),
|
||||||
only(p => section(p, 'Single Sign-On (OIDC)')),
|
only(p => row(authCard(p), 'Require 2FA')),
|
||||||
only(p => section(p, 'Require two-factor authentication (2FA)')),
|
|
||||||
],
|
],
|
||||||
|
cleanup: p => clearOidc(p.request),
|
||||||
},
|
},
|
||||||
'admin-passkeys': {
|
'admin-passkeys': {
|
||||||
guide: guide('admin-passkeys'),
|
guide: guide('admin-passkeys'),
|
||||||
start: opener('admin-settings'),
|
start: opener('admin-settings'),
|
||||||
steps: [
|
steps: [
|
||||||
// Not flipped: the switch saves at once, and the seed keeps passkeys off.
|
// Not flipped: the switch saves at once, and the seed keeps passkeys off.
|
||||||
only(p => section(p, 'Passkey login').getByRole('button', { name: 'Enable passkey login' }).locator('xpath=ancestor::div[contains(@class,"divide-y")][1]')),
|
only(p => row(authCard(p), 'Enable passkey login')),
|
||||||
only(p => section(p, 'Passkey login')),
|
only(p => section(p, 'Passkey login')),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -391,41 +429,36 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
guide: guide('oidc'),
|
guide: guide('oidc'),
|
||||||
start: opener('admin-settings'),
|
start: opener('admin-settings'),
|
||||||
steps: [
|
steps: [
|
||||||
only(p => section(p, 'Single Sign-On (OIDC)')),
|
|
||||||
only(p => section(p, 'Authentication Methods')),
|
|
||||||
],
|
|
||||||
},
|
|
||||||
'instance-keys': {
|
|
||||||
guide: guide('instance-keys'),
|
|
||||||
start: opener('admin-settings'),
|
|
||||||
steps: [
|
|
||||||
only(p => trekApiCard(p)),
|
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
const details = p.locator('details').filter({ hasText: 'What the key may be used for' })
|
const card = section(p, 'Single Sign-On (OIDC)')
|
||||||
if (!(await details.evaluate(el => (el as HTMLDetailsElement).open))) await details.locator('summary').click()
|
await typeInto(p, card.locator('#oidc-display-name'), 'Authentik')
|
||||||
await settle(p)
|
await typeInto(p, card.locator('#oidc-issuer'), 'https://auth.example.org/application/o/trek/')
|
||||||
|
await typeInto(p, card.locator('#oidc-client-id'), 'trek')
|
||||||
|
await typeInto(p, card.locator('#oidc-client-secret'), 'a-long-client-secret')
|
||||||
|
await beat(p, 300)
|
||||||
|
},
|
||||||
|
target: p => section(p, 'Single Sign-On (OIDC)'),
|
||||||
|
hover: async p => { await section(p, 'Single Sign-On (OIDC)').getByRole('button', { name: 'Save', exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await section(p, 'Single Sign-On (OIDC)').getByRole('button', { name: 'Save', exact: true }).click()
|
||||||
|
await expect.poll(async () => {
|
||||||
|
const res = await p.request.get('/api/admin/oidc')
|
||||||
|
return ((await res.json()) as { client_id?: string }).client_id
|
||||||
|
}, { timeout: 10_000 }).toBe('trek')
|
||||||
},
|
},
|
||||||
// The whole Google block: key, Test and the fold opened under it.
|
|
||||||
target: p => block(p, 'Google Maps API Key'),
|
|
||||||
},
|
},
|
||||||
only(p => block(p, 'Unsplash API Key')),
|
{
|
||||||
],
|
// The card and the sign-in rows read the configuration when the page loads.
|
||||||
},
|
prepare: async p => {
|
||||||
'places-transit': {
|
await openAdmin(p, 'Security')
|
||||||
guide: guide('places-transit'),
|
await expect(row(authCard(p), 'SSO Login')).toBeVisible({ timeout: 10_000 })
|
||||||
start: opener('admin-settings'),
|
},
|
||||||
steps: [
|
target: p => row(authCard(p), 'SSO Login'),
|
||||||
only(p => block(p, 'Transit Provider')),
|
},
|
||||||
only(p => block(p, 'Place search provider')),
|
only(p => row(authCard(p), 'Go straight to SSO')),
|
||||||
],
|
|
||||||
},
|
|
||||||
'file-types': {
|
|
||||||
guide: guide('file-types'),
|
|
||||||
start: opener('admin-settings'),
|
|
||||||
steps: [
|
|
||||||
only(p => section(p, 'Allowed File Types')),
|
|
||||||
],
|
],
|
||||||
|
cleanup: p => clearOidc(p.request),
|
||||||
},
|
},
|
||||||
'rotate-jwt-secret': {
|
'rotate-jwt-secret': {
|
||||||
guide: guide('rotate-jwt-secret'),
|
guide: guide('rotate-jwt-secret'),
|
||||||
@@ -440,7 +473,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => modal(p).locator('> [role="presentation"], > div').first(),
|
target: p => dialogPanel(p),
|
||||||
// Never confirmed: rotating would sign the run itself out.
|
// Never confirmed: rotating would sign the run itself out.
|
||||||
hover: async p => { await modal(p).getByRole('button', { name: 'Rotate & Log out' }).hover() },
|
hover: async p => { await modal(p).getByRole('button', { name: 'Rotate & Log out' }).hover() },
|
||||||
act: async p => {
|
act: async p => {
|
||||||
@@ -451,6 +484,33 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// ── Services ─────────────────────────────────────────────────────────────
|
||||||
|
'instance-keys': {
|
||||||
|
guide: guide('instance-keys'),
|
||||||
|
start: services,
|
||||||
|
steps: [
|
||||||
|
only(p => trekApiCard(p)),
|
||||||
|
// The whole Google block: key, Test and what the key may be used for under it.
|
||||||
|
only(p => block(p, 'Google Maps API Key')),
|
||||||
|
only(p => block(p, 'Unsplash API Key')),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'places-transit': {
|
||||||
|
guide: guide('places-transit'),
|
||||||
|
start: services,
|
||||||
|
steps: [
|
||||||
|
only(p => block(p, 'Transit Provider')),
|
||||||
|
only(p => block(p, 'Place search provider')),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
'file-types': {
|
||||||
|
guide: guide('file-types'),
|
||||||
|
start: services,
|
||||||
|
steps: [
|
||||||
|
only(p => section(p, 'Allowed File Types')),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
// ── Addons ───────────────────────────────────────────────────────────────
|
// ── Addons ───────────────────────────────────────────────────────────────
|
||||||
'toggle-addon': {
|
'toggle-addon': {
|
||||||
guide: guide('toggle-addon'),
|
guide: guide('toggle-addon'),
|
||||||
@@ -475,11 +535,12 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
guide: guide('document-providers'),
|
guide: guide('document-providers'),
|
||||||
start: opener('admin-addons'),
|
start: opener('admin-addons'),
|
||||||
steps: [
|
steps: [
|
||||||
// The tile with its shelf: Documents is on in the seed, so the five rows are drawn.
|
// The row with its options: Documents is on in the seed, so the five stores are drawn.
|
||||||
only(p => tile(p, 'Documents')),
|
only(p => tile(p, 'Documents')),
|
||||||
{
|
{
|
||||||
// The row's switch is a ToggleSwitch whose aria-label is the row's title.
|
// The whole row, so its name is in the frame; the switch's aria-label is the row's title.
|
||||||
target: p => tile(p, 'Documents').getByRole('button', { name: 'Nextcloud', exact: true }),
|
target: p => tile(p, 'Documents').getByRole('button', { name: 'Nextcloud', exact: true }).locator('xpath=ancestor::li[1]'),
|
||||||
|
hover: async p => { await tile(p, 'Documents').getByRole('button', { name: 'Nextcloud', exact: true }).hover() },
|
||||||
act: async p => {
|
act: async p => {
|
||||||
const toggle = tile(p, 'Documents').getByRole('button', { name: 'Nextcloud', exact: true })
|
const toggle = tile(p, 'Documents').getByRole('button', { name: 'Nextcloud', exact: true })
|
||||||
await toggle.click()
|
await toggle.click()
|
||||||
@@ -491,6 +552,157 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// Back to the seed, where every store is off; the files run switches this one on for itself.
|
// Back to the seed, where every store is off; the files run switches this one on for itself.
|
||||||
cleanup: p => toggleAddon(p.request, 'nextcloud', false),
|
cleanup: p => toggleAddon(p.request, 'nextcloud', false),
|
||||||
},
|
},
|
||||||
|
'mail-import-setup': {
|
||||||
|
guide: guide('mail-import-setup'),
|
||||||
|
start: opener('admin-addons'),
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => tile(p, 'Booking mail import'),
|
||||||
|
act: async p => {
|
||||||
|
const toggle = tile(p, 'Booking mail import').getByRole('button', { name: 'Import booking mails' })
|
||||||
|
await toggle.click()
|
||||||
|
await expect(toggle).toHaveAttribute('aria-pressed', 'true', { timeout: 10_000 })
|
||||||
|
await expect(p.getByRole('button', { name: 'Set up mail import' })).toBeVisible({ timeout: 10_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => p.getByRole('button', { name: 'Set up mail import' }),
|
||||||
|
act: async p => {
|
||||||
|
await p.getByRole('button', { name: 'Set up mail import' }).click()
|
||||||
|
await expect(modal(p)).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// IMAP draws every field the step names; nothing is saved, so no mailbox is asked.
|
||||||
|
prepare: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: 'Upload only' }).click()
|
||||||
|
await p.getByRole('button', { name: 'IMAP mailbox', exact: true }).last().click()
|
||||||
|
await expect(modal(p).locator('#mail-imap-host')).toBeVisible()
|
||||||
|
await typeInto(p, modal(p).locator('#mail-template'), 'trek+{token}@example.org')
|
||||||
|
await typeInto(p, modal(p).locator('#mail-imap-host'), 'imap.example.org')
|
||||||
|
await typeInto(p, modal(p).locator('#mail-imap-user'), 'trek@example.org')
|
||||||
|
await typeInto(p, modal(p).locator('#mail-imap-pass'), 'mailbox-password')
|
||||||
|
await beat(p, 300)
|
||||||
|
},
|
||||||
|
target: p => dialogPanel(p),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => modal(p).getByRole('button', { name: 'Test connection' }).locator('xpath=..'),
|
||||||
|
hover: async p => { await modal(p).getByRole('button', { name: 'Save', exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: 'Close', exact: true }).last().click()
|
||||||
|
// The setup asks before it drops what was typed.
|
||||||
|
await p.getByRole('button', { name: 'Discard', exact: true }).click()
|
||||||
|
await expect(modal(p)).toHaveCount(0)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: p => putAppSettings(p.request, { mail_ingest_enabled: false }),
|
||||||
|
},
|
||||||
|
'ai-setup': {
|
||||||
|
guide: guide('ai-setup'),
|
||||||
|
// The key is never tested against a provider: fixtures-assistant.ts answers for the connection.
|
||||||
|
start: async p => {
|
||||||
|
const res = await p.request.get('/api/admin/ai/settings')
|
||||||
|
aiSettingsBefore = res.ok() ? await res.json() : null
|
||||||
|
await toggleAddon(p.request, 'ai_assistant', false)
|
||||||
|
await mockInstanceConnection(p)
|
||||||
|
await openAdmin(p, TAB_OF['admin-addons'])
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => tile(p, 'AI'),
|
||||||
|
act: async p => {
|
||||||
|
const toggle = tile(p, 'AI').getByRole('button', { name: 'AI Assistant', exact: true })
|
||||||
|
await toggle.click()
|
||||||
|
await expect(toggle).toHaveAttribute('aria-pressed', 'true', { timeout: 10_000 })
|
||||||
|
await expect(tile(p, 'AI').getByRole('button', { name: 'Set up AI' })).toBeVisible({ timeout: 10_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => tile(p, 'AI').getByRole('button', { name: 'Set up AI' }),
|
||||||
|
act: async p => {
|
||||||
|
await tile(p, 'AI').getByRole('button', { name: 'Set up AI' }).click()
|
||||||
|
await expect(aiDialog(p).getByRole('radiogroup', { name: 'Who pays' })).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => aiDialog(p).getByRole('radiogroup', { name: 'Who pays' }).locator('xpath=..'),
|
||||||
|
hover: async p => { await aiDialog(p).getByRole('radio', { name: 'I pay, own allowed' }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await aiDialog(p).getByRole('radio', { name: 'I pay, own allowed' }).click()
|
||||||
|
await expect(aiDialog(p).getByRole('radio', { name: 'I pay, own allowed' })).toHaveAttribute('aria-checked', 'true')
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await aiDialog(p).getByRole('button', { name: /^Paste an API key/ }).click()
|
||||||
|
await typeInto(p, aiDialog(p).getByPlaceholder('Paste your key here'), AI_KEY)
|
||||||
|
await expect(aiDialog(p).getByText('Detected: Anthropic')).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => aiDialog(p).getByText('Connection for everyone', { exact: true }).locator('xpath=..'),
|
||||||
|
hover: async p => { await aiDialog(p).getByRole('button', { name: 'Connect', exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await aiDialog(p).getByRole('button', { name: 'Connect', exact: true }).click()
|
||||||
|
await expect(aiDialog(p).getByRole('button', { name: 'Remove connection' })).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => aiDialog(p).getByRole('button', { name: 'Remove connection' }).locator('xpath=ancestor::div[contains(@class,"p-3")][1]'),
|
||||||
|
act: async p => {
|
||||||
|
await aiDialog(p).getByRole('button', { name: 'AI Assistant', exact: true }).click()
|
||||||
|
await expect(aiDialog(p).getByText('Keep chats', { exact: true })).toBeVisible({ timeout: 10_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
only(p => aiDialog(p).getByText('Keep chats', { exact: true }).locator('xpath=ancestor::div[contains(@class,"gap-4")][1]')),
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
if (aiSettingsBefore) await p.request.put('/api/admin/ai/settings', { data: aiSettingsBefore })
|
||||||
|
await toggleAddon(p.request, 'ai_assistant', false)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'paddle-water-data': {
|
||||||
|
guide: guide('paddle-water-data'),
|
||||||
|
start: opener('admin-addons'),
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => p.getByRole('button', { name: /^Paddle water data/ }),
|
||||||
|
act: async p => {
|
||||||
|
await p.getByRole('button', { name: /^Paddle water data/ }).click()
|
||||||
|
await expect(modal(p)).toBeVisible()
|
||||||
|
await expect(modal(p).getByTestId('paddle-auto-load')).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
only(p => modal(p).getByTestId('paddle-auto-load')),
|
||||||
|
{
|
||||||
|
// A search shows the hits with their Add; Geofabrik's list comes through the server.
|
||||||
|
prepare: async p => {
|
||||||
|
const field = modal(p).getByPlaceholder('Search Geofabrik, for example Oberpfalz')
|
||||||
|
await typeInto(p, field, 'Oberpfalz')
|
||||||
|
const hit = modal(p).getByRole('button', { name: 'Add', exact: true }).first()
|
||||||
|
const failed = modal(p).getByRole('alert')
|
||||||
|
await expect(hit.or(failed).first()).toBeVisible({ timeout: 30_000 })
|
||||||
|
// Without Geofabrik the field stays empty rather than showing an error.
|
||||||
|
if (!(await hit.isVisible())) await field.fill('')
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => modal(p).getByPlaceholder('Search Geofabrik, for example Oberpfalz').locator('xpath=ancestor::div[contains(@class,"gap-2")][1]'),
|
||||||
|
act: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: 'Close', exact: true }).last().click()
|
||||||
|
await expect(modal(p)).toHaveCount(0)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
// ── Plugins ──────────────────────────────────────────────────────────────
|
// ── Plugins ──────────────────────────────────────────────────────────────
|
||||||
'install-plugin': {
|
'install-plugin': {
|
||||||
@@ -518,9 +730,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
{
|
{
|
||||||
target: p => p.getByTestId('plugin-row-menu-btn-trip-doctor').locator('xpath=ancestor::div[contains(@class,"group") and contains(@class,"px-3.5")][1]'),
|
target: p => p.getByTestId('plugin-row-menu-btn-trip-doctor').locator('xpath=ancestor::div[contains(@class,"group") and contains(@class,"px-3.5")][1]'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
const row = p.getByTestId('plugin-row-menu-btn-trip-doctor').locator('xpath=ancestor::div[contains(@class,"group") and contains(@class,"px-3.5")][1]')
|
const pluginRow = p.getByTestId('plugin-row-menu-btn-trip-doctor').locator('xpath=ancestor::div[contains(@class,"group") and contains(@class,"px-3.5")][1]')
|
||||||
await row.getByRole('button', { name: 'Enable plugin' }).click()
|
await pluginRow.getByRole('button', { name: 'Enable plugin' }).click()
|
||||||
await expect(row.getByText('Active', { exact: true })).toBeVisible({ timeout: 30_000 })
|
await expect(pluginRow.getByText('Active', { exact: true })).toBeVisible({ timeout: 30_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -555,7 +767,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
// The new backend opens in a dialog.
|
// The new backend opens in a dialog.
|
||||||
target: p => modal(p).locator('> [role="presentation"], > div').first(),
|
target: p => dialogPanel(p),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
await modal(p).getByRole('button', { name: 'Cancel' }).click()
|
||||||
await expect(modal(p).getByText('Add backend', { exact: true })).toHaveCount(0)
|
await expect(modal(p).getByText('Add backend', { exact: true })).toHaveCount(0)
|
||||||
@@ -573,19 +785,19 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
guide: guide('channels-instance'),
|
guide: guide('channels-instance'),
|
||||||
start: opener('admin-notifications'),
|
start: opener('admin-notifications'),
|
||||||
steps: [
|
steps: [
|
||||||
only(p => section(p, 'Email (SMTP)')),
|
only(p => block(p, 'Email (SMTP)')),
|
||||||
only(p => section(p, /^Ntfy$/)),
|
only(p => section(p, /^Channels$/).locator('div.divide-y').first()),
|
||||||
only(p => section(p, 'Trip Reminders')),
|
only(p => row(section(p, /^Channels$/), 'Trip Reminders')),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'admin-channels': {
|
'admin-channels': {
|
||||||
guide: guide('admin-channels'),
|
guide: guide('admin-channels'),
|
||||||
start: opener('admin-notifications'),
|
start: opener('admin-notifications'),
|
||||||
steps: [
|
steps: [
|
||||||
only(p => section(p, 'Admin Ntfy')),
|
only(p => section(p, 'Admin alerts')),
|
||||||
only(p => section(p, 'Admin Ntfy').getByRole('button', { name: 'Send test ntfy' })),
|
only(p => block(p, 'Admin Ntfy').getByRole('button', { name: 'Send test ntfy' })),
|
||||||
// The admin matrix: the card whose title is the tab's own name.
|
// The admin matrix at the foot of the same card.
|
||||||
only(p => section(p, /^Notifications$/)),
|
only(p => section(p, 'Admin alerts').locator('div.overflow-x-auto').first()),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'notification-defaults': {
|
'notification-defaults': {
|
||||||
@@ -598,7 +810,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
// ── MCP Access ───────────────────────────────────────────────────────────
|
// ── MCP ──────────────────────────────────────────────────────────────────
|
||||||
'mcp-tokens-admin': {
|
'mcp-tokens-admin': {
|
||||||
guide: guide('mcp-tokens-admin'),
|
guide: guide('mcp-tokens-admin'),
|
||||||
start: opener('admin-mcp-tokens'),
|
start: opener('admin-mcp-tokens'),
|
||||||
@@ -660,11 +872,11 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
target: p => section(p, 'Auto-Backup').getByRole('button', { name: /^Enable auto-backup/ }).locator('xpath=ancestor::label[1]'),
|
target: p => section(p, 'Auto-Backup').getByRole('button', { name: /^Enable auto-backup/ }).locator('xpath=ancestor::label[1]'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await section(p, 'Auto-Backup').getByRole('button', { name: /^Enable auto-backup/ }).click()
|
await section(p, 'Auto-Backup').getByRole('button', { name: /^Enable auto-backup/ }).click()
|
||||||
await expect(section(p, 'Auto-Backup').getByText('Interval', { exact: true })).toBeVisible({ timeout: 10_000 })
|
await expect(section(p, 'Auto-Backup').getByText('Interval', { exact: true }).first()).toBeVisible({ timeout: 10_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
only(p => section(p, 'Auto-Backup').getByText('Delete old backups after', { exact: true }).locator('xpath=..')),
|
only(p => row(section(p, 'Auto-Backup'), 'Delete old backups after')),
|
||||||
],
|
],
|
||||||
cleanup: async p => {
|
cleanup: async p => {
|
||||||
await section(p, 'Auto-Backup').getByRole('button', { name: /^Enable auto-backup/ }).click()
|
await section(p, 'Auto-Backup').getByRole('button', { name: /^Enable auto-backup/ }).click()
|
||||||
|
|||||||
@@ -236,6 +236,13 @@ async function excludedTours(page: Page): Promise<Set<number>> {
|
|||||||
/** What was left out before the tour guide ran, so `cleanup` counts exactly its own change again. */
|
/** What was left out before the tour guide ran, so `cleanup` counts exactly its own change again. */
|
||||||
let excludedBefore = new Set<number>()
|
let excludedBefore = new Set<number>()
|
||||||
|
|
||||||
|
/** Why the Dawarich connection could not be made in `beforeAll`, if it could not. */
|
||||||
|
let dawarichMissing: Error | null = null
|
||||||
|
async function openAtlasWithDawarich(page: Page): Promise<void> {
|
||||||
|
if (dawarichMissing) throw dawarichMissing
|
||||||
|
await openAtlas(page)
|
||||||
|
}
|
||||||
|
|
||||||
const SCRIPTS: Record<string, GuideScript> = {
|
const SCRIPTS: Record<string, GuideScript> = {
|
||||||
'mark-country': {
|
'mark-country': {
|
||||||
guide: guide('mark-country'),
|
guide: guide('mark-country'),
|
||||||
@@ -364,6 +371,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await expect(detailCard(p, 'Portugal')).toBeVisible()
|
await expect(detailCard(p, 'Portugal')).toBeVisible()
|
||||||
},
|
},
|
||||||
target: p => detailCard(p, 'Portugal'),
|
target: p => detailCard(p, 'Portugal'),
|
||||||
|
// On the name with its Planned label: the centre of the card is the
|
||||||
|
// Places badge, whose tooltip covered the trip chip under it.
|
||||||
|
hover: p => panel(p).locator('p.text-sm.font-bold').filter({ hasText: 'Portugal' }).hover(),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -607,7 +617,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// The side column: the Planned and Recorded badges, what does not
|
// The side column: the Planned and Recorded badges, what does not
|
||||||
// count yet, and the i whose tooltip states the rule.
|
// count yet, and the i whose tooltip states the rule.
|
||||||
target: p => showToursButton(p).locator('xpath=..'),
|
target: p => showToursButton(p).locator('xpath=..'),
|
||||||
hover: p => tourPane(p).getByRole('button', { name: 'My tour activities', exact: true }).hover(),
|
// On Still ahead, whose tooltip is one short line. The i's tooltip is the
|
||||||
|
// whole rule in one wide line, and it covered the badges the step names.
|
||||||
|
hover: p => tourPane(p).getByText('Still ahead', { exact: true }).hover(),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: showToursButton,
|
target: showToursButton,
|
||||||
@@ -619,7 +631,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => firstTourRow(p),
|
target: p => firstTourRow(p),
|
||||||
hover: p => firstTourRow(p).locator('[data-testid^="tour-activity-toggle-"]').hover(),
|
// On the tour's name, which has no tooltip: the button's own tooltip ran
|
||||||
|
// past the frame's edge and over the row below.
|
||||||
|
hover: p => firstTourRow(p).locator('span.font-semibold').first().hover(),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
// Found again by its own id afterwards: the list may sort a left-out tour elsewhere.
|
// Found again by its own id afterwards: the list may sort a left-out tour elsewhere.
|
||||||
const id = await firstTourRow(p).getAttribute('data-testid')
|
const id = await firstTourRow(p).getAttribute('data-testid')
|
||||||
@@ -644,7 +658,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
'dawarich-countries': {
|
'dawarich-countries': {
|
||||||
guide: guide('dawarich-countries'),
|
guide: guide('dawarich-countries'),
|
||||||
start: async p => {
|
start: async p => {
|
||||||
await openAtlas(p)
|
await openAtlasWithDawarich(p)
|
||||||
visitedBefore = await visitedCodes(p)
|
visitedBefore = await visitedCodes(p)
|
||||||
},
|
},
|
||||||
steps: [
|
steps: [
|
||||||
@@ -708,7 +722,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
|
|
||||||
'dawarich-wishes': {
|
'dawarich-wishes': {
|
||||||
guide: guide('dawarich-wishes'),
|
guide: guide('dawarich-wishes'),
|
||||||
start: openAtlas,
|
start: openAtlasWithDawarich,
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
target: p => tile(p, 'Wishlist'),
|
target: p => tile(p, 'Wishlist'),
|
||||||
@@ -773,8 +787,14 @@ test.beforeAll(async ({ request }) => {
|
|||||||
const { ensureToursFixtures } = await import('./tour-fixtures')
|
const { ensureToursFixtures } = await import('./tour-fixtures')
|
||||||
await ensureToursFixtures(request)
|
await ensureToursFixtures(request)
|
||||||
// After the Atlas fixtures: the connection adds two wishes with coordinates
|
// After the Atlas fixtures: the connection adds two wishes with coordinates
|
||||||
// (Fushimi Inari Taisha, Wadi Rum) to the list the fixtures create.
|
// (Fushimi Inari Taisha, Wadi Rum) to the list the fixtures create. Without
|
||||||
await ensureDawarichConnection(request)
|
// media.env it cannot be made; the two Dawarich guides then fail at their
|
||||||
|
// start with the reason, and every other guide of the file still runs.
|
||||||
|
try {
|
||||||
|
await ensureDawarichConnection(request)
|
||||||
|
} catch (err) {
|
||||||
|
dawarichMissing = err instanceof Error ? err : new Error(String(err))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test.afterAll(async ({ request }) => {
|
test.afterAll(async ({ request }) => {
|
||||||
|
|||||||
@@ -862,6 +862,35 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'collection-map-lock': {
|
||||||
|
guide: guide('collection-map-lock'),
|
||||||
|
start: p => openList(p, KYOTO),
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => mapShell(p).getByTestId('map-lock-pill'),
|
||||||
|
act: async p => {
|
||||||
|
await mapShell(p).getByTestId('map-lock-pill').click()
|
||||||
|
await expect(mapShell(p).getByRole('button', { name: 'Let the map follow the selection' })).toBeVisible()
|
||||||
|
await blurFocus(p)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => placeRows(p).nth(1),
|
||||||
|
act: async p => {
|
||||||
|
await placeRows(p).nth(1).click()
|
||||||
|
await expect(detail(p)).toBeVisible()
|
||||||
|
// Locked, the map keeps the frame of the whole list, so every pin stays in view.
|
||||||
|
await pageReady(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
const unlock = mapShell(p).getByRole('button', { name: 'Let the map follow the selection' })
|
||||||
|
if (await unlock.count()) await unlock.click()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
'tour-collection-add-to-trip': {
|
'tour-collection-add-to-trip': {
|
||||||
guide: guide('tour-collection-add-to-trip'),
|
guide: guide('tour-collection-add-to-trip'),
|
||||||
start: async p => {
|
start: async p => {
|
||||||
|
|||||||
@@ -468,6 +468,24 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'travel-stats': {
|
||||||
|
guide: guide('travel-stats'),
|
||||||
|
start: async p => {
|
||||||
|
await openDashboard(p)
|
||||||
|
// The flags load from flagcdn; wait for them so the card is not half drawn.
|
||||||
|
await expect(p.locator('.atlas-card.passport .passport-flags img').first()).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => p.locator('.atlas-card.passport'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => p.locator('section.atlas'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
widgets: {
|
widgets: {
|
||||||
guide: guide('widgets'),
|
guide: guide('widgets'),
|
||||||
start: openDashboard,
|
start: openDashboard,
|
||||||
@@ -497,8 +515,11 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await p.getByText('Dashboard widgets', { exact: true }).first().scrollIntoViewIfNeeded()
|
await p.getByText('Dashboard widgets', { exact: true }).first().scrollIntoViewIfNeeded()
|
||||||
await beat(p, 400)
|
await beat(p, 400)
|
||||||
},
|
},
|
||||||
// The Section card itself: the nearest rounded container around its heading.
|
// The Desktop block of the card (its groups and the Right sidebar switch). The
|
||||||
target: p => p.getByText('Dashboard widgets', { exact: true }).first().locator('xpath=ancestor::section[1]'),
|
// whole card with its Mobile half is taller than the frame, and the settings
|
||||||
|
// pane scrolls on its own, so its top ended up under the navigation bar.
|
||||||
|
target: p => p.getByText('Dashboard widgets', { exact: true }).first().locator('xpath=ancestor::section[1]')
|
||||||
|
.getByText('Desktop', { exact: true }).locator('xpath=ancestor::section[1]'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => p.getByRole('link', { name: 'My Trips' }),
|
target: p => p.getByRole('link', { name: 'My Trips' }),
|
||||||
|
|||||||
@@ -27,3 +27,34 @@ export async function resetDefaults(api: APIRequestContext, keys: string[]): Pro
|
|||||||
if (!res.ok()) throw new Error(`could not reset the default "${key}": ${res.status()} ${await res.text()}`);
|
if (!res.ok()) throw new Error(`could not reset the default "${key}": ${res.status()} ${await res.text()}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Writes instance settings the way the admin page does (PUT /api/auth/app-settings). */
|
||||||
|
export async function putAppSettings(api: APIRequestContext, patch: Record<string, string | boolean>): Promise<void> {
|
||||||
|
const res = await api.put('/api/auth/app-settings', { data: patch });
|
||||||
|
if (!res.ok()) throw new Error(`could not save the app settings: ${res.status()} ${await res.text()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const OIDC_EMPTY = { issuer: '', client_id: '', client_secret: '', display_name: '', discovery_url: '' };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An issuer and a client id, which is all TREK needs to call OIDC configured and
|
||||||
|
* draw the SSO rows. Nothing is fetched from the issuer on save.
|
||||||
|
*/
|
||||||
|
export async function configureOidc(api: APIRequestContext): Promise<void> {
|
||||||
|
const res = await api.put('/api/admin/oidc', {
|
||||||
|
data: {
|
||||||
|
...OIDC_EMPTY,
|
||||||
|
issuer: 'https://auth.example.org/application/o/trek/',
|
||||||
|
client_id: 'trek',
|
||||||
|
client_secret: 'a-long-client-secret',
|
||||||
|
display_name: 'Authentik',
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!res.ok()) throw new Error(`could not configure OIDC: ${res.status()} ${await res.text()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Back to the seed, where no identity provider is set. Password login is on there, so the server allows it. */
|
||||||
|
export async function clearOidc(api: APIRequestContext): Promise<void> {
|
||||||
|
const res = await api.put('/api/admin/oidc', { data: OIDC_EMPTY });
|
||||||
|
if (!res.ok()) throw new Error(`could not clear OIDC: ${res.status()} ${await res.text()}`);
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,410 @@
|
|||||||
|
import type { APIRequestContext, Page, Route } from '@playwright/test';
|
||||||
|
import { toggleAddon } from './external';
|
||||||
|
import { seededTrip } from './fixtures';
|
||||||
|
import { PICTURE_DAY } from './guide';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the AI guides need: an AI provider that answers. The run has none and
|
||||||
|
* must not depend on one, so the browser's side of the conversation is
|
||||||
|
* answered here instead, with `page.context().route` (a route on the page
|
||||||
|
* alone misses what the PWA's service worker fetches, see the Immich mock in
|
||||||
|
* `journey.guide.ts`):
|
||||||
|
*
|
||||||
|
* - `/api/ai/status`: whether the assistant runs and on whose connection,
|
||||||
|
* - `/api/ai/connection` and `/api/ai/models`: a person's own key, taken as good,
|
||||||
|
* - `/api/admin/ai/connection` and `/api/admin/ai/models`: the admin's,
|
||||||
|
* - `/api/trips/:id/assistant/...`: the chat, its decisions and sharing.
|
||||||
|
*
|
||||||
|
* What the provider would write is fixed below, short and in the shape the
|
||||||
|
* server streams it (`uiStreamChunkSchema`). What a decision changes in the
|
||||||
|
* trip is done for real through the REST API, so the plan behind the window
|
||||||
|
* shows the new place the way it would after a real Apply, and the answer
|
||||||
|
* shared to the trip chat is a real chat message. Cleanup takes both away.
|
||||||
|
*
|
||||||
|
* Only the addons are switched for real (the AI tile and the Integrations card
|
||||||
|
* show by them); the admin's AI settings are the server's own.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const PROVIDER = { kind: 'anthropic', host: 'api.anthropic.com' } as const;
|
||||||
|
const MODEL = 'claude-sonnet-4-5';
|
||||||
|
export const AI_KEY = 'sk-ant-api03-hm7Rk2vLq9Tz4Wc8Yp1Nd6Fs3Bx5Gj0Ue-x7Qa';
|
||||||
|
const HINT = '…x7Qa';
|
||||||
|
|
||||||
|
const MODELS = {
|
||||||
|
models: [
|
||||||
|
{ id: MODEL, label: 'Claude Sonnet 4.5', supportsTools: true, recommended: true },
|
||||||
|
{ id: 'claude-haiku-4-5', label: 'Claude Haiku 4.5', supportsTools: true },
|
||||||
|
{ id: 'claude-opus-4-1', label: 'Claude Opus 4.1', supportsTools: true },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
const RETENTION = { mode: 'days', days: 90 } as const;
|
||||||
|
|
||||||
|
/** The assistant on the admin's connection, as everyone on the instance sees it. */
|
||||||
|
function instanceStatus() {
|
||||||
|
return {
|
||||||
|
available: true,
|
||||||
|
policy: 'instance_or_user',
|
||||||
|
canConnectOwn: true,
|
||||||
|
effective: { source: 'instance', kind: PROVIDER.kind, model: MODEL, host: PROVIDER.host, paidBy: 'instance' },
|
||||||
|
own: null,
|
||||||
|
instance: { kind: PROVIDER.kind, model: MODEL, host: PROVIDER.host },
|
||||||
|
quota: { used: 3, limit: 50 },
|
||||||
|
privacyAcked: true,
|
||||||
|
retention: RETENTION,
|
||||||
|
openrouterOAuth: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Everyone brings their own: nothing yet, or the key the guide connected. */
|
||||||
|
function ownStatus(connected: boolean) {
|
||||||
|
const own = { scope: 'user', kind: PROVIDER.kind, model: MODEL, hint: HINT, status: 'ok', host: PROVIDER.host };
|
||||||
|
return {
|
||||||
|
available: connected,
|
||||||
|
policy: 'user',
|
||||||
|
canConnectOwn: true,
|
||||||
|
effective: connected
|
||||||
|
? { source: 'user', kind: PROVIDER.kind, model: MODEL, host: PROVIDER.host, paidBy: 'user' }
|
||||||
|
: null,
|
||||||
|
own: connected ? own : null,
|
||||||
|
instance: null,
|
||||||
|
quota: null,
|
||||||
|
privacyAcked: connected,
|
||||||
|
retention: RETENTION,
|
||||||
|
openrouterOAuth: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A server-sent event stream as the server writes it: one `data:` per chunk, closed by [DONE]. */
|
||||||
|
function sse(chunks: unknown[]): string {
|
||||||
|
return [...chunks.map((c) => `data: ${JSON.stringify(c)}\n\n`), 'data: [DONE]\n\n'].join('');
|
||||||
|
}
|
||||||
|
|
||||||
|
const fulfillStream = (route: Route, chunks: unknown[]) =>
|
||||||
|
route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'text/event-stream',
|
||||||
|
headers: { 'cache-control': 'no-cache' },
|
||||||
|
body: sse(chunks),
|
||||||
|
});
|
||||||
|
|
||||||
|
const pathOf = (route: Route) => new URL(route.request().url()).pathname;
|
||||||
|
|
||||||
|
// ── Settings: a person's own key ─────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** Settings, Integrations: the AI card with nothing connected, and a key that connects. */
|
||||||
|
export async function mockOwnConnection(page: Page): Promise<void> {
|
||||||
|
await toggleAddon(page.request, 'ai_assistant', true);
|
||||||
|
let connected = false;
|
||||||
|
await page.context().route(/\/api\/ai\/(status|connection|models|privacy-ack)(\/.*)?(\?.*)?$/, async (route) => {
|
||||||
|
const path = pathOf(route);
|
||||||
|
const method = route.request().method();
|
||||||
|
if (path.endsWith('/ai/status')) return route.fulfill({ json: ownStatus(connected) });
|
||||||
|
if (path.endsWith('/ai/models')) return route.fulfill({ json: MODELS });
|
||||||
|
if (path.endsWith('/ai/privacy-ack')) return route.fulfill({ json: { success: true } });
|
||||||
|
if (path.endsWith('/ai/connection') && method === 'PUT') {
|
||||||
|
connected = true;
|
||||||
|
return route.fulfill({ json: ownStatus(true).own });
|
||||||
|
}
|
||||||
|
if (path.endsWith('/ai/connection') && method === 'DELETE') {
|
||||||
|
connected = false;
|
||||||
|
return route.fulfill({ json: { success: true } });
|
||||||
|
}
|
||||||
|
return route.fallback();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function resetOwnConnection(api: APIRequestContext): Promise<void> {
|
||||||
|
await toggleAddon(api, 'ai_assistant', false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Admin: the connection for everyone ──────────────────────────────────────
|
||||||
|
|
||||||
|
/** Admin, Addons: the AI dialog with no connection for everyone yet, and a key that connects. */
|
||||||
|
export async function mockInstanceConnection(page: Page): Promise<void> {
|
||||||
|
let connected = false;
|
||||||
|
const view = () => ({
|
||||||
|
connection: connected
|
||||||
|
? {
|
||||||
|
scope: 'instance',
|
||||||
|
kind: PROVIDER.kind,
|
||||||
|
model: MODEL,
|
||||||
|
hint: HINT,
|
||||||
|
status: 'ok',
|
||||||
|
host: PROVIDER.host,
|
||||||
|
baseUrl: null,
|
||||||
|
}
|
||||||
|
: null,
|
||||||
|
prefill: null,
|
||||||
|
});
|
||||||
|
await page.context().route(/\/api\/admin\/ai\/(connection|models)(\/.*)?(\?.*)?$/, async (route) => {
|
||||||
|
const path = pathOf(route);
|
||||||
|
const method = route.request().method();
|
||||||
|
if (path.endsWith('/admin/ai/models')) return route.fulfill({ json: MODELS });
|
||||||
|
if (method === 'PUT') connected = true;
|
||||||
|
if (method === 'DELETE') {
|
||||||
|
connected = false;
|
||||||
|
return route.fulfill({ json: { success: true } });
|
||||||
|
}
|
||||||
|
return route.fulfill({ json: view() });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── Trip: the chat ───────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** What the guide asks, and the place the answer suggests for day 1. */
|
||||||
|
export const QUESTION = 'Where should we have dinner near Senso-ji on day 1?';
|
||||||
|
export const SUGGESTED = {
|
||||||
|
name: 'Asakusa Imahan',
|
||||||
|
address: '3-1-12 Nishiasakusa, Taito City, Tokyo',
|
||||||
|
lat: 35.7127,
|
||||||
|
lng: 139.7905,
|
||||||
|
notes: 'Sukiyaki dinner, around 19:00. Book a table a day ahead.',
|
||||||
|
// Its own front on Kokusai-dori (Wikimedia Commons, CC0); the lookup by position found a car park nearby.
|
||||||
|
image:
|
||||||
|
'https://thumb.wikimedia.org/wikipedia/commons/thumb/8/86/Asakusa_Imahan_Kokusai-dori_main_branch.jpg/960px-Asakusa_Imahan_Kokusai-dori_main_branch.jpg',
|
||||||
|
};
|
||||||
|
|
||||||
|
const THREAD = { id: 901, title: 'Dinner near Senso-ji' };
|
||||||
|
const MESSAGE_ID = 'msg-9002';
|
||||||
|
const QUESTION_ID = 'msg-9001';
|
||||||
|
const CALL_ID = 'call-help-imahan-0001';
|
||||||
|
|
||||||
|
const ANSWER =
|
||||||
|
'**Asakusa Imahan** is a good fit: a sukiyaki restaurant known for its wagyu, a short walk from Senso-ji. ' +
|
||||||
|
'Your day ends at teamLab Planets at 16:00, so a table at 19:00 leaves time to get back to Asakusa.\n\n' +
|
||||||
|
'It fills up in the evening, so book a day ahead. Shall I put it on day 1?';
|
||||||
|
|
||||||
|
const FOLLOW_UPS = [
|
||||||
|
'What else is near Senso-ji?',
|
||||||
|
'Is day 1 too packed now?',
|
||||||
|
'Where can we have breakfast in Asakusa?',
|
||||||
|
];
|
||||||
|
|
||||||
|
/** What the mock made for real, so cleanup can take it away again. */
|
||||||
|
export interface AssistantRun {
|
||||||
|
placeIds: number[];
|
||||||
|
chatMessageIds: number[];
|
||||||
|
}
|
||||||
|
|
||||||
|
const listIn = <T>(body: unknown, key: string): T[] =>
|
||||||
|
Array.isArray(body) ? (body as T[]) : (((body as Record<string, unknown>)?.[key] as T[] | undefined) ?? []);
|
||||||
|
|
||||||
|
/** A day as the change card names it: its date the way the server writes it in English. */
|
||||||
|
function dayLabel(date: string | null | undefined, number: number): string {
|
||||||
|
if (!date) return `Day ${number}`;
|
||||||
|
return new Intl.DateTimeFormat('en', { weekday: 'short', day: 'numeric', month: 'short', timeZone: 'UTC' }).format(
|
||||||
|
new Date(`${date.slice(0, 10)}T00:00:00Z`)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trip's assistant: switched on, answering on the admin's connection, with
|
||||||
|
* one turn that suggests dinner on day 1 and holds it as a change to apply.
|
||||||
|
*/
|
||||||
|
export async function mockTripAssistant(page: Page): Promise<AssistantRun> {
|
||||||
|
const run: AssistantRun = { placeIds: [], chatMessageIds: [] };
|
||||||
|
const api = page.request;
|
||||||
|
const { tripId, dayIds } = seededTrip();
|
||||||
|
await toggleAddon(api, 'ai_assistant', true);
|
||||||
|
|
||||||
|
const days = listIn<{ id: number; date?: string | null }>(
|
||||||
|
await (await api.get(`/api/trips/${tripId}/days`)).json(),
|
||||||
|
'days'
|
||||||
|
);
|
||||||
|
const dayId = dayIds[0];
|
||||||
|
const day = days.find((d) => d.id === dayId);
|
||||||
|
const categories = listIn<{ id: number; name: string }>(
|
||||||
|
await (await api.get('/api/categories')).json(),
|
||||||
|
'categories'
|
||||||
|
);
|
||||||
|
const category = categories.find((c) => /restaurant|food/i.test(c.name)) ?? null;
|
||||||
|
|
||||||
|
const args = {
|
||||||
|
dayId,
|
||||||
|
name: SUGGESTED.name,
|
||||||
|
address: SUGGESTED.address,
|
||||||
|
lat: SUGGESTED.lat,
|
||||||
|
lng: SUGGESTED.lng,
|
||||||
|
...(category ? { category_id: category.id } : {}),
|
||||||
|
place_notes: SUGGESTED.notes,
|
||||||
|
};
|
||||||
|
const rows = [
|
||||||
|
{ op: 'add', labelKey: 'day', before: null, after: dayLabel(day?.date, 1) },
|
||||||
|
{ op: 'add', labelKey: 'address', before: null, after: SUGGESTED.address },
|
||||||
|
...(category ? [{ op: 'add', labelKey: 'category', before: null, after: category.name }] : []),
|
||||||
|
{ op: 'add', labelKey: 'notes', before: null, after: SUGGESTED.notes },
|
||||||
|
];
|
||||||
|
const preview = {
|
||||||
|
toolCallId: CALL_ID,
|
||||||
|
verbKey: 'addPlaceToDay',
|
||||||
|
subject: SUGGESTED.name,
|
||||||
|
rows,
|
||||||
|
dayId,
|
||||||
|
placeIds: [],
|
||||||
|
undoable: true,
|
||||||
|
effect: {
|
||||||
|
kind: 'add',
|
||||||
|
dayId,
|
||||||
|
fromDayId: null,
|
||||||
|
placeId: null,
|
||||||
|
assignmentId: null,
|
||||||
|
place: { name: SUGGESTED.name, lat: SUGGESTED.lat, lng: SUGGESTED.lng, categoryId: category?.id ?? null },
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
const createdAt = PICTURE_DAY.toISOString();
|
||||||
|
const question = {
|
||||||
|
id: QUESTION_ID,
|
||||||
|
role: 'user',
|
||||||
|
status: 'complete',
|
||||||
|
createdAt,
|
||||||
|
parts: [{ type: 'text', text: QUESTION }],
|
||||||
|
};
|
||||||
|
const answer: { id: string; role: string; status: string; createdAt: string; parts: Record<string, unknown>[] } = {
|
||||||
|
id: MESSAGE_ID,
|
||||||
|
role: 'assistant',
|
||||||
|
status: 'awaiting_approval',
|
||||||
|
createdAt,
|
||||||
|
parts: [
|
||||||
|
{ type: 'text', text: ANSWER },
|
||||||
|
{ type: 'tool-call', toolCallId: CALL_ID, toolName: 'create_and_assign_place', args, approval: { id: CALL_ID } },
|
||||||
|
{ type: 'data-trek-change', data: preview },
|
||||||
|
{ type: 'data-trek-follow-ups', data: { questions: FOLLOW_UPS } },
|
||||||
|
],
|
||||||
|
};
|
||||||
|
let asked = false;
|
||||||
|
|
||||||
|
const turn = [
|
||||||
|
{ type: 'start', messageId: MESSAGE_ID },
|
||||||
|
{ type: 'data-trek-thread', data: { threadId: THREAD.id, title: THREAD.title } },
|
||||||
|
{ type: 'start-step' },
|
||||||
|
{ type: 'text-start', id: 'text-1' },
|
||||||
|
{ type: 'text-delta', id: 'text-1', delta: ANSWER },
|
||||||
|
{ type: 'text-end', id: 'text-1' },
|
||||||
|
{ type: 'tool-input-start', toolCallId: CALL_ID, toolName: 'create_and_assign_place' },
|
||||||
|
{ type: 'tool-input-available', toolCallId: CALL_ID, toolName: 'create_and_assign_place', input: args },
|
||||||
|
{ type: 'data-trek-change', data: preview },
|
||||||
|
{ type: 'tool-approval-request', approvalId: CALL_ID, toolCallId: CALL_ID },
|
||||||
|
{ type: 'finish-step' },
|
||||||
|
{ type: 'data-trek-follow-ups', data: { questions: FOLLOW_UPS } },
|
||||||
|
{ type: 'data-trek-quota', data: { used: 4, limit: 50 } },
|
||||||
|
{ type: 'finish', finishReason: 'tool-calls' },
|
||||||
|
];
|
||||||
|
|
||||||
|
/** Apply: the place made and planned for real, then the receipt the server would stream. */
|
||||||
|
async function apply(): Promise<unknown[]> {
|
||||||
|
const placeRes = await api.post(`/api/trips/${tripId}/places`, {
|
||||||
|
data: {
|
||||||
|
name: SUGGESTED.name,
|
||||||
|
address: SUGGESTED.address,
|
||||||
|
lat: SUGGESTED.lat,
|
||||||
|
lng: SUGGESTED.lng,
|
||||||
|
notes: SUGGESTED.notes,
|
||||||
|
image_url: SUGGESTED.image,
|
||||||
|
...(category ? { category_id: category.id } : {}),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!placeRes.ok())
|
||||||
|
throw new Error(`could not create ${SUGGESTED.name}: ${placeRes.status()} ${await placeRes.text()}`);
|
||||||
|
const placeBody = (await placeRes.json()) as { place?: { id: number }; id?: number };
|
||||||
|
const placeId = placeBody.place?.id ?? placeBody.id;
|
||||||
|
if (typeof placeId !== 'number') throw new Error('the new place came back without an id');
|
||||||
|
run.placeIds.push(placeId);
|
||||||
|
const assigned = await api.post(`/api/trips/${tripId}/days/${dayId}/assignments`, { data: { place_id: placeId } });
|
||||||
|
if (!assigned.ok())
|
||||||
|
throw new Error(`could not plan ${SUGGESTED.name}: ${assigned.status()} ${await assigned.text()}`);
|
||||||
|
const applied = {
|
||||||
|
toolCallId: CALL_ID,
|
||||||
|
entity: 'place',
|
||||||
|
ids: [placeId],
|
||||||
|
dayId,
|
||||||
|
undoUntil: new Date(PICTURE_DAY.getTime() + 2 * 3600_000).toISOString(),
|
||||||
|
};
|
||||||
|
answer.status = 'complete';
|
||||||
|
answer.parts = answer.parts.map((p) =>
|
||||||
|
p.type === 'tool-call'
|
||||||
|
? { ...p, result: { place: { id: placeId } }, isError: false, approval: { id: CALL_ID, approved: true } }
|
||||||
|
: p
|
||||||
|
);
|
||||||
|
answer.parts.push({ type: 'data-trek-applied', data: applied });
|
||||||
|
return [
|
||||||
|
{ type: 'start', messageId: MESSAGE_ID },
|
||||||
|
{ type: 'tool-output-available', toolCallId: CALL_ID, output: { place: { id: placeId } } },
|
||||||
|
{ type: 'data-trek-applied', data: applied },
|
||||||
|
{ type: 'finish', finishReason: 'stop' },
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
await page
|
||||||
|
.context()
|
||||||
|
.route(/\/api\/ai\/(status|privacy-ack)(\?.*)?$/, (route) =>
|
||||||
|
pathOf(route).endsWith('/status')
|
||||||
|
? route.fulfill({ json: instanceStatus() })
|
||||||
|
: route.fulfill({ json: { success: true } })
|
||||||
|
);
|
||||||
|
await page.context().route(new RegExp(`/api/trips/${tripId}/assistant/`), async (route) => {
|
||||||
|
const path = pathOf(route).replace(`/api/trips/${tripId}/assistant`, '');
|
||||||
|
const method = route.request().method();
|
||||||
|
if (path === '/threads' && method === 'GET') {
|
||||||
|
return route.fulfill({
|
||||||
|
json: { threads: asked ? [{ id: THREAD.id, title: THREAD.title, lastMessageAt: createdAt }] : [] },
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (path === `/threads/${THREAD.id}` && method === 'GET') {
|
||||||
|
return route.fulfill({
|
||||||
|
json: {
|
||||||
|
thread: { id: THREAD.id, title: THREAD.title, lastMessageAt: createdAt },
|
||||||
|
messages: [question, answer],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
if (path === '/chat' && method === 'POST') {
|
||||||
|
asked = true;
|
||||||
|
return fulfillStream(route, turn);
|
||||||
|
}
|
||||||
|
if (path === `/threads/${THREAD.id}/decisions` && method === 'POST') {
|
||||||
|
const body = route.request().postDataJSON() as { decisions?: { toolCallId: string; approved: boolean }[] };
|
||||||
|
const approved = body.decisions?.find((d) => d.toolCallId === CALL_ID)?.approved;
|
||||||
|
if (!approved) {
|
||||||
|
answer.status = 'complete';
|
||||||
|
return fulfillStream(route, [
|
||||||
|
{ type: 'start', messageId: MESSAGE_ID },
|
||||||
|
{ type: 'tool-output-denied', toolCallId: CALL_ID },
|
||||||
|
{ type: 'finish', finishReason: 'stop' },
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
return fulfillStream(route, await apply());
|
||||||
|
}
|
||||||
|
if (path.startsWith(`/threads/${THREAD.id}/messages/`) && path.endsWith('/share') && method === 'POST') {
|
||||||
|
// A real message in the trip chat, so the chat shows what was shared.
|
||||||
|
const { text } = route.request().postDataJSON() as { text: string };
|
||||||
|
const posted = await api.post(`/api/trips/${tripId}/collab/messages`, { data: { text } });
|
||||||
|
const json = (await posted.json()) as { message?: { id: number } };
|
||||||
|
if (json.message?.id) run.chatMessageIds.push(json.message.id);
|
||||||
|
return route.fulfill({ status: posted.status(), json });
|
||||||
|
}
|
||||||
|
if (path === '/stop') return route.fulfill({ json: { success: true } });
|
||||||
|
if (path.startsWith('/tool-calls/') && path.endsWith('/undo')) {
|
||||||
|
for (const id of run.placeIds.splice(0)) await api.delete(`/api/trips/${tripId}/places/${id}`);
|
||||||
|
return route.fulfill({ json: { undone: true } });
|
||||||
|
}
|
||||||
|
return route.fulfill({ status: 404, json: { error: 'not mocked' } });
|
||||||
|
});
|
||||||
|
return run;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Take away what the chat made, and switch the assistant off again. */
|
||||||
|
export async function resetTripAssistant(api: APIRequestContext, run: AssistantRun | null): Promise<void> {
|
||||||
|
const { tripId } = seededTrip();
|
||||||
|
for (const id of run?.chatMessageIds ?? []) await api.delete(`/api/trips/${tripId}/collab/messages/${id}`);
|
||||||
|
// By name as well: a run that stopped between the create and the receipt left one the list does not know.
|
||||||
|
const places = listIn<{ id: number; name: string }>(
|
||||||
|
await (await api.get(`/api/trips/${tripId}/places`)).json(),
|
||||||
|
'places'
|
||||||
|
);
|
||||||
|
for (const place of places.filter((p) => p.name === SUGGESTED.name)) {
|
||||||
|
await api.delete(`/api/trips/${tripId}/places/${place.id}`);
|
||||||
|
}
|
||||||
|
await toggleAddon(api, 'ai_assistant', false);
|
||||||
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
import type { APIRequestContext } from '@playwright/test';
|
import type { APIRequestContext } from '@playwright/test';
|
||||||
|
import { createHmac } from 'node:crypto';
|
||||||
|
import { day, mailHeaderDate } from '../dates';
|
||||||
import { seededTrip } from './fixtures';
|
import { seededTrip } from './fixtures';
|
||||||
import { asMember, PARTNER } from './fixtures-vacay';
|
import { asMember, PARTNER } from './fixtures-vacay';
|
||||||
|
|
||||||
@@ -156,3 +158,112 @@ export async function removeNotificationFixtures(api: APIRequestContext): Promis
|
|||||||
if (ours) await api.delete(`${INBOX}/${n.id}`);
|
if (ours) await api.delete(`${INBOX}/${n.id}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Booking mails ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** The notice a mail whose booking waits for the reader leaves under the bell. */
|
||||||
|
export const MAIL_PENDING_TITLE = 'Forwarded bookings to review';
|
||||||
|
const MAIL_PENDING_KEY = 'notif.mail_booking_pending.title';
|
||||||
|
/** The media run's own webhook key; a mail service signs with the admin's. */
|
||||||
|
const WEBHOOK_SECRET = 'help-media-webhook-secret-for-the-notifications';
|
||||||
|
/** The forwarded mail, as Pending bookings lists it. */
|
||||||
|
export const MAIL_SUBJECT = 'Your ryokan in Hakone';
|
||||||
|
|
||||||
|
async function putAppSettings(api: APIRequestContext, data: Record<string, string | boolean>): Promise<void> {
|
||||||
|
await ok(await api.put('/api/auth/app-settings', { data }), 'could not save the mail import settings');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mail import on, the way an admin switches it on, with the signed webhook
|
||||||
|
* as its transport so the fixture can deliver a mail itself, and the admin's
|
||||||
|
* own Read with AI off: no model answers in the media run and no extractor is
|
||||||
|
* needed, so the mail waits in Pending bookings and TREK sends the "Forwarded
|
||||||
|
* bookings to review" notice, which is what the guide shows. Then a plain text
|
||||||
|
* confirmation goes to the Japan trip's address, and the fixture waits for
|
||||||
|
* the notice.
|
||||||
|
*/
|
||||||
|
export async function ensureMailPendingNotice(api: APIRequestContext): Promise<void> {
|
||||||
|
await putAppSettings(api, {
|
||||||
|
mail_ingest_enabled: true,
|
||||||
|
mail_ingest_transport: 'webhook',
|
||||||
|
mail_ingest_address_template: 'trips+{token}@example.com',
|
||||||
|
mail_ingest_webhook_secret: WEBHOOK_SECRET,
|
||||||
|
});
|
||||||
|
await ok(
|
||||||
|
await api.patch('/api/mail-ingest/settings', { data: { ai_enabled: false } }),
|
||||||
|
'could not turn Read with AI off'
|
||||||
|
);
|
||||||
|
const { tripId } = seededTrip();
|
||||||
|
let found = (await (await api.get(`/api/trips/${tripId}/mail-ingest/address`)).json()) as {
|
||||||
|
address: { address: string } | null;
|
||||||
|
};
|
||||||
|
if (!found.address) {
|
||||||
|
await ok(
|
||||||
|
await api.post(`/api/trips/${tripId}/mail-ingest/address`, { data: {} }),
|
||||||
|
'could not create the trip address'
|
||||||
|
);
|
||||||
|
found = (await (await api.get(`/api/trips/${tripId}/mail-ingest/address`)).json()) as typeof found;
|
||||||
|
}
|
||||||
|
const to = found.address?.address;
|
||||||
|
if (!to) throw new Error('the trip has no mail address');
|
||||||
|
const raw = Buffer.from(
|
||||||
|
[
|
||||||
|
'From: Hakone Ginyu <stay@ginyu.example>',
|
||||||
|
`To: ${to}`,
|
||||||
|
`Subject: ${MAIL_SUBJECT}`,
|
||||||
|
`Date: ${mailHeaderDate(-28, '09:12', '+0900')}`,
|
||||||
|
'Message-ID: <gny-40218@ginyu.example>',
|
||||||
|
'MIME-Version: 1.0',
|
||||||
|
'Content-Type: text/plain; charset=utf-8',
|
||||||
|
'',
|
||||||
|
'Dear guest,',
|
||||||
|
'',
|
||||||
|
'thank you for choosing Hakone Ginyu. Your room with a private open-air bath is reserved.',
|
||||||
|
'',
|
||||||
|
`Check-in: ${day(-6)}, from 15:00`,
|
||||||
|
`Check-out: ${day(-5)}, until 11:00`,
|
||||||
|
'Guests: 2',
|
||||||
|
'Confirmation number: GNY-40218',
|
||||||
|
'',
|
||||||
|
'Hakone Ginyu, 100-1 Miyanoshita, Hakone, Kanagawa',
|
||||||
|
'',
|
||||||
|
].join('\r\n')
|
||||||
|
);
|
||||||
|
const timestamp = String(Math.floor(Date.now() / 1000));
|
||||||
|
const signature = createHmac('sha256', WEBHOOK_SECRET).update(`${timestamp}\n${to}\n`).update(raw).digest('hex');
|
||||||
|
await ok(
|
||||||
|
await api.post('/api/mail-ingest/inbound', {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'message/rfc822',
|
||||||
|
'X-Trek-Timestamp': timestamp,
|
||||||
|
'X-Trek-Recipient': to,
|
||||||
|
'X-Trek-Signature': `sha256=${signature}`,
|
||||||
|
},
|
||||||
|
data: raw,
|
||||||
|
}),
|
||||||
|
'the webhook refused the mail'
|
||||||
|
);
|
||||||
|
for (let i = 0; i < 90; i++) {
|
||||||
|
if ((await inbox(api)).some((n) => n.title_key === MAIL_PENDING_KEY && !n.is_read)) return;
|
||||||
|
await new Promise((res) => setTimeout(res, 1000));
|
||||||
|
}
|
||||||
|
throw new Error('no "Forwarded bookings to review" notification arrived');
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Back to the seed: the waiting entry, the trip address, the notice and the import itself go. */
|
||||||
|
export async function removeMailPendingNotice(api: APIRequestContext): Promise<void> {
|
||||||
|
const open = await api.get('/api/mail-ingest/inbox?status=open');
|
||||||
|
if (open.ok()) {
|
||||||
|
const { entries = [] } = (await open.json()) as { entries?: { id: number }[] };
|
||||||
|
for (const entry of entries) await api.post(`/api/mail-ingest/candidates/${entry.id}/discard`, { data: {} });
|
||||||
|
}
|
||||||
|
const { tripId } = seededTrip();
|
||||||
|
await api.delete(`/api/trips/${tripId}/mail-ingest/address`);
|
||||||
|
await api.patch('/api/mail-ingest/settings', { data: { ai_enabled: true } });
|
||||||
|
for (const n of await inbox(api)) if (n.title_key === MAIL_PENDING_KEY) await api.delete(`${INBOX}/${n.id}`);
|
||||||
|
await putAppSettings(api, {
|
||||||
|
mail_ingest_enabled: false,
|
||||||
|
mail_ingest_transport: 'off',
|
||||||
|
mail_ingest_webhook_secret: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import type { APIRequestContext } from '@playwright/test';
|
import type { APIRequestContext } from '@playwright/test';
|
||||||
|
import { existsSync, mkdirSync, writeFileSync } from 'node:fs';
|
||||||
|
import path from 'node:path';
|
||||||
import { ensureDawarichConnection, toggleAddon } from './external';
|
import { ensureDawarichConnection, toggleAddon } from './external';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -52,9 +54,9 @@ export async function resetDawarichStays(api: APIRequestContext, tripId: number)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tours is on for every install, and with it on the places column has no
|
* Tours is on for every install. No guide of the places column switches it off
|
||||||
* Import file. The file guide pictures the column of an install that switched
|
* any more; the run still switches it on after the file, in case an older
|
||||||
* it off, and switches it back on afterwards.
|
* attempt left it off.
|
||||||
*/
|
*/
|
||||||
export const setTours = (api: APIRequestContext, enabled: boolean): Promise<void> => toggleAddon(api, 'tours', enabled);
|
export const setTours = (api: APIRequestContext, enabled: boolean): Promise<void> => toggleAddon(api, 'tours', enabled);
|
||||||
|
|
||||||
@@ -73,3 +75,87 @@ export async function undoDawarichStays(api: APIRequestContext, tripId: number):
|
|||||||
}
|
}
|
||||||
await resetDawarichStays(api, tripId);
|
await resetDawarichStays(api, tripId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The pins of the file import: three Kyoto sights the seed does not have, as Google My Maps exports them. */
|
||||||
|
export const KML_PINS: [string, number, number][] = [
|
||||||
|
['Kiyomizu-dera', 34.9949, 135.785],
|
||||||
|
['Yasaka Shrine', 35.0037, 135.7785],
|
||||||
|
['Gion Shirakawa', 35.0059, 135.7748],
|
||||||
|
];
|
||||||
|
|
||||||
|
/** A KML layer of pins only, no line: the file the places column imports as places. Drawn once, on first use. */
|
||||||
|
export function pinsKmlFixture(): string {
|
||||||
|
const dir = path.join(process.cwd(), 'e2e', '.tmp');
|
||||||
|
mkdirSync(dir, { recursive: true });
|
||||||
|
const file = path.join(dir, 'kyoto-sights.kml');
|
||||||
|
if (existsSync(file)) return file;
|
||||||
|
const marks = KML_PINS.map(
|
||||||
|
([name, lat, lng]) =>
|
||||||
|
` <Placemark><name>${name}</name><Point><coordinates>${lng},${lat},0</coordinates></Point></Placemark>`
|
||||||
|
).join('\n');
|
||||||
|
writeFileSync(
|
||||||
|
file,
|
||||||
|
`<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<kml xmlns="http://www.opengis.net/kml/2.2">
|
||||||
|
<Document>
|
||||||
|
<name>Kyoto sights</name>
|
||||||
|
${marks}
|
||||||
|
</Document>
|
||||||
|
</kml>
|
||||||
|
`
|
||||||
|
);
|
||||||
|
return file;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface TripTag {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The tags the tag guide starts with, and the one it adds itself. */
|
||||||
|
export const GUIDE_TAGS = [
|
||||||
|
{ name: 'Must see', color: '#f97316' },
|
||||||
|
{ name: 'Rainy day', color: '#6366f1' },
|
||||||
|
{ name: 'Night view', color: '#ec4899' },
|
||||||
|
];
|
||||||
|
export const NEW_TAG = 'Photo spot';
|
||||||
|
|
||||||
|
async function tripTags(api: APIRequestContext, tripId: number): Promise<TripTag[]> {
|
||||||
|
const res = await api.get(`/api/trips/${tripId}/tags`);
|
||||||
|
if (!res.ok()) throw new Error(`could not list the trip's tags: ${res.status()} ${await res.text()}`);
|
||||||
|
return ((await res.json()) as { tags: TripTag[] }).tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Deletes the guide's tags, which takes them off every place too. */
|
||||||
|
export async function removeGuideTags(api: APIRequestContext, tripId: number): Promise<void> {
|
||||||
|
const names = new Set([...GUIDE_TAGS.map((tag) => tag.name), NEW_TAG].map((name) => name.toLowerCase()));
|
||||||
|
for (const tag of await tripTags(api, tripId)) {
|
||||||
|
if (!names.has(tag.name.toLowerCase())) continue;
|
||||||
|
const res = await api.delete(`/api/trips/${tripId}/tags/${tag.id}`);
|
||||||
|
if (!res.ok() && res.status() !== 404) throw new Error(`could not delete the tag ${tag.name}: ${res.status()}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The trip's tags for the tag guide, fresh: Must see, Rainy day and Night view,
|
||||||
|
* with Must see already on two places, so the filter at the end has more than
|
||||||
|
* the one place the guide tags itself.
|
||||||
|
*/
|
||||||
|
export async function ensureGuideTags(api: APIRequestContext, tripId: number, tagged: string[]): Promise<void> {
|
||||||
|
await removeGuideTags(api, tripId);
|
||||||
|
const ids: Record<string, number> = {};
|
||||||
|
for (const tag of GUIDE_TAGS) {
|
||||||
|
const res = await api.post(`/api/trips/${tripId}/tags`, { data: tag });
|
||||||
|
if (!res.ok()) throw new Error(`could not add the tag ${tag.name}: ${res.status()} ${await res.text()}`);
|
||||||
|
ids[tag.name] = ((await res.json()) as { tag: TripTag }).tag.id;
|
||||||
|
}
|
||||||
|
const list = await api.get(`/api/trips/${tripId}/places`);
|
||||||
|
const body = (await list.json()) as { places?: { id: number; name: string }[] } | { id: number; name: string }[];
|
||||||
|
const places = Array.isArray(body) ? body : (body.places ?? []);
|
||||||
|
for (const name of tagged) {
|
||||||
|
const place = places.find((x) => x.name === name);
|
||||||
|
if (!place) throw new Error(`no seeded place "${name}" to tag`);
|
||||||
|
const res = await api.put(`/api/trips/${tripId}/places/${place.id}`, { data: { tags: [ids['Must see']] } });
|
||||||
|
if (!res.ok()) throw new Error(`could not tag ${name}: ${res.status()} ${await res.text()}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import type { APIRequestContext, Page } from '@playwright/test';
|
import type { APIRequestContext, Page } from '@playwright/test';
|
||||||
|
import { readFileSync } from 'node:fs';
|
||||||
import { at, day } from '../dates';
|
import { at, day } from '../dates';
|
||||||
import { seededTrip } from './fixtures';
|
import { coverFixture, seededTrip } from './fixtures';
|
||||||
import { PICTURE_DAY } from './guide';
|
import { PICTURE_DAY } from './guide';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -43,6 +44,8 @@ export const FUEL_STOP = {
|
|||||||
address: 'Ebina, Kanagawa',
|
address: 'Ebina, Kanagawa',
|
||||||
description: 'Fuel and food on the Tomei Expressway, halfway to Hakone.',
|
description: 'Fuel and food on the Tomei Expressway, halfway to Hakone.',
|
||||||
stop_type: 'fuel',
|
stop_type: 'fuel',
|
||||||
|
// What a fuel stop starts with; a new place would otherwise stand an hour at the pump.
|
||||||
|
duration_minutes: 10,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -82,6 +85,38 @@ export async function removeFuelStop(api: APIRequestContext): Promise<void> {
|
|||||||
if (id !== null) await api.delete(`/api/trips/${tripId}/places/${id}`);
|
if (id !== null) await api.delete(`/api/trips/${tripId}/places/${id}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── A stop on the way with a picture, for the stop photo guide ───────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Owakudani, the volcanic valley above Hakone on day 4, as a Sights stop on the
|
||||||
|
* way with a picture of its own. The cover drawing is a mountain ridge at
|
||||||
|
* sunset, which is what the valley looks like towards Fuji in the evening.
|
||||||
|
*/
|
||||||
|
export const PHOTO_STOP = 'Owakudani';
|
||||||
|
|
||||||
|
/** The picture uploaded as the place's own image, and the valley made a Sights stop. */
|
||||||
|
export async function ensurePhotoStop(api: APIRequestContext): Promise<void> {
|
||||||
|
const { tripId } = seededTrip();
|
||||||
|
const id = await placeIdOf(api, PHOTO_STOP);
|
||||||
|
if (id === null) throw new Error(`the seeded place "${PHOTO_STOP}" is missing`);
|
||||||
|
const image = await api.post(`/api/trips/${tripId}/places/${id}/image`, {
|
||||||
|
multipart: {
|
||||||
|
image: { name: 'owakudani-evening.jpg', mimeType: 'image/jpeg', buffer: readFileSync(await coverFixture()) },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
if (!image.ok()) throw new Error(`could not give "${PHOTO_STOP}" a picture: ${image.status()} ${await image.text()}`);
|
||||||
|
const put = await api.put(`/api/trips/${tripId}/places/${id}`, { data: { stop_type: 'sights' } });
|
||||||
|
if (!put.ok())
|
||||||
|
throw new Error(`could not make "${PHOTO_STOP}" a stop on the way: ${put.status()} ${await put.text()}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The valley a destination without a picture again; the update reclaims the uploaded file. */
|
||||||
|
export async function removePhotoStop(api: APIRequestContext): Promise<void> {
|
||||||
|
const { tripId } = seededTrip();
|
||||||
|
const id = await placeIdOf(api, PHOTO_STOP);
|
||||||
|
if (id !== null) await api.put(`/api/trips/${tripId}/places/${id}`, { data: { stop_type: null, image_url: null } });
|
||||||
|
}
|
||||||
|
|
||||||
// ── A ferry on day 3, for the bookings guide ─────────────────────────────────
|
// ── A ferry on day 3, for the bookings guide ─────────────────────────────────
|
||||||
|
|
||||||
/** The boat across Lake Ashi, between the two Hakone stops of day 3. */
|
/** The boat across Lake Ashi, between the two Hakone stops of day 3. */
|
||||||
|
|||||||
@@ -115,11 +115,29 @@ export async function waitForFlyover(page: Page): Promise<void> {
|
|||||||
await expect(playButton(page).or(pauseButton(page))).toBeVisible({ timeout: 120_000 });
|
await expect(playButton(page).or(pauseButton(page))).toBeVisible({ timeout: 120_000 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Search again while the card says a kind could not be searched. The public
|
||||||
|
* Overpass servers answer 429 and 504 under load, and a picture of that banner
|
||||||
|
* teaches nothing; a calm try or two usually gets through.
|
||||||
|
*/
|
||||||
|
export async function searchAgainWhileUnavailable(page: Page): Promise<void> {
|
||||||
|
const banner = page.getByText(/^Could not be searched right now/).first();
|
||||||
|
// Two tries, 20 s apart: more does not fit the test's time, and a longer outage needs a later run.
|
||||||
|
for (let attempt = 0; attempt < 2; attempt++) {
|
||||||
|
if (!(await banner.isVisible())) return;
|
||||||
|
await page.waitForTimeout(20_000);
|
||||||
|
await alongSearch(page).click();
|
||||||
|
await expect(alongSearch(page)).toHaveText(/Search again/, { timeout: 90_000 });
|
||||||
|
await page.waitForTimeout(1_000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Ask "Along the tour" with what it starts with (the first three kinds, 500 m) and wait for the list. */
|
/** Ask "Along the tour" with what it starts with (the first three kinds, 500 m) and wait for the list. */
|
||||||
export async function searchAlong(page: Page): Promise<void> {
|
export async function searchAlong(page: Page): Promise<void> {
|
||||||
await alongCard(page).scrollIntoViewIfNeeded();
|
await alongCard(page).scrollIntoViewIfNeeded();
|
||||||
await alongSearch(page).click();
|
await alongSearch(page).click();
|
||||||
await expect(alongSearch(page)).toHaveText(/Search again/, { timeout: 90_000 });
|
await expect(alongSearch(page)).toHaveText(/Search again/, { timeout: 90_000 });
|
||||||
|
await searchAgainWhileUnavailable(page);
|
||||||
await expect(alongList(page), 'the search along the tour found nothing (Overpass or the places index)').toBeVisible();
|
await expect(alongList(page), 'the search along the tour found nothing (Overpass or the places index)').toBeVisible();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,8 +35,9 @@ export const PLANNER_TOURS = {
|
|||||||
export const SPARE_DESCRIPTION = 'From the hut across the Cisles meadows and down to the Col Raiser gondola.';
|
export const SPARE_DESCRIPTION = 'From the hut across the Cisles meadows and down to the Col Raiser gondola.';
|
||||||
/** What the description reads after the "someone else saved it" write of the conflict guide. */
|
/** What the description reads after the "someone else saved it" write of the conflict guide. */
|
||||||
export const REMOTE_DESCRIPTION = 'Mira: we take the gondola down, the last stretch is closed this week.';
|
export const REMOTE_DESCRIPTION = 'Mira: we take the gondola down, the last stretch is closed this week.';
|
||||||
/** The query the drawing guide types into the map search; the hut is where its points lie. */
|
/** The query the drawing guide types into the map search; the hut is where its points lie. OSM names it
|
||||||
export const SEARCH_QUERY = 'Rifugio Firenze';
|
* "Ncisles - Regensburger - Firenze", and "Rifugio Firenze" alone finds other huts of the valley first. */
|
||||||
|
export const SEARCH_QUERY = 'Regensburger Firenze';
|
||||||
|
|
||||||
async function body<T>(
|
async function body<T>(
|
||||||
res: { ok(): boolean; status(): number; text(): Promise<string>; json(): Promise<unknown> },
|
res: { ok(): boolean; status(): number; text(): Promise<string>; json(): Promise<unknown> },
|
||||||
@@ -440,24 +441,33 @@ export async function centreOf(locator: Locator): Promise<{ x: number; y: number
|
|||||||
return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
|
return { x: box.x + box.width / 2, y: box.y + box.height / 2 };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* RouteHitBand's path: transparent and 20 px wide. Its 'cursor-copy' class is
|
||||||
|
* not on the rendered path, so the band is found by its stroke instead.
|
||||||
|
*/
|
||||||
|
const ROUTE_BAND = '.leaflet-overlay-pane path[stroke="transparent"][stroke-width="20"]';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A spot on the drawn route, `share` of the way along its widest hit band:
|
* A spot on the drawn route, `share` of the way along its widest hit band:
|
||||||
* the invisible band Leaflet lays along the line to take the click that adds
|
* the invisible band Leaflet lays along the line to take the click that adds
|
||||||
* a shaping point.
|
* a shaping point.
|
||||||
*/
|
*/
|
||||||
export async function spotOnRoute(page: Page, share = 0.3): Promise<{ x: number; y: number }> {
|
export async function spotOnRoute(page: Page, share = 0.3): Promise<{ x: number; y: number }> {
|
||||||
const at = await page.evaluate((k) => {
|
const at = await page.evaluate(
|
||||||
const bands = Array.from(document.querySelectorAll('.leaflet-overlay-pane path.cursor-copy')) as SVGPathElement[];
|
({ k, sel }) => {
|
||||||
const band = bands.sort((a, b) => b.getTotalLength() - a.getTotalLength())[0];
|
const bands = Array.from(document.querySelectorAll(sel)) as SVGPathElement[];
|
||||||
const ctm = band?.getScreenCTM();
|
const band = bands.sort((a, b) => b.getTotalLength() - a.getTotalLength())[0];
|
||||||
if (!band || !ctm) return null;
|
const ctm = band?.getScreenCTM();
|
||||||
const p = band.getPointAtLength(band.getTotalLength() * k);
|
if (!band || !ctm) return null;
|
||||||
const s = new DOMPoint(p.x, p.y).matrixTransform(ctm);
|
const p = band.getPointAtLength(band.getTotalLength() * k);
|
||||||
return { x: s.x, y: s.y };
|
const s = new DOMPoint(p.x, p.y).matrixTransform(ctm);
|
||||||
}, share);
|
return { x: s.x, y: s.y };
|
||||||
|
},
|
||||||
|
{ k: share, sel: ROUTE_BAND }
|
||||||
|
);
|
||||||
if (!at) throw new Error('no drawn route to click on');
|
if (!at) throw new Error('no drawn route to click on');
|
||||||
return at;
|
return at;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The drawn route's click band, for the ring: the widest one. */
|
/** The drawn route's click band, for the ring: the widest one. */
|
||||||
export const routeBand = (page: Page) => page.locator('.leaflet-overlay-pane path.cursor-copy').first();
|
export const routeBand = (page: Page) => page.locator(ROUTE_BAND).first();
|
||||||
|
|||||||
@@ -2,8 +2,9 @@ import { test, expect, type APIResponse, type Locator, type Page } from '@playwr
|
|||||||
import { readFileSync } from 'node:fs'
|
import { readFileSync } from 'node:fs'
|
||||||
import { clearNotices } from '../screenshots/shot'
|
import { clearNotices } from '../screenshots/shot'
|
||||||
import { captureGuide, captureHero, dismissReleaseNotice, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
import { captureGuide, captureHero, dismissReleaseNotice, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
||||||
import { ensureExtraTrips, ensureJourneyFixtures, filesImageFixture, SECOND_JOURNEY, SPARE_TRIP } from './fixtures'
|
import { coverFixture, ensureExtraTrips, ensureJourneyFixtures, filesImageFixture, SECOND_JOURNEY, SPARE_TRIP } from './fixtures'
|
||||||
import { connectJournalDawarich, releaseJournalDawarich, STAY_DAY, writtenEntryIds } from './fixtures-journey'
|
import { connectJournalDawarich, releaseJournalDawarich, STAY_DAY, writtenEntryIds } from './fixtures-journey'
|
||||||
|
import { day } from '../dates'
|
||||||
import { journeyGuides, journeyContext, journalGuides, journalContext, studioGuides, studioContext } from '../../src/help/contexts/journey'
|
import { journeyGuides, journeyContext, journalGuides, journalContext, studioGuides, studioContext } from '../../src/help/contexts/journey'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
|
|
||||||
@@ -355,6 +356,78 @@ async function setJourney(page: Page, data: Record<string, boolean>): Promise<vo
|
|||||||
await answer(await page.request.patch(`/api/journeys/${journeyId}`, { data }), `update the journey with ${JSON.stringify(data)}`)
|
await answer(await page.request.patch(`/api/journeys/${journeyId}`, { data }), `update the journey with ${JSON.stringify(data)}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── A photo library (Immich) ──────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The album guide needs a connected Immich holding an album that is bigger than
|
||||||
|
* the trip. No library runs beside the media run, so the page's own calls to
|
||||||
|
* one are answered here: the addon list names Immich as on, its status says
|
||||||
|
* connected, and the album holds the trip's last week plus a summer and a
|
||||||
|
* spring before it. The thumbnails are the drawn fixtures, taken in turn, since
|
||||||
|
* no photograph may live in this repository. The routes sit on the context,
|
||||||
|
* not the page: once the app's service worker has taken the page over, its
|
||||||
|
* requests no longer pass a page route. The context is the guide's own, so
|
||||||
|
* nothing is left behind for the next guide.
|
||||||
|
*/
|
||||||
|
const ALBUM = { id: 'help-album', albumName: 'Shared with Mia', assetCount: 16 }
|
||||||
|
const ALBUM_RANGE = { from: -7, to: 0 }
|
||||||
|
const ALBUM_SHOTS: { offset: number; city: string }[] = [
|
||||||
|
{ offset: 0, city: 'Kyoto' }, { offset: 0, city: 'Kyoto' },
|
||||||
|
{ offset: -1, city: 'Kyoto' }, { offset: -2, city: 'Hakone' },
|
||||||
|
{ offset: -4, city: 'Tokyo' }, { offset: -4, city: 'Tokyo' },
|
||||||
|
{ offset: -6, city: 'Tokyo' }, { offset: -7, city: 'Tokyo' },
|
||||||
|
{ offset: -96, city: 'Lisbon' }, { offset: -96, city: 'Lisbon' }, { offset: -97, city: 'Sintra' },
|
||||||
|
{ offset: -98, city: 'Lisbon' }, { offset: -150, city: 'Hamburg' }, { offset: -150, city: 'Hamburg' },
|
||||||
|
{ offset: -151, city: 'Hamburg' }, { offset: -152, city: 'Lübeck' },
|
||||||
|
]
|
||||||
|
const albumAssets = () => ALBUM_SHOTS.map((shot, i) => {
|
||||||
|
const taken = `${day(shot.offset)}T${String(9 + (i % 8)).padStart(2, '0')}:20:00`
|
||||||
|
return { id: `help-asset-${i}`, takenAt: `${taken}.000Z`, localTakenAt: taken, city: shot.city, mediaType: 'image' }
|
||||||
|
})
|
||||||
|
|
||||||
|
async function fakePhotoLibrary(page: Page): Promise<void> {
|
||||||
|
const files = [
|
||||||
|
await coverFixture(), await filesImageFixture('arashiyama'), await filesImageFixture('hakone-ryokan'),
|
||||||
|
await filesImageFixture('nishiki-market'), await filesImageFixture('jr-pass-map'),
|
||||||
|
].map(f => readFileSync(f))
|
||||||
|
const assets = albumAssets()
|
||||||
|
await page.context().route(/\/api\/addons(\?.*)?$/, async route => {
|
||||||
|
const res = await route.fetch()
|
||||||
|
const body = (await res.json()) as { addons?: { id: string }[] }
|
||||||
|
const addons = (body.addons ?? []).filter(a => a.id !== 'immich')
|
||||||
|
await route.fulfill({ response: res, json: { ...body, addons: [...addons, { id: 'immich', name: 'Immich', type: 'photo_provider', enabled: true }] } })
|
||||||
|
})
|
||||||
|
await page.context().route(/\/api\/integrations\/memories\/immich\//, async route => {
|
||||||
|
const path = new URL(route.request().url()).pathname
|
||||||
|
if (path.endsWith('/status')) return route.fulfill({ json: { connected: true } })
|
||||||
|
if (path.endsWith('/albums')) return route.fulfill({ json: { albums: [ALBUM, { id: 'help-album-2', albumName: 'Camera roll', assetCount: 1284 }] } })
|
||||||
|
if (path.includes('/albums/')) return route.fulfill({ json: { assets } })
|
||||||
|
if (path.endsWith('/search')) {
|
||||||
|
const trip = assets.filter(a => a.localTakenAt.slice(0, 10) >= day(ALBUM_RANGE.from))
|
||||||
|
return route.fulfill({ json: { assets: trip, hasMore: false } })
|
||||||
|
}
|
||||||
|
const asset = /help-asset-(\d+)/.exec(path)
|
||||||
|
if (asset) return route.fulfill({ contentType: 'image/jpeg', body: files[Number(asset[1]) % files.length] })
|
||||||
|
return route.fulfill({ status: 404, json: { error: 'not found' } })
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
const pickerDialog = (page: Page) => page.getByRole('dialog', { name: 'Immich' })
|
||||||
|
const albumRange = (page: Page) => pickerDialog(page).getByRole('group', { name: 'Taken between' })
|
||||||
|
|
||||||
|
/** Open one of the range's two calendars and pick a day, going back month by month from the picture day's. */
|
||||||
|
async function pickAlbumDay(page: Page, which: 0 | 1, iso: string): Promise<void> {
|
||||||
|
await albumRange(page).getByRole('button').nth(which).click()
|
||||||
|
const today = day(0)
|
||||||
|
const months = (Number(today.slice(0, 4)) - Number(iso.slice(0, 4))) * 12 + Number(today.slice(5, 7)) - Number(iso.slice(5, 7))
|
||||||
|
const back = page.getByRole('button', { name: 'Previous month' })
|
||||||
|
await expect(back).toBeVisible()
|
||||||
|
for (let i = 0; i < months; i++) await back.click()
|
||||||
|
// The calendar floats over the page in a portal: its day cells are the last buttons of that number.
|
||||||
|
await page.getByRole('button', { name: String(Number(iso.slice(8, 10))), exact: true }).last().click()
|
||||||
|
await expect(back).toHaveCount(0)
|
||||||
|
}
|
||||||
|
|
||||||
// ── The map and a recorded day ────────────────────────────────────────────────
|
// ── The map and a recorded day ────────────────────────────────────────────────
|
||||||
|
|
||||||
/** The frosted switches at the top of the map: Plan, Recorded, Entries, Photos and the key. */
|
/** The frosted switches at the top of the map: Plan, Recorded, Entries, Photos and the key. */
|
||||||
@@ -468,6 +541,7 @@ async function markTextTarget(page: Page): Promise<void> {
|
|||||||
const words = page.locator('.st-sheet').getByText(/\p{L}{3,}/u).first()
|
const words = page.locator('.st-sheet').getByText(/\p{L}{3,}/u).first()
|
||||||
await expect(words).toBeVisible()
|
await expect(words).toBeVisible()
|
||||||
await words.evaluate(el => {
|
await words.evaluate(el => {
|
||||||
|
for (const old of Array.from(document.querySelectorAll('[data-help-text]'))) old.removeAttribute('data-help-text')
|
||||||
const r = el.getBoundingClientRect()
|
const r = el.getBoundingClientRect()
|
||||||
const hit = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2)
|
const hit = document.elementFromPoint(r.left + r.width / 2, r.top + r.height / 2)
|
||||||
hit?.setAttribute('data-help-text', '')
|
hit?.setAttribute('data-help-text', '')
|
||||||
@@ -501,8 +575,9 @@ async function openStudio(page: Page): Promise<void> {
|
|||||||
await expect(page.locator('.st-bar')).toBeVisible({ timeout: 30_000 })
|
await expect(page.locator('.st-bar')).toBeVisible({ timeout: 30_000 })
|
||||||
await expect(rail(page)).toBeVisible({ timeout: 30_000 })
|
await expect(rail(page)).toBeVisible({ timeout: 30_000 })
|
||||||
await studioSection(page, 'Pages')
|
await studioSection(page, 'Pages')
|
||||||
// An untouched book is cover, first page, one empty spread, last page and back: five thumbnails.
|
// The book is laid out anew for every guide: the guides before this one leave
|
||||||
if ((await thumbs(page).count()) < 7) await relayoutBook(page)
|
// photos, words, stickers and backgrounds on its pages.
|
||||||
|
await relayoutBook(page)
|
||||||
await settle(page)
|
await settle(page)
|
||||||
await page.waitForTimeout(800)
|
await page.waitForTimeout(800)
|
||||||
}
|
}
|
||||||
@@ -884,6 +959,55 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
// Immich is answered by fakePhotoLibrary: an album of sixteen photos, half of
|
||||||
|
// them from the trip's last week, the rest from two earlier trips.
|
||||||
|
'album-date-range': {
|
||||||
|
guide: guide('album-date-range'),
|
||||||
|
start: async p => {
|
||||||
|
await fakePhotoLibrary(p)
|
||||||
|
await openJournal(p)
|
||||||
|
await p.getByRole('button', { name: 'Gallery' }).first().click()
|
||||||
|
await expect(p.getByRole('button', { name: 'Immich', exact: true })).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => p.getByRole('button', { name: 'Immich', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await p.getByRole('button', { name: 'Immich', exact: true }).click()
|
||||||
|
await expect(pickerDialog(p)).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await pickerDialog(p).getByRole('button', { name: 'Albums', exact: true }).click()
|
||||||
|
await expect(pickerDialog(p).getByRole('button', { name: /^Shared with Mia/ })).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => pickerDialog(p).getByRole('button', { name: /^Shared with Mia/ }),
|
||||||
|
act: async p => {
|
||||||
|
await pickerDialog(p).getByRole('button', { name: /^Shared with Mia/ }).click()
|
||||||
|
await expect(albumRange(p)).toBeVisible()
|
||||||
|
await expect(pickerDialog(p).getByRole('button', { name: /^Select all \(16\)/ })).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: albumRange,
|
||||||
|
act: async p => {
|
||||||
|
await pickAlbumDay(p, 0, day(ALBUM_RANGE.from))
|
||||||
|
await pickAlbumDay(p, 1, day(ALBUM_RANGE.to))
|
||||||
|
const all = pickerDialog(p).getByRole('button', { name: /^Select all \(8\)/ })
|
||||||
|
await expect(all).toBeVisible()
|
||||||
|
await all.click()
|
||||||
|
await expect(pickerDialog(p).getByRole('button', { name: /^Add \(8\)/ })).toBeEnabled()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
'journey-map-layers': {
|
'journey-map-layers': {
|
||||||
guide: guide('journey-map-layers'),
|
guide: guide('journey-map-layers'),
|
||||||
start: openJournal,
|
start: openJournal,
|
||||||
@@ -927,6 +1051,31 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'journey-satellite': {
|
||||||
|
guide: guide('journey-satellite'),
|
||||||
|
start: openJournal,
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => mapPanel(p).getByRole('button', { name: 'Switch to satellite view' }),
|
||||||
|
act: async p => {
|
||||||
|
await mapPanel(p).getByRole('button', { name: 'Switch to satellite view' }).click()
|
||||||
|
await expect(mapPanel(p).getByRole('button', { name: 'Switch to map view' })).toBeVisible()
|
||||||
|
await p.waitForTimeout(1500) // the imagery
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => mapPanel(p).getByRole('button', { name: 'Switch to map view' }),
|
||||||
|
act: async p => {
|
||||||
|
await mapPanel(p).getByRole('button', { name: 'Switch to map view' }).click()
|
||||||
|
await expect(mapPanel(p).getByRole('button', { name: 'Switch to satellite view' })).toBeVisible()
|
||||||
|
await p.waitForTimeout(1000) // the map tiles
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
// ── A recorded day (Dawarich) ───────────────────────────────────────────
|
// ── A recorded day (Dawarich) ───────────────────────────────────────────
|
||||||
'journey-keep-route': {
|
'journey-keep-route': {
|
||||||
guide: guide('journey-keep-route'),
|
guide: guide('journey-keep-route'),
|
||||||
@@ -1517,8 +1666,21 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: p => sidePanel(p).locator('.st-theme-apply'),
|
target: p => sidePanel(p).locator('.st-theme-apply'),
|
||||||
|
act: async p => {
|
||||||
|
await sidePanel(p).getByRole('button', { name: 'Apply to the book' }).click()
|
||||||
|
await settle(p)
|
||||||
|
await p.waitForTimeout(800)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
// Applying the theme is one undo step; the next guides find the book in its own theme again.
|
||||||
|
cleanup: async p => {
|
||||||
|
await p.getByRole('button', { name: 'Undo', exact: true }).first().click()
|
||||||
|
// The book saves a moment after the change; leaving earlier would keep the theme.
|
||||||
|
await p.waitForTimeout(3_000)
|
||||||
|
await expect(p.getByText('Saved', { exact: true }).first()).toBeVisible({ timeout: 15_000 })
|
||||||
|
await expect(p.locator('.st-bar').getByText('Saving', { exact: true })).toHaveCount(0, { timeout: 15_000 })
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
'studio-stickers': {
|
'studio-stickers': {
|
||||||
@@ -1536,6 +1698,14 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => sidePanel(p).locator('.st-shape-grid').first(),
|
target: p => sidePanel(p).locator('.st-shape-grid').first(),
|
||||||
|
// The step says to click one, and the result shows it on the spread, selected.
|
||||||
|
act: async p => {
|
||||||
|
const before = await sheetElements(p).count()
|
||||||
|
await sidePanel(p).locator('.st-sticker-btn').first().click()
|
||||||
|
await expect.poll(async () => sheetElements(p).count()).toBeGreaterThan(before)
|
||||||
|
await settle(p)
|
||||||
|
await p.waitForTimeout(600)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -1545,6 +1715,15 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
start: openStudio,
|
start: openStudio,
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
|
// A new, empty spread: every page Auto layout made already holds words or figures,
|
||||||
|
// and the element would land on top of them. It opens selected, ready to take it.
|
||||||
|
prepare: async p => {
|
||||||
|
await studioSection(p, 'Pages')
|
||||||
|
const before = await thumbs(p).count()
|
||||||
|
await sidePanel(p).getByRole('button', { name: 'Add spread' }).click()
|
||||||
|
await expect(thumbs(p)).toHaveCount(before + 1)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
target: p => railButton(p, 'Travel'),
|
target: p => railButton(p, 'Travel'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await studioSection(p, 'Travel')
|
await studioSection(p, 'Travel')
|
||||||
@@ -1557,6 +1736,13 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => sidePanel(p).locator('.st-travel-card').first(),
|
target: p => sidePanel(p).locator('.st-travel-card').first(),
|
||||||
|
act: async p => {
|
||||||
|
const before = await sheetElements(p).count()
|
||||||
|
await sidePanel(p).locator('.st-travel-card').first().click()
|
||||||
|
await expect.poll(async () => sheetElements(p).count()).toBeGreaterThan(before)
|
||||||
|
await settle(p)
|
||||||
|
await p.waitForTimeout(600)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -1566,10 +1752,21 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
start: openStudio,
|
start: openStudio,
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
|
// The first words on a spread can belong to a figure, so the spreads are
|
||||||
|
// tried in turn until a click selects text and the inspector offers Effects.
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await studioSection(p, 'Pages')
|
await studioSection(p, 'Pages')
|
||||||
await thumbs(p).nth(2).locator('.st-thumb').click()
|
const count = await thumbs(p).count()
|
||||||
await settle(p)
|
for (let i = 2; i < count; i++) {
|
||||||
|
await thumbs(p).nth(i).locator('.st-thumb').click()
|
||||||
|
await settle(p)
|
||||||
|
if (!(await markTextTarget(p).then(() => true, () => false))) continue
|
||||||
|
await textTarget(p).click()
|
||||||
|
const isText = await inspector(p).getByRole('button', { name: 'Effects' }).waitFor({ timeout: 3_000 }).then(() => true, () => false)
|
||||||
|
await p.keyboard.press('Escape')
|
||||||
|
await settle(p)
|
||||||
|
if (isText) break
|
||||||
|
}
|
||||||
await markTextTarget(p)
|
await markTextTarget(p)
|
||||||
},
|
},
|
||||||
target: p => textTarget(p),
|
target: p => textTarget(p),
|
||||||
|
|||||||
@@ -4,8 +4,12 @@ import type { HelpGuide } from '../../src/help/types';
|
|||||||
import { clearNotices } from '../screenshots/shot';
|
import { clearNotices } from '../screenshots/shot';
|
||||||
import {
|
import {
|
||||||
BOOKING_TITLE,
|
BOOKING_TITLE,
|
||||||
|
ensureMailPendingNotice,
|
||||||
ensureNotificationFixtures,
|
ensureNotificationFixtures,
|
||||||
|
MAIL_PENDING_TITLE,
|
||||||
|
MAIL_SUBJECT,
|
||||||
markUnread,
|
markUnread,
|
||||||
|
removeMailPendingNotice,
|
||||||
removeNotificationFixtures,
|
removeNotificationFixtures,
|
||||||
SHARE_TITLE,
|
SHARE_TITLE,
|
||||||
unreadIds,
|
unreadIds,
|
||||||
@@ -37,12 +41,18 @@ const guide = (id: string): HelpGuide => {
|
|||||||
*/
|
*/
|
||||||
const bell = (page: Page): Locator => page.getByTitle('Notifications', { exact: true }).first();
|
const bell = (page: Page): Locator => page.getByTitle('Notifications', { exact: true }).first();
|
||||||
/** The panel the bell opens, found through its footer button. */
|
/** The panel the bell opens, found through its footer button. */
|
||||||
const panel = (page: Page): Locator => page.getByRole('button', { name: 'Show all notifications' }).locator('xpath=..');
|
const panel = (page: Page): Locator =>
|
||||||
|
page
|
||||||
|
.locator('div.shadow-xl')
|
||||||
|
.filter({ has: page.getByRole('button', { name: 'Show all notifications' }) })
|
||||||
|
.first();
|
||||||
/** The column of the /notifications page: header, filter pills and the list. */
|
/** The column of the /notifications page: header, filter pills and the list. */
|
||||||
const pageColumn = (page: Page): Locator => page.locator('.max-w-2xl').first();
|
const pageColumn = (page: Page): Locator => page.locator('.max-w-2xl').first();
|
||||||
/** One notification (InAppNotificationItem's root) by its title, in the panel or the page. */
|
/** One notification (InAppNotificationItem's root) by its title, in the panel or the page. */
|
||||||
const item = (scope: Locator, title: string): Locator =>
|
const ITEM = 'div.group.relative';
|
||||||
scope.locator('div.relative.px-4.py-3').filter({ hasText: title }).first();
|
const item = (scope: Locator, title: string): Locator => scope.locator(ITEM).filter({ hasText: title }).first();
|
||||||
|
/** Pending bookings, the inbox of forwarded mails the Review button opens. */
|
||||||
|
const mailInbox = (page: Page): Locator => page.getByRole('dialog', { name: 'Pending bookings' });
|
||||||
/** The user menu button at the top right: avatar, name and chevron. */
|
/** The user menu button at the top right: avatar, name and chevron. */
|
||||||
const userMenu = (page: Page): Locator =>
|
const userMenu = (page: Page): Locator =>
|
||||||
page
|
page
|
||||||
@@ -89,9 +99,10 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
{ target: bell, act: openBell },
|
{ target: bell, act: openBell },
|
||||||
{
|
{
|
||||||
target: panel,
|
target: panel,
|
||||||
// Over the newest one, so its unread tint is not covered by the pointer.
|
// On the panel's head: a pointed-at row trades its time and dot for its tools,
|
||||||
|
// and the text is about the time and the dot.
|
||||||
hover: async (p) => {
|
hover: async (p) => {
|
||||||
await item(panel(p), SHARE_TITLE).hover();
|
await panel(p).locator('span.bg-accent-subtle').first().hover();
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -171,9 +182,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
target: (p) => item(pageColumn(p), BOOKING_TITLE).getByTitle('Delete', { exact: true }),
|
target: (p) => item(pageColumn(p), BOOKING_TITLE).getByTitle('Delete', { exact: true }),
|
||||||
act: async (p) => {
|
act: async (p) => {
|
||||||
await item(pageColumn(p), BOOKING_TITLE).getByTitle('Delete', { exact: true }).click();
|
await item(pageColumn(p), BOOKING_TITLE).getByTitle('Delete', { exact: true }).click();
|
||||||
await expect(pageColumn(p).locator('div.relative.px-4.py-3').filter({ hasText: BOOKING_TITLE })).toHaveCount(
|
await expect(pageColumn(p).locator(ITEM).filter({ hasText: BOOKING_TITLE })).toHaveCount(0);
|
||||||
0
|
|
||||||
);
|
|
||||||
await settle(p);
|
await settle(p);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -185,6 +194,41 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'booking-mail-notifications': {
|
||||||
|
guide: guide('booking-mail-notifications'),
|
||||||
|
start: async (p) => {
|
||||||
|
await ensureMailPendingNotice(p.request);
|
||||||
|
await openDashboard(p);
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: bell,
|
||||||
|
act: async (p) => {
|
||||||
|
await bell(p).click();
|
||||||
|
await expect(item(panel(p), MAIL_PENDING_TITLE)).toBeVisible();
|
||||||
|
await settle(p);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: (p) => item(panel(p), MAIL_PENDING_TITLE),
|
||||||
|
// On the button the text names, so the row's tools stay out of the way.
|
||||||
|
hover: async (p) => {
|
||||||
|
await item(panel(p), MAIL_PENDING_TITLE).getByRole('button', { name: 'Review' }).hover();
|
||||||
|
},
|
||||||
|
act: async (p) => {
|
||||||
|
await item(panel(p), MAIL_PENDING_TITLE).getByRole('button', { name: 'Review' }).click();
|
||||||
|
await expect(mailInbox(p)).toBeVisible({ timeout: 15_000 });
|
||||||
|
await expect(mailInbox(p).getByText(MAIL_SUBJECT).first()).toBeVisible({ timeout: 15_000 });
|
||||||
|
await settle(p);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{ target: mailInbox },
|
||||||
|
],
|
||||||
|
cleanup: async (p) => {
|
||||||
|
await removeMailPendingNotice(p.request);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
'notification-settings': {
|
'notification-settings': {
|
||||||
guide: guide('notification-settings'),
|
guide: guide('notification-settings'),
|
||||||
start: openNotifications,
|
start: openNotifications,
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
mediaEnv, wandererUrl, wandererToken, allowWanderer, ensureWandererConnection, disconnectWanderer,
|
mediaEnv, wandererUrl, wandererToken, allowWanderer, ensureWandererConnection, disconnectWanderer,
|
||||||
ensureActivePlugin, removeSideloadedPlugin, parkOfflineChanges, clearParkedChanges,
|
ensureActivePlugin, removeSideloadedPlugin, parkOfflineChanges, clearParkedChanges,
|
||||||
} from './fixtures-settings'
|
} from './fixtures-settings'
|
||||||
|
import { mockOwnConnection, resetOwnConnection, AI_KEY } from './fixtures-assistant'
|
||||||
import { settingsContext, settingsTabContexts, settingsGuides } from '../../src/help/contexts/settings'
|
import { settingsContext, settingsTabContexts, settingsGuides } from '../../src/help/contexts/settings'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
|
|
||||||
@@ -18,7 +19,7 @@ import type { HelpGuide } from '../../src/help/types'
|
|||||||
* with, because settings is the last file of the run.
|
* with, because settings is the last file of the run.
|
||||||
*
|
*
|
||||||
* The cards come from `components/Settings/settingsKit.tsx`: a <section> with an
|
* The cards come from `components/Settings/settingsKit.tsx`: a <section> with an
|
||||||
* <h2> in its head band, rows inside (`SettingRow`, a div with `px-3.5`), boxes
|
* <h2> in its head band, rows inside (`SettingRow`, a div with `px-4 py-3`), boxes
|
||||||
* of rows (`SettingRows`, a div with `divide-y`). A stacked row puts its wide
|
* of rows (`SettingRows`, a div with `divide-y`). A stacked row puts its wide
|
||||||
* control in a sibling below the label, so a row is found from its label by its
|
* control in a sibling below the label, so a row is found from its label by its
|
||||||
* own div, never by the label's parent.
|
* own div, never by the label's parent.
|
||||||
@@ -57,7 +58,7 @@ const label = (page: Page, sectionTitle: string | RegExp, text: string) =>
|
|||||||
const field = (page: Page, sectionTitle: string | RegExp, text: string) => label(page, sectionTitle, text).locator('xpath=..')
|
const field = (page: Page, sectionTitle: string | RegExp, text: string) => label(page, sectionTitle, text).locator('xpath=..')
|
||||||
/** A whole row (label, control and whatever the row holds below them) by its label. */
|
/** A whole row (label, control and whatever the row holds below them) by its label. */
|
||||||
const row = (page: Page, sectionTitle: string | RegExp, text: string) =>
|
const row = (page: Page, sectionTitle: string | RegExp, text: string) =>
|
||||||
label(page, sectionTitle, text).locator('xpath=ancestor::div[contains(@class,"px-3.5")][1]')
|
label(page, sectionTitle, text).locator('xpath=ancestor::div[contains(@class,"px-4") and contains(@class,"py-3")][1]')
|
||||||
/** The box of rows a row sits in. */
|
/** The box of rows a row sits in. */
|
||||||
const rows = (page: Page, sectionTitle: string | RegExp, text: string) =>
|
const rows = (page: Page, sectionTitle: string | RegExp, text: string) =>
|
||||||
label(page, sectionTitle, text).locator('xpath=ancestor::div[contains(@class,"divide-y")][1]')
|
label(page, sectionTitle, text).locator('xpath=ancestor::div[contains(@class,"divide-y")][1]')
|
||||||
@@ -102,6 +103,24 @@ function totp(secretBase32: string): string {
|
|||||||
|
|
||||||
const only = (target: (p: Page) => Locator) => ({ target })
|
const only = (target: (p: Page) => Locator) => ({ target })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The booking mail import, switched on the way an admin does it (the same
|
||||||
|
* settings the Bookings guides use), so the Booking mails card shows the
|
||||||
|
* person's own address. Off again in cleanup.
|
||||||
|
*/
|
||||||
|
async function mailImport(page: Page, on: boolean): Promise<void> {
|
||||||
|
const data = on
|
||||||
|
? {
|
||||||
|
mail_ingest_enabled: true,
|
||||||
|
mail_ingest_transport: 'webhook',
|
||||||
|
mail_ingest_address_template: 'trips+{token}@example.com',
|
||||||
|
mail_ingest_webhook_secret: 'help-media-webhook-secret-for-the-pictures',
|
||||||
|
}
|
||||||
|
: { mail_ingest_enabled: false, mail_ingest_transport: 'off', mail_ingest_webhook_secret: '' }
|
||||||
|
const res = await page.request.put('/api/auth/app-settings', { data })
|
||||||
|
if (!res.ok()) throw new Error(`could not switch the mail import: ${res.status()} ${await res.text()}`)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Save, wait for the card to say Connected, then Test connection and wait for
|
* Save, wait for the card to say Connected, then Test connection and wait for
|
||||||
* its answer: the order the connect guides tell the reader.
|
* its answer: the order the connect guides tell the reader.
|
||||||
@@ -121,11 +140,11 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
start: opener('settings-display'),
|
start: opener('settings-display'),
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
target: p => field(p, 'Startup', 'Start page').locator('xpath=..'),
|
target: p => row(p, 'Startup', 'Start page'),
|
||||||
// The start tab only exists once the app opens on the active trip.
|
// The start tab only exists once the app opens on the active trip.
|
||||||
act: async p => { await section(p, 'Startup').getByRole('button', { name: 'Active trip' }).click(); await settle(p) },
|
act: async p => { await section(p, 'Startup').getByRole('button', { name: 'Active trip' }).click(); await settle(p) },
|
||||||
},
|
},
|
||||||
only(p => field(p, 'Startup', 'Start tab').locator('xpath=..')),
|
only(p => row(p, 'Startup', 'Start tab')),
|
||||||
],
|
],
|
||||||
cleanup: async p => { await section(p, 'Startup').getByRole('button', { name: 'Dashboard', exact: true }).click(); await settle(p) },
|
cleanup: async p => { await section(p, 'Startup').getByRole('button', { name: 'Dashboard', exact: true }).click(); await settle(p) },
|
||||||
},
|
},
|
||||||
@@ -207,6 +226,31 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
cleanup: async p => { await p.reload(); await settle(p) },
|
cleanup: async p => { await p.reload(); await settle(p) },
|
||||||
},
|
},
|
||||||
|
'map-hide-pois': {
|
||||||
|
guide: guide('map-hide-pois'),
|
||||||
|
start: opener('settings-map'),
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
// Mapbox GL with its default style, Mapbox Standard; nothing is saved, the reload in cleanup drops it.
|
||||||
|
prepare: async p => {
|
||||||
|
const card = section(p, /^Map$/)
|
||||||
|
await card.getByRole('button', { name: /Mapbox GL/ }).click()
|
||||||
|
await settle(p)
|
||||||
|
// Mapbox GL starts on its default style, Mapbox Standard, the style the step names.
|
||||||
|
await expect(card.getByRole('button', { name: /^Mapbox Standard/ })).toBeVisible()
|
||||||
|
},
|
||||||
|
target: p => section(p, /^Map$/).getByText('Map Style', { exact: true }).first().locator('xpath=..'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => row(p, /^Map$/, 'Hide Points of Interest'),
|
||||||
|
act: async p => {
|
||||||
|
await row(p, /^Map$/, 'Hide Points of Interest').locator('button[aria-pressed]').click()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => { await p.reload(); await settle(p) },
|
||||||
|
},
|
||||||
|
|
||||||
// ── Notifications ────────────────────────────────────────────────────────
|
// ── Notifications ────────────────────────────────────────────────────────
|
||||||
'notification-channels': {
|
'notification-channels': {
|
||||||
@@ -229,6 +273,23 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
// ── Integrations ─────────────────────────────────────────────────────────
|
// ── Integrations ─────────────────────────────────────────────────────────
|
||||||
|
'booking-mail-address': {
|
||||||
|
guide: guide('booking-mail-address'),
|
||||||
|
start: async p => {
|
||||||
|
await mailImport(p, true)
|
||||||
|
await openSettings(p, 'Integrations')
|
||||||
|
await expect(section(p, 'Booking mails').locator('code')).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
// The address with its copy and New address buttons.
|
||||||
|
only(p => section(p, 'Booking mails').locator('code').locator('xpath=..')),
|
||||||
|
only(p => section(p, 'Booking mails').getByText('Forward automatically', { exact: true }).locator('xpath=..')),
|
||||||
|
only(p => rows(p, 'Booking mails', 'Import booking mails')),
|
||||||
|
only(p => section(p, 'Booking mails').getByRole('button', { name: /Pending bookings/ }).locator('xpath=..')),
|
||||||
|
],
|
||||||
|
cleanup: async p => { await mailImport(p, false); await p.reload(); await settle(p) },
|
||||||
|
},
|
||||||
'photo-providers': {
|
'photo-providers': {
|
||||||
guide: guide('photo-providers'),
|
guide: guide('photo-providers'),
|
||||||
start: opener('settings-integrations'),
|
start: opener('settings-integrations'),
|
||||||
@@ -344,6 +405,43 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
cleanup: p => disconnectWanderer(p.request),
|
cleanup: p => disconnectWanderer(p.request),
|
||||||
},
|
},
|
||||||
|
'connect-ai': {
|
||||||
|
guide: guide('connect-ai'),
|
||||||
|
// The key is never tested against a provider: fixtures-assistant.ts answers for the connection.
|
||||||
|
start: async p => {
|
||||||
|
await mockOwnConnection(p)
|
||||||
|
await openSettings(p, TAB_OF['settings-integrations'])
|
||||||
|
await expect(p.getByRole('group', { name: 'What would you like to chat with?' })).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => p.getByRole('group', { name: 'What would you like to chat with?' }),
|
||||||
|
hover: async p => { await p.getByRole('button', { name: /^Paste an API key/ }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await p.getByRole('button', { name: /^Paste an API key/ }).click()
|
||||||
|
await expect(p.getByPlaceholder('Paste your key here')).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await typeInto(p, p.getByPlaceholder('Paste your key here'), AI_KEY)
|
||||||
|
await expect(p.getByText('Detected: Anthropic')).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => p.getByPlaceholder('Paste your key here').locator('xpath=ancestor::div[contains(@class,"gap-3")][1]'),
|
||||||
|
hover: async p => { await p.getByRole('button', { name: 'Connect', exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await p.getByRole('button', { name: 'Connect', exact: true }).click()
|
||||||
|
await expect(p.getByRole('button', { name: 'Open assistant' })).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
only(p => p.getByRole('button', { name: 'Open assistant' }).locator('xpath=ancestor::div[contains(@class,"divide-y")][1]')),
|
||||||
|
],
|
||||||
|
cleanup: p => resetOwnConnection(p.request),
|
||||||
|
},
|
||||||
'api-keys': {
|
'api-keys': {
|
||||||
guide: guide('api-keys'),
|
guide: guide('api-keys'),
|
||||||
start: opener('settings-integrations'),
|
start: opener('settings-integrations'),
|
||||||
@@ -408,7 +506,8 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
guide: guide('plugin-settings'),
|
guide: guide('plugin-settings'),
|
||||||
start: opener('settings-plugins'),
|
start: opener('settings-plugins'),
|
||||||
steps: [
|
steps: [
|
||||||
only(p => section(p, 'Plugin settings')),
|
// The first plugin's own card, which follows the Plugin settings heading card.
|
||||||
|
only(p => section(p, 'Plugin settings').locator('xpath=following::section[1]')),
|
||||||
only(p => section(p, 'Plugin activity')),
|
only(p => section(p, 'Plugin activity')),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
|
import { createHmac } from 'node:crypto'
|
||||||
import { test, expect, type Locator, type Page } from '@playwright/test'
|
import { test, expect, type Locator, type Page } from '@playwright/test'
|
||||||
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
||||||
import { day } from '../dates'
|
import { day, mailHeaderDate } from '../dates'
|
||||||
import { seededTrip, ensureBookingsFixtures, bookingPdfFixture, bookingEmlFixture, BOOKING_EML, HOTEL_TO_BOOK, UNATTACHED_FILE } from './fixtures'
|
import { seededTrip, ensureBookingsFixtures, bookingPdfFixture, bookingEmlFixture, BOOKING_EML, HOTEL_TO_BOOK, UNATTACHED_FILE } from './fixtures'
|
||||||
import { openTrip, modal, portalDialog, importSteps, importTask, dismissImportTask, deleteTripFiles } from './trip-shared'
|
import { openTrip, modal, portalDialog, importDialog, importSteps, importTask, dismissImportTask, deleteTripFiles } from './trip-shared'
|
||||||
import { requireExtractor, allowEmlUploads } from './external'
|
import { requireExtractor, allowEmlUploads, toggleAddon } from './external'
|
||||||
import { tripBookingsContext, tripBookingsGuides } from '../../src/help/contexts/tripBookings'
|
import { tripBookingsContext, tripBookingsGuides } from '../../src/help/contexts/tripBookings'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
|
|
||||||
@@ -220,6 +221,116 @@ const closeModal = async (page: Page): Promise<void> => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── Booking mails ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
|
/** The trip's own address, under the drop box of the import dialog. */
|
||||||
|
const forwardCard = (page: Page) => importDialog(page).getByText('Or forward by mail', { exact: true }).locator('xpath=..')
|
||||||
|
/** The user menu button at the top right: avatar, name and chevron. */
|
||||||
|
const userMenu = (page: Page) => page.getByRole('button').filter({ has: page.locator('span.max-w-40') }).first()
|
||||||
|
/** Pending bookings in the user menu, with the count of waiting mails after its label. */
|
||||||
|
const inboxEntryPoint = (page: Page) => page.getByRole('button', { name: /^Pending bookings/ })
|
||||||
|
const mailInbox = (page: Page) => page.getByRole('dialog', { name: 'Pending bookings' })
|
||||||
|
const inboxEntry = (page: Page) => mailInbox(page).getByRole('listitem').filter({ hasText: MAIL_SUBJECT }).first()
|
||||||
|
|
||||||
|
const MAIL_SUBJECT = 'Your table at Kikunoi'
|
||||||
|
/** What the guide saves: the title corrected in the form, the code TREK read from the mail. */
|
||||||
|
const MAIL_BOOKING = { title: 'Dinner at Kikunoi', code: 'KKN-77310' }
|
||||||
|
/** The media run's own webhook key; a mail service signs with the admin's. */
|
||||||
|
const WEBHOOK_SECRET = 'help-media-webhook-secret-for-the-pictures'
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The mail import, switched on the way an admin does it, with the signed
|
||||||
|
* webhook as its transport so the guide can deliver a mail itself. The import
|
||||||
|
* dialog only opens where the server can read confirmations, so AI Parsing is
|
||||||
|
* on as well, while the person's own Read with AI is off: no model answers in
|
||||||
|
* the media run, and without it the mail waits in the inbox, which is the
|
||||||
|
* part of the flow the guide shows. Off again in cleanup, entries and the
|
||||||
|
* trip address with it.
|
||||||
|
*/
|
||||||
|
async function mailImportOn(page: Page, on: boolean): Promise<void> {
|
||||||
|
const api = page.request
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
if (on) {
|
||||||
|
await putAppSettings(page, {
|
||||||
|
mail_ingest_enabled: true,
|
||||||
|
mail_ingest_transport: 'webhook',
|
||||||
|
mail_ingest_address_template: 'trips+{token}@example.com',
|
||||||
|
mail_ingest_webhook_secret: WEBHOOK_SECRET,
|
||||||
|
})
|
||||||
|
await toggleAddon(api, 'llm_parsing', true)
|
||||||
|
await api.patch('/api/mail-ingest/settings', { data: { ai_enabled: false } })
|
||||||
|
return
|
||||||
|
}
|
||||||
|
const inbox = await api.get('/api/mail-ingest/inbox?status=open')
|
||||||
|
if (inbox.ok()) {
|
||||||
|
const { entries = [] } = (await inbox.json()) as { entries?: { id: number }[] }
|
||||||
|
for (const entry of entries) await api.post(`/api/mail-ingest/candidates/${entry.id}/discard`, { data: {} })
|
||||||
|
}
|
||||||
|
await api.delete(`/api/trips/${tripId}/mail-ingest/address`)
|
||||||
|
await api.patch('/api/mail-ingest/settings', { data: { ai_enabled: true } })
|
||||||
|
await toggleAddon(api, 'llm_parsing', false)
|
||||||
|
await putAppSettings(page, { mail_ingest_enabled: false, mail_ingest_transport: 'off', mail_ingest_webhook_secret: '' })
|
||||||
|
}
|
||||||
|
|
||||||
|
async function putAppSettings(page: Page, data: Record<string, string | boolean>): Promise<void> {
|
||||||
|
const res = await page.request.put('/api/auth/app-settings', { data })
|
||||||
|
if (!res.ok()) throw new Error(`could not save the mail import settings: ${res.status()} ${await res.text()}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forward the restaurant's confirmation to the trip's address, the way a mail
|
||||||
|
* service hands a mail to TREK: raw, signed with the webhook key over the
|
||||||
|
* time, the recipient and every byte. Then wait until it was read and waits
|
||||||
|
* in the inbox. A plain text mail on purpose: nothing machine-readable in it,
|
||||||
|
* so the booking form starts from what the mail says in words.
|
||||||
|
*/
|
||||||
|
async function forwardMail(page: Page): Promise<void> {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
const found = await page.request.get(`/api/trips/${tripId}/mail-ingest/address`)
|
||||||
|
const { address } = (await found.json()) as { address: { address: string } | null }
|
||||||
|
if (!address) throw new Error('the trip has no mail address after Create an address for this trip')
|
||||||
|
const raw = Buffer.from(
|
||||||
|
[
|
||||||
|
'From: Kikunoi Honten <reservations@kikunoi.example>',
|
||||||
|
`To: ${address.address}`,
|
||||||
|
`Subject: ${MAIL_SUBJECT}`,
|
||||||
|
`Date: ${mailHeaderDate(-30, '10:24', '+0900')}`,
|
||||||
|
'Message-ID: <kkn-77310@kikunoi.example>',
|
||||||
|
'MIME-Version: 1.0',
|
||||||
|
'Content-Type: text/plain; charset=utf-8',
|
||||||
|
'',
|
||||||
|
'Dear Ms Lindberg,',
|
||||||
|
'',
|
||||||
|
'thank you for your reservation at Kikunoi Honten. We look forward to welcoming you.',
|
||||||
|
'',
|
||||||
|
`Date: ${day(-3)}, 19:00`,
|
||||||
|
'Guests: 2',
|
||||||
|
`Reservation number: ${MAIL_BOOKING.code}`,
|
||||||
|
'',
|
||||||
|
'Kikunoi Honten, 459 Shimokawara-cho, Higashiyama-ku, Kyoto',
|
||||||
|
'',
|
||||||
|
].join('\r\n'),
|
||||||
|
)
|
||||||
|
const timestamp = String(Math.floor(Date.now() / 1000))
|
||||||
|
const signature = createHmac('sha256', WEBHOOK_SECRET).update(`${timestamp}\n${address.address}\n`).update(raw).digest('hex')
|
||||||
|
const res = await page.request.post('/api/mail-ingest/inbound', {
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'message/rfc822',
|
||||||
|
'X-Trek-Timestamp': timestamp,
|
||||||
|
'X-Trek-Recipient': address.address,
|
||||||
|
'X-Trek-Signature': `sha256=${signature}`,
|
||||||
|
},
|
||||||
|
data: raw,
|
||||||
|
})
|
||||||
|
if (!res.ok()) throw new Error(`the webhook refused the mail: ${res.status()} ${await res.text()}`)
|
||||||
|
await expect
|
||||||
|
.poll(async () => {
|
||||||
|
const count = await page.request.get('/api/mail-ingest/inbox/count')
|
||||||
|
return count.ok() ? ((await count.json()) as { pending?: number }).pending ?? 0 : 0
|
||||||
|
}, { timeout: 90_000, intervals: [1000] })
|
||||||
|
.toBeGreaterThan(0)
|
||||||
|
}
|
||||||
|
|
||||||
const only = (target: (p: Page) => Locator) => ({ target })
|
const only = (target: (p: Page) => Locator) => ({ target })
|
||||||
|
|
||||||
const SCRIPTS: Record<string, GuideScript> = {
|
const SCRIPTS: Record<string, GuideScript> = {
|
||||||
@@ -290,7 +401,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
target: p => viewItem(p, 'Type'),
|
target: p => viewItem(p, 'Type'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await viewItem(p, 'Type').click()
|
await viewItem(p, 'Type').click()
|
||||||
await expect(sectionHead(p, 'Tour')).toBeVisible()
|
await expect(sectionHead(p, 'Guided tour')).toBeVisible()
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -309,10 +420,12 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await closeViewOptions(p)
|
await closeViewOptions(p)
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: p => sectionHead(p, 'Tour'),
|
// The label: the heading itself spans the whole width, and a frame
|
||||||
|
// centred on it would cut the label off at the left.
|
||||||
|
target: p => sectionHead(p, 'Guided tour').getByText('Guided tour', { exact: true }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await sectionHead(p, 'Tour').click()
|
await sectionHead(p, 'Guided tour').click()
|
||||||
await expect(sectionHead(p, 'Tour')).toHaveAttribute('aria-expanded', 'false')
|
await expect(sectionHead(p, 'Guided tour')).toHaveAttribute('aria-expanded', 'false')
|
||||||
await expect(bookingCard(p, 'Kyoto Cycling Tour')).toHaveCount(0)
|
await expect(bookingCard(p, 'Kyoto Cycling Tour')).toHaveCount(0)
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
@@ -489,9 +602,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => detail(p, VIEWED.title).getByRole('button', { name: 'On map', exact: true }),
|
target: p => detail(p, VIEWED.title).getByRole('button', { name: 'Map', exact: true }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await detail(p, VIEWED.title).getByRole('button', { name: 'On map', exact: true }).click()
|
await detail(p, VIEWED.title).getByRole('button', { name: 'Map', exact: true }).click()
|
||||||
await expect(detail(p, VIEWED.title)).toHaveCount(0)
|
await expect(detail(p, VIEWED.title)).toHaveCount(0)
|
||||||
// The tab goes and the plan opens on the tour's day with its place selected.
|
// The tab goes and the plan opens on the tour's day with its place selected.
|
||||||
await expect(p.getByRole('heading', { name: 'Bookings', exact: true, level: 2 })).toHaveCount(0)
|
await expect(p.getByRole('heading', { name: 'Bookings', exact: true, level: 2 })).toHaveCount(0)
|
||||||
@@ -590,7 +703,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await expect(modal(p).getByRole('button', { name: UNATTACHED_FILE, exact: true })).toBeVisible()
|
await expect(modal(p).getByRole('button', { name: UNATTACHED_FILE, exact: true })).toBeVisible()
|
||||||
await beat(p, 300)
|
await beat(p, 300)
|
||||||
},
|
},
|
||||||
target: p => modal(p).getByRole('button', { name: 'Link existing file' }).locator('xpath=..'),
|
// The list it opens above the button: what the reader picks from. The
|
||||||
|
// button's own box leaves the list out, since it floats over the form.
|
||||||
|
target: p => modal(p).getByRole('button', { name: UNATTACHED_FILE, exact: true }).locator('xpath=..'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: UNATTACHED_FILE, exact: true }).click()
|
await modal(p).getByRole('button', { name: UNATTACHED_FILE, exact: true }).click()
|
||||||
await expect(modal(p).getByRole('button', { name: UNATTACHED_FILE, exact: true })).toHaveCount(0)
|
await expect(modal(p).getByRole('button', { name: UNATTACHED_FILE, exact: true })).toHaveCount(0)
|
||||||
@@ -711,9 +826,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => filterMenu(p).getByRole('button', { name: /^Tour\b/ }),
|
target: p => filterMenu(p).getByRole('button', { name: /^Guided tour\b/ }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await filterMenu(p).getByRole('button', { name: /^Tour\b/ }).click()
|
await filterMenu(p).getByRole('button', { name: /^Guided tour\b/ }).click()
|
||||||
await expect(bookingCard(p, 'Haneda Airport P4')).toHaveCount(0)
|
await expect(bookingCard(p, 'Haneda Airport P4')).toHaveCount(0)
|
||||||
await expect(bookingCard(p, 'Kyoto Cycling Tour')).toBeVisible()
|
await expect(bookingCard(p, 'Kyoto Cycling Tour')).toBeVisible()
|
||||||
await settle(p)
|
await settle(p)
|
||||||
@@ -819,6 +934,89 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await deleteTripFiles(p, BOOKING_EML)
|
await deleteTripFiles(p, BOOKING_EML)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'forward-booking-mail': {
|
||||||
|
guide: guide('forward-booking-mail'),
|
||||||
|
start: async p => {
|
||||||
|
await mailImportOn(p, true)
|
||||||
|
await openBookings(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => p.getByRole('button', { name: 'Import booking confirmations', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await p.getByRole('button', { name: 'Import booking confirmations', exact: true }).click()
|
||||||
|
await expect(importDialog(p)).toBeVisible()
|
||||||
|
await expect(forwardCard(p)).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: forwardCard,
|
||||||
|
act: async p => {
|
||||||
|
await forwardCard(p).getByRole('button', { name: 'Create an address for this trip' }).click()
|
||||||
|
await expect(forwardCard(p).locator('code')).toContainText('@', { timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// The address and its copy button; copying itself needs a clipboard the headless browser lacks.
|
||||||
|
target: p => forwardCard(p).locator('code').locator('xpath=..'),
|
||||||
|
act: async p => {
|
||||||
|
await importDialog(p).getByRole('button', { name: 'Cancel', exact: true }).click()
|
||||||
|
await expect(importDialog(p)).toHaveCount(0)
|
||||||
|
await forwardMail(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
// A fresh page reads the waiting count, as anyone arriving later would.
|
||||||
|
await openBookings(p)
|
||||||
|
await userMenu(p).click()
|
||||||
|
await expect(inboxEntryPoint(p)).toBeVisible()
|
||||||
|
await expect(inboxEntryPoint(p)).toContainText('1')
|
||||||
|
await beat(p, 300)
|
||||||
|
},
|
||||||
|
target: inboxEntryPoint,
|
||||||
|
act: async p => {
|
||||||
|
await inboxEntryPoint(p).click()
|
||||||
|
await expect(inboxEntry(p)).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: inboxEntry,
|
||||||
|
act: async p => {
|
||||||
|
await inboxEntry(p).getByRole('button', { name: 'Fill in yourself' }).click()
|
||||||
|
await expect(mailInbox(p)).toHaveCount(0)
|
||||||
|
await expect(modal(p).getByRole('heading', { name: 'New Reservation' })).toBeVisible({ timeout: 20_000 })
|
||||||
|
await expect(codeBox(p)).toHaveValue(MAIL_BOOKING.code)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await typeInto(p, titleBox(p), MAIL_BOOKING.title)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => modal(p).getByRole('dialog'),
|
||||||
|
act: async p => {
|
||||||
|
await saveButton(p, 'Add').click()
|
||||||
|
await expect(modal(p)).toHaveCount(0, { timeout: 20_000 })
|
||||||
|
// Fill in yourself opens the trip without its tab; the result shows the booking where it belongs.
|
||||||
|
await openBookings(p)
|
||||||
|
await expect(bookingCard(p, MAIL_BOOKING.title)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await bookingCard(p, MAIL_BOOKING.title).scrollIntoViewIfNeeded()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
await clearPanelState(p)
|
||||||
|
await deleteBookings(p, MAIL_BOOKING.title)
|
||||||
|
await mailImportOn(p, false)
|
||||||
|
},
|
||||||
|
},
|
||||||
'edit-booking': {
|
'edit-booking': {
|
||||||
guide: guide('edit-booking'),
|
guide: guide('edit-booking'),
|
||||||
start: openBookings,
|
start: openBookings,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import { readFileSync } from 'node:fs'
|
||||||
import { test, expect, type Locator, type Page } from '@playwright/test'
|
import { test, expect, type Locator, type Page } from '@playwright/test'
|
||||||
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
||||||
import { day, long, short } from '../dates'
|
import { day, long, short } from '../dates'
|
||||||
import { seededTrip, ensureCostsFixtures } from './fixtures'
|
import { seededTrip, ensureCostsFixtures, filesPdfFixture } from './fixtures'
|
||||||
import { openTrip, modal } from './trip-shared'
|
import { openTrip, modal } from './trip-shared'
|
||||||
import { RAMEN, RECEIPT_FILE, receiptFixture, removeReceiptFiles } from './fixtures-trip-costs'
|
import { RAMEN, RECEIPT_FILE, receiptFixture, removeReceiptFiles } from './fixtures-trip-costs'
|
||||||
import { tripCostsContext, tripCostsGuides } from '../../src/help/contexts/tripCosts'
|
import { tripCostsContext, tripCostsGuides } from '../../src/help/contexts/tripCosts'
|
||||||
@@ -30,7 +31,8 @@ const SEEDED_EUR = 'Flights FRA → HND'
|
|||||||
const BOOKING = 'LH716 FRA → HND'
|
const BOOKING = 'LH716 FRA → HND'
|
||||||
/** A seeded expense costs-table gives its days to. */
|
/** A seeded expense costs-table gives its days to. */
|
||||||
const JR_PASS = 'JR Pass (14 days)'
|
const JR_PASS = 'JR Pass (14 days)'
|
||||||
const DINNER = 'Kaiseki dinner in Gion'
|
/** The dinner add-expense records; not the seed's Kaiseki dinner, which cleanup would delete with it. */
|
||||||
|
const DINNER = 'Yakitori dinner in Pontocho'
|
||||||
const UPGRADE = 'Shinkansen seat upgrade'
|
const UPGRADE = 'Shinkansen seat upgrade'
|
||||||
const LUNCH = { name: 'Nishiki Market lunch', category: 'food', total_price: 4800, currency: 'JPY', expense_date: day(-4) }
|
const LUNCH = { name: 'Nishiki Market lunch', category: 'food', total_price: 4800, currency: 'JPY', expense_date: day(-4) }
|
||||||
/** The row costs-table adds to Food & drink; the table names a new row this until it is renamed. */
|
/** The row costs-table adds to Food & drink; the table names a new row this until it is renamed. */
|
||||||
@@ -38,6 +40,12 @@ const MATCHA = 'Matcha in Uji'
|
|||||||
const NEW_ROW = 'New Entry'
|
const NEW_ROW = 'New Entry'
|
||||||
/** Where the tab keeps the list/table choice (CostsPanel's COSTS_VIEW_KEY). */
|
/** Where the tab keeps the list/table choice (CostsPanel's COSTS_VIEW_KEY). */
|
||||||
const VIEW_KEY = 'trek:costs-view'
|
const VIEW_KEY = 'trek:costs-view'
|
||||||
|
/** A stay split-by-shares divides by nights: three, three and two, so the shares come out even. */
|
||||||
|
const MACHIYA = { name: 'Machiya stay in Kyoto', category: 'accommodation', total_price: 39000, currency: 'JPY', expense_date: day(-5) }
|
||||||
|
/** The trip file link-receipt-file puts on the JR Pass; the voucher is the pass's invoice. */
|
||||||
|
const VOUCHER = 'JR-Pass-voucher.pdf'
|
||||||
|
/** Where useCostsCurrency keeps one trip's picked currency. */
|
||||||
|
const SHOWN_IN_KEY = (tripId: number) => `trek:costs-currency:${tripId}`
|
||||||
|
|
||||||
/** The Costs tab, waited out: its panel is lazy and its figures come from the server. */
|
/** The Costs tab, waited out: its panel is lazy and its figures come from the server. */
|
||||||
const openCosts = async (p: Page): Promise<void> => {
|
const openCosts = async (p: Page): Promise<void> => {
|
||||||
@@ -185,6 +193,36 @@ async function pickCurrency(page: Page, code: string): Promise<void> {
|
|||||||
await settle(page)
|
await settle(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ── The bar's currency picker and the sidebar's switches ─────────────────────
|
||||||
|
const showIn = (page: Page) => page.getByRole('button', { name: 'Show amounts in', exact: true })
|
||||||
|
const showInList = (page: Page) => page.getByRole('group', { name: 'Show amounts in', exact: true })
|
||||||
|
const modeSwitch = (page: Page) => page.getByRole('button', { name: 'Split costs between travelers', exact: true })
|
||||||
|
|
||||||
|
async function setCostsMode(page: Page, mode: 'split' | 'totals'): Promise<void> {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
const res = await page.request.put(`/api/trips/${tripId}`, { data: { costs_mode: mode } })
|
||||||
|
if (!res.ok()) throw new Error(`could not set costs_mode ${mode}: ${res.status()} ${await res.text()}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The voucher as a trip file, uploaded once; the seed has no document of its own. */
|
||||||
|
async function ensureVoucher(page: Page): Promise<void> {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
const res = await page.request.get(`/api/trips/${tripId}/files`)
|
||||||
|
const { files = [] } = (await res.json()) as { files?: { original_name: string }[] }
|
||||||
|
if (files.some(f => f.original_name === VOUCHER)) return
|
||||||
|
const uploaded = await page.request.post(`/api/trips/${tripId}/files`, {
|
||||||
|
multipart: { file: { name: VOUCHER, mimeType: 'application/pdf', buffer: readFileSync(filesPdfFixture('JR-Pass-voucher')) } },
|
||||||
|
})
|
||||||
|
if (!uploaded.ok()) throw new Error(`could not upload ${VOUCHER}: ${uploaded.status()} ${await uploaded.text()}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Open the expense editor on a ledger row with its pencil. */
|
||||||
|
async function editRow(page: Page, name: string): Promise<void> {
|
||||||
|
await rowActions(page, name).getByRole('button', { name: 'Edit' }).click()
|
||||||
|
await expect(nameBox(page)).toHaveValue(name)
|
||||||
|
await settle(page)
|
||||||
|
}
|
||||||
|
|
||||||
const SCRIPTS: Record<string, GuideScript> = {
|
const SCRIPTS: Record<string, GuideScript> = {
|
||||||
'add-expense': {
|
'add-expense': {
|
||||||
guide: guide('add-expense'),
|
guide: guide('add-expense'),
|
||||||
@@ -422,6 +460,90 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
cleanup: p => deleteExpenses(p, UPGRADE),
|
cleanup: p => deleteExpenses(p, UPGRADE),
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'split-by-shares': {
|
||||||
|
guide: guide('split-by-shares'),
|
||||||
|
start: async p => {
|
||||||
|
await createExpense(p, MACHIYA)
|
||||||
|
await openCosts(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
prepare: p => editRow(p, MACHIYA.name),
|
||||||
|
target: p => block(p, 'Split').getByRole('button', { name: 'Custom', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await block(p, 'Split').getByRole('button', { name: 'Custom', exact: true }).click()
|
||||||
|
await expect(block(p, 'Split').getByRole('group', { name: 'Enter shares as' })).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => block(p, 'Split').getByRole('group', { name: 'Enter shares as' }),
|
||||||
|
act: async p => {
|
||||||
|
await block(p, 'Split').getByRole('group', { name: 'Enter shares as' }).getByRole('button', { name: 'Shares', exact: true }).click()
|
||||||
|
await expect(block(p, 'Split').getByRole('textbox', { name: /^Shares for / })).toHaveCount(3)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Three nights, three nights, and jonas came a day later.
|
||||||
|
prepare: async p => {
|
||||||
|
const fields = block(p, 'Split').getByRole('textbox', { name: /^Shares for / })
|
||||||
|
await fields.nth(0).fill('3')
|
||||||
|
await fields.nth(1).fill('3')
|
||||||
|
await fields.nth(2).fill('2')
|
||||||
|
await expect(block(p, 'Split').getByText('Split matches total')).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => block(p, 'Split').getByRole('textbox', { name: /^Shares for / }).first().locator('xpath=ancestor::div[contains(@class,"divide-y")][1]'),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => modal(p).getByRole('button', { name: 'Save', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: 'Save', exact: true }).click()
|
||||||
|
await expect(modal(p)).toHaveCount(0)
|
||||||
|
await dropFocus(p)
|
||||||
|
await expect(expRow(p, MACHIYA.name)).toBeVisible()
|
||||||
|
await expRow(p, MACHIYA.name).evaluate(el => el.scrollIntoView({ block: 'center' }))
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
await deleteExpenses(p, MACHIYA.name)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
|
'costs-show-in': {
|
||||||
|
guide: guide('costs-show-in'),
|
||||||
|
start: openCosts,
|
||||||
|
steps: [
|
||||||
|
only(showIn),
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await showIn(p).click()
|
||||||
|
await expect(showInList(p)).toBeVisible()
|
||||||
|
await beat(p, 300)
|
||||||
|
},
|
||||||
|
target: showInList,
|
||||||
|
act: async p => {
|
||||||
|
await showInList(p).locator('input').first().fill('EUR')
|
||||||
|
await showInList(p).getByRole('button', { name: /^EUR/ }).click()
|
||||||
|
await expect(showIn(p)).toHaveText(/EUR/)
|
||||||
|
await expect(card(p, 'Total trip spend')).toHaveText(/€/, { timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
only(p => p.locator('.costs-summary')),
|
||||||
|
// Ringed in its new state; the reader picks the first entry to go back.
|
||||||
|
only(showIn),
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
await p.evaluate(key => { try { localStorage.removeItem(key) } catch { /* no storage: nothing to put back */ } }, SHOWN_IN_KEY(tripId))
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
'expense-receipts': {
|
'expense-receipts': {
|
||||||
guide: guide('expense-receipts'),
|
guide: guide('expense-receipts'),
|
||||||
start: async p => {
|
start: async p => {
|
||||||
@@ -488,6 +610,62 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'link-receipt-file': {
|
||||||
|
guide: guide('link-receipt-file'),
|
||||||
|
start: async p => {
|
||||||
|
await ensureVoucher(p)
|
||||||
|
await openCosts(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => rowActions(p, JR_PASS).getByRole('button', { name: 'Edit' }),
|
||||||
|
act: async p => {
|
||||||
|
await editRow(p, JR_PASS)
|
||||||
|
await expect(block(p, 'Receipts & Invoices')).toBeVisible()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Opened for the picture, so the files it offers stand under the icon.
|
||||||
|
prepare: async p => {
|
||||||
|
await block(p, 'Receipts & Invoices').getByRole('button', { name: 'Link', exact: true }).click()
|
||||||
|
await expect(modal(p).getByRole('button', { name: VOUCHER })).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => block(p, 'Receipts & Invoices').getByRole('button', { name: 'Link', exact: true }),
|
||||||
|
// Pointer on the offered file, so the icon's tooltip does not cover the list.
|
||||||
|
hover: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: VOUCHER }).hover()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => modal(p).getByRole('button', { name: VOUCHER }),
|
||||||
|
act: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: VOUCHER }).click()
|
||||||
|
await expect(block(p, 'Receipts & Invoices').getByText(VOUCHER)).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => modal(p).getByRole('button', { name: 'Save', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: 'Save', exact: true }).click()
|
||||||
|
await expect(modal(p)).toHaveCount(0, { timeout: 20_000 })
|
||||||
|
await dropFocus(p)
|
||||||
|
await expect(expRow(p, JR_PASS).getByRole('button', { name: 'View receipt' })).toBeVisible({ timeout: 20_000 })
|
||||||
|
await expRow(p, JR_PASS).evaluate(el => el.scrollIntoView({ block: 'center' }))
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
for (const item of (await budgetItems(p)).filter(i => i.name === JR_PASS)) {
|
||||||
|
await p.request.put(`/api/trips/${tripId}/budget/${item.id}`, { data: { receipt_file_ids: [] } })
|
||||||
|
}
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
'filter-costs': {
|
'filter-costs': {
|
||||||
guide: guide('filter-costs'),
|
guide: guide('filter-costs'),
|
||||||
start: openCosts,
|
start: openCosts,
|
||||||
@@ -559,6 +737,31 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'leave-out-category': {
|
||||||
|
guide: guide('leave-out-category'),
|
||||||
|
start: openCosts,
|
||||||
|
steps: [
|
||||||
|
only(p => card(p, 'By category')),
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await card(p, 'By category').getByRole('button', { name: 'Leave Transport out of the totals' }).click()
|
||||||
|
await expect(card(p, 'By category').getByRole('button', { name: 'Count all', exact: true })).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => card(p, 'By category'),
|
||||||
|
},
|
||||||
|
only(p => card(p, 'Total trip spend')),
|
||||||
|
{
|
||||||
|
target: p => card(p, 'By category').getByRole('button', { name: 'Count all', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await card(p, 'By category').getByRole('button', { name: 'Count all', exact: true }).click()
|
||||||
|
await expect(card(p, 'By category').getByText('Select a category to leave it out of the totals.')).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
'settle-up': {
|
'settle-up': {
|
||||||
guide: guide('settle-up'),
|
guide: guide('settle-up'),
|
||||||
start: async p => {
|
start: async p => {
|
||||||
@@ -638,6 +841,50 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'costs-totals-only': {
|
||||||
|
guide: guide('costs-totals-only'),
|
||||||
|
start: openCosts,
|
||||||
|
steps: [
|
||||||
|
only(p => card(p, 'Split costs between travelers')),
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await modeSwitch(p).click()
|
||||||
|
await expect(modeSwitch(p)).toHaveAttribute('aria-pressed', 'false', { timeout: 15_000 })
|
||||||
|
await expect(card(p, 'Settle up')).toHaveCount(0)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
// The count under the total, which stands alone now; the frame around it
|
||||||
|
// shows the total and the ledger under it without payers or split. The
|
||||||
|
// card itself spans the whole width and would be cut at both sides.
|
||||||
|
target: p => card(p, 'Total trip spend').getByText(/^\d+ expenses?$/),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await addExpense(p).click()
|
||||||
|
await expect(nameBox(p)).toBeVisible()
|
||||||
|
await expect(modal(p).getByText('Who paid?', { exact: true })).toHaveCount(0)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
// The editor itself, not the dimmed backdrop around it.
|
||||||
|
target: p => p.getByRole('dialog').last(),
|
||||||
|
act: closeModal,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => card(p, 'Split costs between travelers'),
|
||||||
|
act: async p => {
|
||||||
|
await modeSwitch(p).click()
|
||||||
|
await expect(modeSwitch(p)).toHaveAttribute('aria-pressed', 'true', { timeout: 15_000 })
|
||||||
|
await expect(card(p, 'Settle up')).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
await setCostsMode(p, 'split')
|
||||||
|
},
|
||||||
|
},
|
||||||
|
|
||||||
'expense-from-booking': {
|
'expense-from-booking': {
|
||||||
guide: guide('expense-from-booking'),
|
guide: guide('expense-from-booking'),
|
||||||
start: async p => {
|
start: async p => {
|
||||||
|
|||||||
@@ -224,7 +224,12 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
only(p => stop(p, 'Arashiyama Bamboo Grove')),
|
only(p => stop(p, 'Arashiyama Bamboo Grove')),
|
||||||
only(p => stop(p, 'Nishiki Market')),
|
only(p => stop(p, 'Nishiki Market')),
|
||||||
only(connector),
|
only(connector),
|
||||||
only(routeBar),
|
{
|
||||||
|
// Hovered on Route itself: the bar's centre is the Walking button, whose
|
||||||
|
// tooltip would stand over the ring.
|
||||||
|
target: routeBar,
|
||||||
|
hover: async p => { await routeBar(p).getByRole('button', { name: 'Route', exact: true }).hover() },
|
||||||
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
'place-onto-day': {
|
'place-onto-day': {
|
||||||
@@ -252,7 +257,16 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
target: p => toOpenDay(p, SPARE.name),
|
target: p => toOpenDay(p, SPARE.name),
|
||||||
},
|
},
|
||||||
only(p => p.getByRole('button', { name: 'Add place to this day' }).first()),
|
only(p => p.getByRole('button', { name: 'Add place to this day' }).first()),
|
||||||
only(p => p.getByRole('button', { name: 'Add to the open day' })),
|
{
|
||||||
|
target: p => p.getByRole('button', { name: 'Add to the open day' }),
|
||||||
|
// The result shows the place as a stop on day 2, where step 1 dropped it,
|
||||||
|
// with the details panel of the open day out of the way.
|
||||||
|
act: async p => {
|
||||||
|
await closeDayDetails(p)
|
||||||
|
await stop(p, SPARE.name).evaluate(el => el.scrollIntoView({ block: 'center' }))
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
cleanup: p => deleteByName(p, SPARE.name),
|
cleanup: p => deleteByName(p, SPARE.name),
|
||||||
},
|
},
|
||||||
@@ -474,6 +488,8 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => noteDialog(p).getByText('Icon', { exact: true }).locator('xpath=../..'),
|
target: p => noteDialog(p).getByText('Icon', { exact: true }).locator('xpath=../..'),
|
||||||
|
// Pointed at the heading: the block's centre is an icon whose tooltip would stand in it.
|
||||||
|
hover: async p => { await noteDialog(p).getByText('Icon', { exact: true }).hover() },
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await noteDialog(p).getByRole('button', { name: 'Add', exact: true }).click()
|
await noteDialog(p).getByRole('button', { name: 'Add', exact: true }).click()
|
||||||
await expect(noteDialog(p)).toHaveCount(0)
|
await expect(noteDialog(p)).toHaveCount(0)
|
||||||
@@ -528,7 +544,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
guide: guide('manage-days'),
|
guide: guide('manage-days'),
|
||||||
start: p => openTrip(p),
|
start: p => openTrip(p),
|
||||||
steps: [
|
steps: [
|
||||||
only(p => dayHeader(p, 1)),
|
// The dates, and with them the days, are changed in the trip's edit form,
|
||||||
|
// which Trip settings at the top of the planner opens.
|
||||||
|
only(p => p.getByRole('button', { name: 'Trip settings' }).first()),
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await p.getByRole('button', { name: 'Reorder days' }).click()
|
await p.getByRole('button', { name: 'Reorder days' }).click()
|
||||||
@@ -655,6 +673,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
only(p => modal(p).getByText('Document', { exact: true }).locator('xpath=ancestor::section[1]')),
|
only(p => modal(p).getByText('Document', { exact: true }).locator('xpath=ancestor::section[1]')),
|
||||||
only(p => modal(p).getByText('Calendar', { exact: true }).locator('xpath=ancestor::section[1]')),
|
only(p => modal(p).getByText('Calendar', { exact: true }).locator('xpath=ancestor::section[1]')),
|
||||||
only(p => modal(p).getByText(/^Maps & GPS/).locator('xpath=ancestor::section[1]')),
|
only(p => modal(p).getByText(/^Maps & GPS/).locator('xpath=ancestor::section[1]')),
|
||||||
|
only(p => modal(p).getByText(/^Google Maps/).locator('xpath=ancestor::section[1]')),
|
||||||
],
|
],
|
||||||
cleanup: closeModal,
|
cleanup: closeModal,
|
||||||
},
|
},
|
||||||
|
|||||||
+307
-143
@@ -17,8 +17,12 @@ import type { HelpGuide } from '../../src/help/types'
|
|||||||
* not undo their changes one by one: the list is snapshotted once before the
|
* not undo their changes one by one: the list is snapshotted once before the
|
||||||
* first guide (`fixtures-trip-lists.ts`) and put back from that snapshot when
|
* first guide (`fixtures-trip-lists.ts`) and put back from that snapshot when
|
||||||
* each packing guide starts and again when it ends. What lives outside the
|
* each packing guide starts and again when it ends. What lives outside the
|
||||||
* items (a template, a bag, a list's assignees, a task) is removed by the
|
* items (a template, a bag, a list's assignees, who brings or sees an item, a
|
||||||
* guide that made it.
|
* task) is removed by the guide that made it.
|
||||||
|
*
|
||||||
|
* A packing row shows only what is set; a click on its name opens the item's
|
||||||
|
* window, where every choice about the item lives. The list-wide actions sit
|
||||||
|
* in the menu behind the three dots next to Add list.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const guide = (id: string): HelpGuide => {
|
const guide = (id: string): HelpGuide => {
|
||||||
@@ -57,16 +61,23 @@ const OPEN_ITEM = 'Slip-on shoes for temples'
|
|||||||
/** A list with one open item, so Check All visibly finishes it. */
|
/** A list with one open item, so Check All visibly finishes it. */
|
||||||
const CHECK_ALL_LIST = 'Electronics'
|
const CHECK_ALL_LIST = 'Electronics'
|
||||||
const CHECK_ALL_OPEN = 'eSIM activation code'
|
const CHECK_ALL_OPEN = 'eSIM activation code'
|
||||||
/** Fully packed in the seed, so the Open filter hides its list. */
|
/** Fully packed in the seed, so Hide packed hides its list. */
|
||||||
const PACKED_ITEM = 'Passport'
|
const PACKED_ITEM = 'Passport'
|
||||||
/** What the ordering guide moves: the third list onto the first, then the last item of that first list to its top. */
|
/** What the ordering guide moves: the third list onto the first, then the last item of that first list to its top. */
|
||||||
const MOVED_LIST = 'Electronics'
|
const MOVED_LIST = 'Electronics'
|
||||||
const FIRST_LIST = 'Documents'
|
const FIRST_LIST = 'Documents'
|
||||||
const MOVED_ITEM = 'Credit card and some yen'
|
const MOVED_ITEM = 'Credit card and some yen'
|
||||||
const TOP_ITEM = 'Passport'
|
const TOP_ITEM = 'Passport'
|
||||||
|
/** A to Z puts this one first in Clothing, where the seed has it in the middle. */
|
||||||
|
const SORTED_LIST = 'Clothing'
|
||||||
|
const SORTED_FIRST = 'Light layers'
|
||||||
/** Packed in the seed; the counting guide unticks it and counts five pairs in. */
|
/** Packed in the seed; the counting guide unticks it and counts five pairs in. */
|
||||||
const PIECES_ITEM = 'Merino socks'
|
const PIECES_ITEM = 'Merino socks'
|
||||||
const PIECES = 5
|
const PIECES = 5
|
||||||
|
/** The item whose window the editing guide walks through; it gets a second bringer. */
|
||||||
|
const EDIT_ITEM = 'Power bank'
|
||||||
|
/** The list the whole-list sharing guide hands to one person. */
|
||||||
|
const SHARE_LIST = 'Toiletries'
|
||||||
/** The count in the label moves with what is ticked, so it is matched, not spelled. */
|
/** The count in the label moves with what is ticked, so it is matched, not spelled. */
|
||||||
const CLEAR_CHECKED = /^Remove \d+ checked$/
|
const CLEAR_CHECKED = /^Remove \d+ checked$/
|
||||||
|
|
||||||
@@ -76,8 +87,8 @@ const CLEAR_CHECKED = /^Remove \d+ checked$/
|
|||||||
const cat = (page: Page, name: string): Locator =>
|
const cat = (page: Page, name: string): Locator =>
|
||||||
page.getByText(name, { exact: true }).first().locator('xpath=ancestor::div[2]')
|
page.getByText(name, { exact: true }).first().locator('xpath=ancestor::div[2]')
|
||||||
/**
|
/**
|
||||||
* The head band of a card. The ⋯ has to be taken from here: every item row
|
* The head band of a card. The ⋯ has to be taken from here: the card's rows
|
||||||
* carries a ⋯ of its own, so the card as a whole holds several of them.
|
* and its add field hold buttons of their own.
|
||||||
*/
|
*/
|
||||||
const catHeader = (page: Page, name: string): Locator => cat(page, name).locator('> div').first()
|
const catHeader = (page: Page, name: string): Locator => cat(page, name).locator('> div').first()
|
||||||
const catMenu = (page: Page, name: string): Locator =>
|
const catMenu = (page: Page, name: string): Locator =>
|
||||||
@@ -91,48 +102,38 @@ const item = (page: Page, name: string): Locator =>
|
|||||||
page.locator('.packing-item-row').filter({ hasText: name }).first()
|
page.locator('.packing-item-row').filter({ hasText: name }).first()
|
||||||
/** A row's own grip is a bare draggable div, the first thing in the row. */
|
/** A row's own grip is a bare draggable div, the first thing in the row. */
|
||||||
const rowGrip = (page: Page, name: string): Locator => item(page, name).locator('div[draggable="true"]')
|
const rowGrip = (page: Page, name: string): Locator => item(page, name).locator('div[draggable="true"]')
|
||||||
|
/** The name of a row is the button that opens the item's window. */
|
||||||
|
const itemName = (page: Page, name: string): Locator => item(page, name).locator('button[aria-haspopup="dialog"]')
|
||||||
|
/** The item's window, portalled to <body>; only one is ever open. */
|
||||||
|
const itemWindow = (page: Page): Locator => page.locator('div[role="dialog"].trek-menu-enter')
|
||||||
|
/** The short list a pill of the window opens under its line. */
|
||||||
|
const choiceList = (page: Page): Locator => itemWindow(page).locator('div.max-h-56')
|
||||||
|
/** A line of the window found by its label, for the pill on it. */
|
||||||
|
const windowLine = (page: Page, label: string): Locator =>
|
||||||
|
itemWindow(page).getByText(label, { exact: true }).locator('xpath=..')
|
||||||
/** The two-column grid of list cards; its children are the cards, in order. */
|
/** The two-column grid of list cards; its children are the cards, in order. */
|
||||||
const listGrid = (page: Page): Locator =>
|
const listGrid = (page: Page): Locator =>
|
||||||
page.locator('div.grid').filter({ has: page.locator('.packing-item-row') }).first()
|
page.locator('div.grid').filter({ has: page.locator('.packing-item-row') }).first()
|
||||||
/** The only item of the list the first guide builds; its name changes mid-guide. */
|
/** The only item of the list the first guide builds; its name changes mid-guide. */
|
||||||
const onlyRow = (page: Page): Locator => cat(page, NEW_LIST).locator('.packing-item-row').first()
|
const onlyRow = (page: Page): Locator => cat(page, NEW_LIST).locator('.packing-item-row').first()
|
||||||
/** An item's own ⋯, which holds Move to List, Sharing, Rename and Delete. */
|
/** The line beside Shared and My list that counts what is packed. */
|
||||||
const rowMenu = (page: Page, name: string): Locator => item(page, name).locator('.packing-row-overflow button')
|
const progressLine = (page: Page): Locator => page.getByText(/^\d+ of \d+ packed$/).first().locator('xpath=..')
|
||||||
/** The open item menu; Sharing is a whole line in it. */
|
|
||||||
const rowMenuSharing = (page: Page): Locator =>
|
|
||||||
page.locator('.trek-menu-enter').getByRole('button', { name: /^Sharing/ })
|
|
||||||
/**
|
|
||||||
* The progress card's count and percentage. The total is a span of its own
|
|
||||||
* that reads "/28"; the category badges hold "n/m" in one span, so they never match.
|
|
||||||
*/
|
|
||||||
const progressCount = (page: Page): Locator =>
|
|
||||||
page.getByText(/^\/\d+$/).first().locator('xpath=ancestor::div[2]')
|
|
||||||
/** The quantity badge is the first field among a row's inline actions while it has no counter. */
|
|
||||||
const quantityField = (page: Page, name: string): Locator =>
|
|
||||||
item(page, name).locator('.packing-row-inline-actions input').first()
|
|
||||||
/** The packed counter of a multi-piece item, named "3 of 5 packed". */
|
|
||||||
const piecesCounter = (page: Page, name: string): Locator =>
|
|
||||||
item(page, name).getByRole('group', { name: / of \d+ packed$/ })
|
|
||||||
/** The name dialog that Add list and Save as template open. */
|
/** The name dialog that Add list and Save as template open. */
|
||||||
const nameDialog = (page: Page, confirm: string): Locator => page.getByRole('button', { name: confirm, exact: true })
|
const nameDialog = (page: Page, confirm: string): Locator => page.getByRole('button', { name: confirm, exact: true })
|
||||||
/** The sharing dropdown is portalled to <body>, so the hint's parent is the card itself. */
|
/** The three dots next to Add list, and the menu they open. */
|
||||||
const shareMenu = (page: Page): Locator =>
|
const listsMenuButton = (page: Page): Locator =>
|
||||||
page.getByText('In the group pool, visible to everyone').locator('xpath=ancestor::div[1]')
|
page.getByRole('button', { name: 'Add list' }).locator('xpath=..').getByRole('button', { name: 'Show more' })
|
||||||
/** Its click-catcher, the only way back out of the menu once a name is ticked. */
|
const listsMenu = (page: Page): Locator => page.getByRole('menu')
|
||||||
const shareOverlay = (page: Page): Locator => page.locator('div[role="presentation"][style*="z-index: 1099"]').last()
|
|
||||||
/** The bulk-import dialog, a DialogShell whose head band carries its title. */
|
/** The bulk-import dialog, a DialogShell whose head band carries its title. */
|
||||||
const importCard = (page: Page): Locator =>
|
const importCard = (page: Page): Locator =>
|
||||||
page.getByRole('dialog').filter({ has: page.getByText('Import Packing List', { exact: true }) })
|
page.getByRole('dialog').filter({ has: page.getByText('Import Packing List', { exact: true }) })
|
||||||
/**
|
/** The whole-list sharing dialog, found by its footer button. */
|
||||||
* The bag picker of a row and the member picker of a bag both hang off the
|
const listSharing = (page: Page): Locator =>
|
||||||
* body, so they are found by their caption rather than inside the row.
|
page.getByRole('dialog').filter({ has: page.getByRole('button', { name: 'Apply to list' }) })
|
||||||
*/
|
/** The member picker of a bag hangs off the body, so it is found by its caption. */
|
||||||
const bagPicker = (page: Page): Locator => page.locator('.trek-menu-enter').filter({ hasText: 'Bags' }).last()
|
|
||||||
const bagMemberPicker = (page: Page): Locator => page.locator('.trek-menu-enter').filter({ hasText: 'Assign members' }).last()
|
const bagMemberPicker = (page: Page): Locator => page.locator('.trek-menu-enter').filter({ hasText: 'Assign members' }).last()
|
||||||
/** The calendar a date field opens, a portal of its own. */
|
/** The calendar a date field opens, a portal of its own. */
|
||||||
const datePicker = (page: Page): Locator => page.getByRole('dialog', { name: 'Date picker' })
|
const datePicker = (page: Page): Locator => page.getByRole('dialog', { name: 'Date picker' })
|
||||||
/** The Export button's menu: print, Markdown and CSV. */
|
|
||||||
const exportMenu = (page: Page): Locator => page.getByRole('menu')
|
|
||||||
/** The printable page inside the preview, a srcdoc frame of its own. */
|
/** The printable page inside the preview, a srcdoc frame of its own. */
|
||||||
const printFrame = (page: Page) => page.frameLocator('iframe[title^="Packing List"]')
|
const printFrame = (page: Page) => page.frameLocator('iframe[title^="Packing List"]')
|
||||||
/** The bag sidebar: the innermost box holding the guide's bag and the weight summary below the cards. */
|
/** The bag sidebar: the innermost box holding the guide's bag and the weight summary below the cards. */
|
||||||
@@ -177,6 +178,35 @@ async function openTodos(page: Page): Promise<void> {
|
|||||||
await settle(page)
|
await settle(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The three dots next to Add list, opened. */
|
||||||
|
async function openListsMenu(page: Page): Promise<void> {
|
||||||
|
await listsMenuButton(page).click()
|
||||||
|
await expect(listsMenu(page)).toBeVisible()
|
||||||
|
await beat(page, 300)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The menu and the item window sit over a full-viewport catcher; a click in
|
||||||
|
* the corner closes either without touching what is under it.
|
||||||
|
*/
|
||||||
|
async function clickAside(page: Page): Promise<void> {
|
||||||
|
await page.mouse.click(20, VIEWPORT.height - 40)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Opens an item's window, with its row in the middle of the screen so the window has room below it. */
|
||||||
|
async function openItem(page: Page, name: string): Promise<void> {
|
||||||
|
await item(page, name).evaluate(el => el.scrollIntoView({ block: 'center' }))
|
||||||
|
await itemName(page, name).click()
|
||||||
|
await expect(itemWindow(page)).toBeVisible()
|
||||||
|
await settle(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function closeItem(page: Page): Promise<void> {
|
||||||
|
await itemWindow(page).getByRole('button', { name: 'Close', exact: true }).click()
|
||||||
|
await expect(itemWindow(page)).toHaveCount(0)
|
||||||
|
await settle(page)
|
||||||
|
}
|
||||||
|
|
||||||
// ── Putting the seed back ────────────────────────────────────────────────────
|
// ── Putting the seed back ────────────────────────────────────────────────────
|
||||||
|
|
||||||
/** The packing list as the seed and the fixtures left it, taken in beforeAll. */
|
/** The packing list as the seed and the fixtures left it, taken in beforeAll. */
|
||||||
@@ -198,6 +228,9 @@ async function startLists(page: Page): Promise<void> {
|
|||||||
interface PackingRow {
|
interface PackingRow {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
|
category: string | null
|
||||||
|
is_private?: number | boolean
|
||||||
|
contributors?: { user_id: number; username: string }[]
|
||||||
}
|
}
|
||||||
|
|
||||||
async function packingItems(page: Page): Promise<PackingRow[]> {
|
async function packingItems(page: Page): Promise<PackingRow[]> {
|
||||||
@@ -207,6 +240,24 @@ async function packingItems(page: Page): Promise<PackingRow[]> {
|
|||||||
return body.items ?? []
|
return body.items ?? []
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Puts items back into the group pool, the seed's tier for every item. */
|
||||||
|
async function shareWithEveryone(page: Page, rows: PackingRow[]): Promise<void> {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
for (const row of rows) {
|
||||||
|
await page.request.put(`/api/trips/${tripId}/packing/${row.id}/sharing`, { data: { visibility: 'common', recipient_ids: [] } })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Takes a member off the people who bring an item. */
|
||||||
|
async function dropBringer(page: Page, itemName: string, username: string): Promise<void> {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
const row = (await packingItems(page)).find(x => x.name === itemName)
|
||||||
|
if (!row) return
|
||||||
|
for (const c of (row.contributors ?? []).filter(x => x.username === username)) {
|
||||||
|
await page.request.delete(`/api/trips/${tripId}/packing/${row.id}/contributors/${c.user_id}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function deleteTemplate(page: Page, name: string): Promise<void> {
|
async function deleteTemplate(page: Page, name: string): Promise<void> {
|
||||||
const res = await page.request.get('/api/admin/packing-templates')
|
const res = await page.request.get('/api/admin/packing-templates')
|
||||||
const body = (await res.json()) as { templates?: { id: number; name: string }[] }
|
const body = (await res.json()) as { templates?: { id: number; name: string }[] }
|
||||||
@@ -266,7 +317,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await cat(p, NEW_LIST).getByRole('button', { name: 'Add item' }).click()
|
await cat(p, NEW_LIST).getByRole('button', { name: 'Add item' }).click()
|
||||||
const field = p.getByPlaceholder('Item name...')
|
const field = p.getByPlaceholder('Item name...')
|
||||||
await typeInto(p, field, FIRST_ITEM)
|
await typeInto(p, field, FIRST_ITEM)
|
||||||
// Enter renames the list's '...' row rather than adding a second one,
|
// Enter fills the list's empty row rather than adding a second one,
|
||||||
// and leaves the field open; Escape is how it closes.
|
// and leaves the field open; Escape is how it closes.
|
||||||
await field.press('Enter')
|
await field.press('Enter')
|
||||||
await expect(item(p, FIRST_ITEM)).toBeVisible({ timeout: 20_000 })
|
await expect(item(p, FIRST_ITEM)).toBeVisible({ timeout: 20_000 })
|
||||||
@@ -275,18 +326,19 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prepare: async p => { await onlyRow(p).hover() },
|
prepare: async p => {
|
||||||
// A click on the name renames it; the row has no pencil of its own.
|
await onlyRow(p).locator('button[aria-haspopup="dialog"]').click()
|
||||||
target: p => onlyRow(p).getByRole('button', { name: FIRST_ITEM }),
|
await expect(itemWindow(p)).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
// The name at the top of the window is the field the text means.
|
||||||
|
target: p => itemWindow(p).getByRole('textbox', { name: 'Rename' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await onlyRow(p).getByRole('button', { name: FIRST_ITEM }).click()
|
const field = itemWindow(p).getByRole('textbox', { name: 'Rename' })
|
||||||
// While editing, the name is the row's first input; the quantity and
|
|
||||||
// the weight come after it.
|
|
||||||
const field = onlyRow(p).locator('input').first()
|
|
||||||
await typeInto(p, field, RENAMED_ITEM)
|
await typeInto(p, field, RENAMED_ITEM)
|
||||||
await field.press('Enter')
|
await field.press('Enter')
|
||||||
await expect(item(p, RENAMED_ITEM)).toBeVisible({ timeout: 20_000 })
|
await expect(item(p, RENAMED_ITEM)).toBeVisible({ timeout: 20_000 })
|
||||||
await settle(p)
|
await closeItem(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -301,8 +353,11 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
// Shown on the first list: the new one is the last card on the page, and
|
||||||
|
// its menu would run past the bottom of the screen.
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await catMenu(p, NEW_LIST).click()
|
await catHeader(p, FIRST_LIST).evaluate(el => el.scrollIntoView({ block: 'center' }))
|
||||||
|
await catMenu(p, FIRST_LIST).click()
|
||||||
await expect(p.getByRole('button', { name: 'Delete List' })).toBeVisible()
|
await expect(p.getByRole('button', { name: 'Delete List' })).toBeVisible()
|
||||||
await beat(p, 300)
|
await beat(p, 300)
|
||||||
},
|
},
|
||||||
@@ -310,14 +365,15 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// The pointer rests on the three dots that opened it, not on an entry.
|
// The pointer rests on the three dots that opened it, not on an entry.
|
||||||
// Moved by coordinates: the menu's click-catcher covers the button.
|
// Moved by coordinates: the menu's click-catcher covers the button.
|
||||||
hover: async p => {
|
hover: async p => {
|
||||||
const b = await catMenu(p, NEW_LIST).boundingBox()
|
const b = await catMenu(p, FIRST_LIST).boundingBox()
|
||||||
if (b) await p.mouse.move(b.x + b.width / 2, b.y + b.height / 2)
|
if (b) await p.mouse.move(b.x + b.width / 2, b.y + b.height / 2)
|
||||||
},
|
},
|
||||||
act: async p => {
|
act: async p => {
|
||||||
// The menu sits over a full-viewport catcher; a click in the corner
|
// A click in the corner closes the menu without deleting the list the picture was just taken of.
|
||||||
// closes it without deleting the list the picture was just taken of.
|
await clickAside(p)
|
||||||
await p.mouse.click(20, VIEWPORT.height - 40)
|
|
||||||
await expect(p.getByRole('button', { name: 'Delete List' })).toHaveCount(0)
|
await expect(p.getByRole('button', { name: 'Delete List' })).toHaveCount(0)
|
||||||
|
// Back to the new list for the after-picture.
|
||||||
|
await cat(p, NEW_LIST).evaluate(el => el.scrollIntoView({ block: 'center' }))
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -328,6 +384,61 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await p.request.put(`/api/trips/${tripId}/packing/category-assignees/${encodeURIComponent(NEW_LIST)}`, { data: { user_ids: [] } })
|
await p.request.put(`/api/trips/${tripId}/packing/category-assignees/${encodeURIComponent(NEW_LIST)}`, { data: { user_ids: [] } })
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'edit-packing-item': {
|
||||||
|
guide: guide('edit-packing-item'),
|
||||||
|
start: async p => {
|
||||||
|
await dropBringer(p, EDIT_ITEM, MEMBER)
|
||||||
|
await startLists(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => itemName(p, EDIT_ITEM),
|
||||||
|
act: p => openItem(p, EDIT_ITEM),
|
||||||
|
},
|
||||||
|
only(p => itemWindow(p).getByRole('textbox', { name: 'Rename' })),
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await windowLine(p, 'List').getByRole('button').click()
|
||||||
|
await expect(choiceList(p)).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: choiceList,
|
||||||
|
// The pointer on another list, as if about to pick it.
|
||||||
|
hover: async p => { await choiceList(p).getByRole('button', { name: FIRST_LIST, exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
// Shown, not picked: the item would leave its row and the window with it.
|
||||||
|
await windowLine(p, 'List').getByRole('button').click()
|
||||||
|
await expect(choiceList(p)).toHaveCount(0)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await windowLine(p, 'Brought by').getByRole('button').click()
|
||||||
|
await expect(choiceList(p)).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: choiceList,
|
||||||
|
hover: async p => { await choiceList(p).getByRole('button', { name: MEMBER, exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await choiceList(p).getByRole('button', { name: MEMBER, exact: true }).click()
|
||||||
|
await expect(windowLine(p, 'Brought by')).toContainText(MEMBER, { timeout: 20_000 })
|
||||||
|
await windowLine(p, 'Brought by').getByRole('button').click()
|
||||||
|
await expect(choiceList(p)).toHaveCount(0)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => itemWindow(p).getByRole('button', { name: 'Delete', exact: true }),
|
||||||
|
// Shown, not pressed: the window closes with its cross.
|
||||||
|
act: closeItem,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await dropBringer(p, EDIT_ITEM, MEMBER)
|
||||||
|
await resetPacking(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
'arrange-packing-list': {
|
'arrange-packing-list': {
|
||||||
guide: guide('arrange-packing-list'),
|
guide: guide('arrange-packing-list'),
|
||||||
start: startLists,
|
start: startLists,
|
||||||
@@ -355,10 +466,14 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => p.getByRole('button', { name: 'A to Z' }),
|
prepare: openListsMenu,
|
||||||
|
target: p => listsMenu(p).getByRole('button', { name: 'A to Z' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await p.getByRole('button', { name: 'A to Z' }).click()
|
await listsMenu(p).getByRole('button', { name: 'A to Z' }).click()
|
||||||
await expect(p.getByRole('button', { name: 'A to Z' })).toHaveAttribute('aria-pressed', 'true')
|
// The order is a switch with a tick; the menu stays open for the next one.
|
||||||
|
await clickAside(p)
|
||||||
|
await expect(listsMenu(p)).toHaveCount(0)
|
||||||
|
await expect(cat(p, SORTED_LIST).locator('.packing-item-row').first()).toContainText(SORTED_FIRST, { timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -375,17 +490,14 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
start: startLists,
|
start: startLists,
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
// The grip is a div, so the tick box is the row's first button.
|
target: p => item(p, OPEN_ITEM).locator('.packing-check'),
|
||||||
target: p => item(p, OPEN_ITEM).getByRole('button').first(),
|
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await item(p, OPEN_ITEM).getByRole('button').first().click()
|
await item(p, OPEN_ITEM).locator('.packing-check').click()
|
||||||
await expect(item(p, OPEN_ITEM).locator('.packing-check')).toHaveAttribute('aria-pressed', 'true', { timeout: 20_000 })
|
await expect(item(p, OPEN_ITEM).locator('.packing-check')).toHaveAttribute('aria-pressed', 'true', { timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// The count and the percentage, with the bar beside them: the whole card is
|
only(progressLine),
|
||||||
// wider than any frame and would lose both at its edges.
|
|
||||||
only(progressCount),
|
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await catMenu(p, CHECK_ALL_LIST).click()
|
await catMenu(p, CHECK_ALL_LIST).click()
|
||||||
@@ -400,23 +512,27 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => p.getByRole('button', { name: 'Open', exact: true }),
|
prepare: openListsMenu,
|
||||||
|
target: p => listsMenu(p).getByRole('button', { name: 'Hide packed' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await p.getByRole('button', { name: 'Open', exact: true }).click()
|
await listsMenu(p).getByRole('button', { name: 'Hide packed' }).click()
|
||||||
|
await clickAside(p)
|
||||||
|
await expect(listsMenu(p)).toHaveCount(0)
|
||||||
await expect(item(p, PACKED_ITEM)).toHaveCount(0, { timeout: 20_000 })
|
await expect(item(p, PACKED_ITEM)).toHaveCount(0, { timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => p.getByRole('button', { name: CLEAR_CHECKED }),
|
prepare: openListsMenu,
|
||||||
|
target: p => listsMenu(p).getByRole('button', { name: CLEAR_CHECKED }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
// A native window.confirm, which cannot be pictured. The step shows the
|
// A native window.confirm, which cannot be pictured. The step shows the
|
||||||
// button and answers the browser with Cancel: with the Open filter on,
|
// entry and answers the browser with Cancel: with the packed items
|
||||||
// the screen looks the same either way, and the seed's ticked items
|
// hidden, the screen looks the same either way, and the seed's ticked
|
||||||
// (most of the list) stay where they are for the guides after this one.
|
// items (most of the list) stay where they are for the guides after this one.
|
||||||
p.once('dialog', d => { void d.dismiss() })
|
p.once('dialog', d => { void d.dismiss() })
|
||||||
await p.getByRole('button', { name: CLEAR_CHECKED }).click()
|
await listsMenu(p).getByRole('button', { name: CLEAR_CHECKED }).click()
|
||||||
await expect(p.getByRole('button', { name: CLEAR_CHECKED })).toBeVisible()
|
await expect(listsMenu(p)).toHaveCount(0)
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -432,39 +548,34 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
prepare: async p => { await item(p, PIECES_ITEM).hover() },
|
target: p => itemName(p, PIECES_ITEM),
|
||||||
target: p => quantityField(p, PIECES_ITEM),
|
act: p => openItem(p, PIECES_ITEM),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => itemWindow(p).getByRole('group', { name: 'Qty' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
const field = quantityField(p, PIECES_ITEM)
|
const field = itemWindow(p).getByRole('group', { name: 'Qty' }).locator('input')
|
||||||
await typeInto(p, field, String(PIECES))
|
await typeInto(p, field, String(PIECES))
|
||||||
await field.press('Enter')
|
await field.press('Enter')
|
||||||
await expect(piecesCounter(p, PIECES_ITEM)).toHaveAccessibleName(`0 of ${PIECES} packed`, { timeout: 20_000 })
|
await expect(itemWindow(p).getByRole('group', { name: `0 of ${PIECES} packed` })).toBeVisible({ timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => piecesCounter(p, PIECES_ITEM),
|
target: p => itemWindow(p).getByRole('group', { name: / of \d+ packed$/ }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
for (let n = 1; n <= 3; n++) {
|
for (let n = 1; n <= 3; n++) {
|
||||||
await item(p, PIECES_ITEM).getByRole('button', { name: 'Pack one more' }).click()
|
await itemWindow(p).getByRole('button', { name: 'Pack one more' }).click()
|
||||||
await expect(piecesCounter(p, PIECES_ITEM)).toHaveAccessibleName(`${n} of ${PIECES} packed`, { timeout: 20_000 })
|
await expect(itemWindow(p).getByRole('group', { name: `${n} of ${PIECES} packed` })).toBeVisible({ timeout: 20_000 })
|
||||||
}
|
}
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Partly packed: the counter in the accent, the tick box outlined in it.
|
// Partly packed: the count in the row, the tick box outlined in the accent.
|
||||||
|
prepare: closeItem,
|
||||||
target: p => item(p, PIECES_ITEM),
|
target: p => item(p, PIECES_ITEM),
|
||||||
act: async p => {
|
|
||||||
for (let n = 4; n <= PIECES; n++) {
|
|
||||||
await item(p, PIECES_ITEM).getByRole('button', { name: 'Pack one more' }).click()
|
|
||||||
await expect(piecesCounter(p, PIECES_ITEM)).toHaveAccessibleName(`${n} of ${PIECES} packed`, { timeout: 20_000 })
|
|
||||||
}
|
|
||||||
await expect(item(p, PIECES_ITEM).locator('.packing-check')).toHaveAttribute('aria-pressed', 'true', { timeout: 20_000 })
|
|
||||||
await settle(p)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
only(p => item(p, PIECES_ITEM)),
|
|
||||||
],
|
],
|
||||||
cleanup: resetPacking,
|
cleanup: resetPacking,
|
||||||
},
|
},
|
||||||
@@ -473,26 +584,32 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
start: startLists,
|
start: startLists,
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
target: p => p.getByRole('button', { name: 'Apply template' }),
|
target: listsMenuButton,
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await p.getByRole('button', { name: 'Apply template' }).click()
|
await openListsMenu(p)
|
||||||
await expect(p.locator('.trek-menu-enter').last()).toBeVisible()
|
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => p.locator('.trek-menu-enter').last(),
|
prepare: async p => {
|
||||||
|
await listsMenu(p).getByRole('button', { name: 'Apply template' }).click()
|
||||||
|
await expect(listsMenu(p).getByRole('button', { name: new RegExp(`^${TEMPLATE.name}`) })).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => listsMenu(p).getByRole('button', { name: new RegExp(`^${TEMPLATE.name}`) }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await p.locator('.trek-menu-enter').last().getByRole('button', { name: new RegExp(`^${TEMPLATE.name}`) }).click()
|
await listsMenu(p).getByRole('button', { name: new RegExp(`^${TEMPLATE.name}`) }).click()
|
||||||
await expect(cat(p, TEMPLATE.category)).toBeVisible({ timeout: 30_000 })
|
await expect(cat(p, TEMPLATE.category)).toBeVisible({ timeout: 30_000 })
|
||||||
|
await expect(listsMenu(p)).toHaveCount(0)
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
only(p => p.getByRole('button', { name: /^Shared/ })),
|
only(p => p.getByRole('button', { name: /^Shared/ })),
|
||||||
{
|
{
|
||||||
target: p => p.getByRole('button', { name: 'Save as template' }),
|
prepare: openListsMenu,
|
||||||
|
target: p => listsMenu(p).getByRole('button', { name: 'Save as template' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await p.getByRole('button', { name: 'Save as template' }).click()
|
await listsMenu(p).getByRole('button', { name: 'Save as template' }).click()
|
||||||
const field = p.getByPlaceholder('Template name')
|
const field = p.getByPlaceholder('Template name')
|
||||||
await typeInto(p, field, SAVED_TEMPLATE)
|
await typeInto(p, field, SAVED_TEMPLATE)
|
||||||
await nameDialog(p, 'Save').click()
|
await nameDialog(p, 'Save').click()
|
||||||
@@ -511,10 +628,10 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
start: startLists,
|
start: startLists,
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
// An icon at the right end of the bar, named Import by its label and tooltip.
|
prepare: openListsMenu,
|
||||||
target: p => p.getByRole('button', { name: 'Import', exact: true }),
|
target: p => listsMenu(p).getByRole('button', { name: 'Import', exact: true }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await p.getByRole('button', { name: 'Import', exact: true }).click()
|
await listsMenu(p).getByRole('button', { name: 'Import', exact: true }).click()
|
||||||
await expect(importCard(p)).toBeVisible()
|
await expect(importCard(p)).toBeVisible()
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
@@ -555,19 +672,21 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
start: startLists,
|
start: startLists,
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
target: p => p.getByRole('button', { name: 'Export', exact: true }),
|
target: listsMenuButton,
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await p.getByRole('button', { name: 'Export', exact: true }).click()
|
await openListsMenu(p)
|
||||||
await expect(exportMenu(p)).toBeVisible()
|
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// The two file entries download at once; the step shows them, it does not press them.
|
// The two file entries download at once; the step shows them, it does not press them.
|
||||||
only(exportMenu),
|
|
||||||
{
|
{
|
||||||
target: p => exportMenu(p).getByRole('menuitem', { name: 'Print or save as PDF' }),
|
target: listsMenu,
|
||||||
|
hover: async p => { await listsMenu(p).getByRole('button', { name: 'CSV for import (.csv)' }).hover() },
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => listsMenu(p).getByRole('button', { name: 'Print or save as PDF' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await exportMenu(p).getByRole('menuitem', { name: 'Print or save as PDF' }).click()
|
await listsMenu(p).getByRole('button', { name: 'Print or save as PDF' }).click()
|
||||||
await expect(printFrame(p).locator('h1')).toBeVisible({ timeout: 15_000 })
|
await expect(printFrame(p).locator('h1')).toBeVisible({ timeout: 15_000 })
|
||||||
// The page carries the app's own Poppins; the result picture waits for it.
|
// The page carries the app's own Poppins; the result picture waits for it.
|
||||||
await printFrame(p).locator('body').evaluate(async () => { await document.fonts.ready })
|
await printFrame(p).locator('body').evaluate(async () => { await document.fonts.ready })
|
||||||
@@ -577,7 +696,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// Pressing it opens the operating system's print dialog, which is not part
|
// Pressing it opens the operating system's print dialog, which is not part
|
||||||
// of the picture; the button is shown, not pressed. The result picture is the
|
// of the picture; the button is shown, not pressed. The result picture is the
|
||||||
// preview itself.
|
// preview itself.
|
||||||
only(p => p.getByRole('button', { name: 'Print or save as PDF' })),
|
only(p => p.getByRole('button', { name: 'Print or save as PDF' }).last()),
|
||||||
],
|
],
|
||||||
cleanup: async p => {
|
cleanup: async p => {
|
||||||
await p.getByRole('button', { name: 'Close', exact: true }).first().click()
|
await p.getByRole('button', { name: 'Close', exact: true }).first().click()
|
||||||
@@ -598,24 +717,17 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: p => openItem(p, SHARED_ITEM),
|
||||||
await item(p, SHARED_ITEM).hover()
|
// The whole line: its label and the three choices.
|
||||||
await rowMenu(p, SHARED_ITEM).click()
|
target: p => itemWindow(p).getByRole('radiogroup', { name: 'Visible to' }).locator('xpath=../..'),
|
||||||
await expect(rowMenuSharing(p)).toBeVisible()
|
|
||||||
await beat(p, 300)
|
|
||||||
},
|
|
||||||
target: rowMenuSharing,
|
|
||||||
act: async p => {
|
|
||||||
await rowMenuSharing(p).click()
|
|
||||||
await expect(shareMenu(p)).toBeVisible()
|
|
||||||
await settle(p)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: shareMenu,
|
target: p => itemWindow(p).getByRole('radio', { name: 'Only me' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await shareMenu(p).getByRole('button', { name: /^Personal/ }).click()
|
await itemWindow(p).getByRole('radio', { name: 'Only me' }).click()
|
||||||
|
// The row leaves the shared list, and its window goes with it.
|
||||||
await expect(item(p, SHARED_ITEM)).toHaveCount(0, { timeout: 20_000 })
|
await expect(item(p, SHARED_ITEM)).toHaveCount(0, { timeout: 20_000 })
|
||||||
|
await expect(itemWindow(p)).toHaveCount(0)
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -629,31 +741,80 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await item(p, SHARED_ITEM).hover()
|
await openItem(p, SHARED_ITEM)
|
||||||
await rowMenu(p, SHARED_ITEM).click()
|
await itemWindow(p).getByRole('radio', { name: 'Selected' }).click()
|
||||||
await rowMenuSharing(p).click()
|
await expect(choiceList(p)).toBeVisible()
|
||||||
await expect(shareMenu(p)).toBeVisible()
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: choiceList,
|
||||||
|
hover: async p => { await choiceList(p).getByRole('button', { name: MEMBER, exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await choiceList(p).getByRole('button', { name: MEMBER, exact: true }).click()
|
||||||
|
await expect(item(p, SHARED_ITEM).getByLabel('shared with 1')).toBeVisible({ timeout: 20_000 })
|
||||||
|
await closeItem(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await shareWithEveryone(p, (await packingItems(p)).filter(x => x.name === SHARED_ITEM))
|
||||||
|
await resetPacking(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'share-packing-list': {
|
||||||
|
guide: guide('share-packing-list'),
|
||||||
|
start: async p => {
|
||||||
|
await shareWithEveryone(p, (await packingItems(p)).filter(x => x.category === SHARE_LIST))
|
||||||
|
await startLists(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await catMenu(p, SHARE_LIST).click()
|
||||||
|
await expect(p.getByRole('button', { name: 'Sharing for Whole List' })).toBeVisible()
|
||||||
await beat(p, 300)
|
await beat(p, 300)
|
||||||
},
|
},
|
||||||
target: p => shareMenu(p).getByRole('button', { name: MEMBER }),
|
target: p => p.getByRole('button', { name: 'Sharing for Whole List' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await shareMenu(p).getByRole('button', { name: MEMBER }).click()
|
await p.getByRole('button', { name: 'Sharing for Whole List' }).click()
|
||||||
// Ticking a name leaves the menu open on purpose; its catcher closes it,
|
await expect(listSharing(p)).toBeVisible()
|
||||||
// and the item menu under it has one of its own.
|
await settle(p)
|
||||||
await shareOverlay(p).click({ position: { x: 5, y: 5 } })
|
},
|
||||||
await p.mouse.click(20, VIEWPORT.height - 40)
|
},
|
||||||
await expect(p.locator('.trek-menu-enter')).toHaveCount(0)
|
{
|
||||||
await expect(item(p, SHARED_ITEM).getByLabel('shared with 1')).toBeVisible({ timeout: 20_000 })
|
// The box of the three tiers; the list starts on Shared, where the seed has it.
|
||||||
|
target: p => listSharing(p).getByRole('button', { name: /^Shared with/ }).locator('xpath=..'),
|
||||||
|
hover: async p => { await listSharing(p).getByRole('button', { name: /^Shared with/ }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await listSharing(p).getByRole('button', { name: /^Shared with/ }).click()
|
||||||
|
await expect(listSharing(p).getByRole('button', { name: MEMBER, exact: true })).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => listSharing(p).getByRole('button', { name: MEMBER, exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await listSharing(p).getByRole('button', { name: MEMBER, exact: true }).click()
|
||||||
|
await expect(listSharing(p).getByRole('button', { name: MEMBER, exact: true })).toHaveAttribute('aria-pressed', 'true')
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => listSharing(p).getByRole('button', { name: 'Apply to list' }),
|
||||||
|
act: async p => {
|
||||||
|
await listSharing(p).getByRole('button', { name: 'Apply to list' }).click()
|
||||||
|
await expect(listSharing(p)).toHaveCount(0, { timeout: 30_000 })
|
||||||
|
// The confirmation is a toast; the after-picture waits for it to go.
|
||||||
|
const done = p.getByText(`Sharing changed for "${SHARE_LIST}"`)
|
||||||
|
await expect(done).toBeVisible({ timeout: 20_000 })
|
||||||
|
await p.getByRole('button', { name: /^My list/ }).click()
|
||||||
|
await expect(cat(p, SHARE_LIST)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await expect(done).toHaveCount(0, { timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
cleanup: async p => {
|
cleanup: async p => {
|
||||||
const { tripId } = seededTrip()
|
await shareWithEveryone(p, (await packingItems(p)).filter(x => x.category === SHARE_LIST))
|
||||||
const row = (await packingItems(p)).find(x => x.name === SHARED_ITEM)
|
|
||||||
if (row) {
|
|
||||||
await p.request.put(`/api/trips/${tripId}/packing/${row.id}/sharing`, { data: { visibility: 'common', recipient_ids: [] } })
|
|
||||||
}
|
|
||||||
await resetPacking(p)
|
await resetPacking(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -666,35 +827,38 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
|
prepare: p => openItem(p, BAG_ITEM),
|
||||||
// The weight field's placeholder really is a dash: it is the app's own
|
// The weight field's placeholder really is a dash: it is the app's own
|
||||||
// string, not prose, so it is matched exactly as rendered.
|
// string, not prose, so it is matched exactly as rendered. The ring takes
|
||||||
target: p => item(p, BAG_ITEM).getByPlaceholder('—'),
|
// the whole pill, the grams with it.
|
||||||
|
target: p => itemWindow(p).getByPlaceholder('—').locator('xpath=..'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
const field = item(p, BAG_ITEM).getByPlaceholder('—')
|
const field = itemWindow(p).getByPlaceholder('—')
|
||||||
await typeInto(p, field, '620')
|
await typeInto(p, field, '620')
|
||||||
|
await field.press('Enter')
|
||||||
await expect(field).toHaveValue('620', { timeout: 20_000 })
|
await expect(field).toHaveValue('620', { timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prepare: async p => { await item(p, BAG_ITEM).hover() },
|
target: p => windowLine(p, 'Bag').getByRole('button'),
|
||||||
// The circle is dashed with a parcel in it while the item is in no bag.
|
|
||||||
target: p => item(p, BAG_ITEM).locator('button:has(svg.lucide-package)'),
|
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await item(p, BAG_ITEM).locator('button:has(svg.lucide-package)').click()
|
await windowLine(p, 'Bag').getByRole('button').click()
|
||||||
await expect(bagPicker(p).getByRole('button', { name: 'Add bag' })).toBeVisible()
|
await expect(itemWindow(p).getByPlaceholder('Add bag')).toBeVisible()
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => bagPicker(p).getByRole('button', { name: 'Add bag' }),
|
// The line at the end of the bag list, with its round add button.
|
||||||
|
target: p => itemWindow(p).getByPlaceholder('Add bag').locator('xpath=..'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await bagPicker(p).getByRole('button', { name: 'Add bag' }).click()
|
const field = itemWindow(p).getByPlaceholder('Add bag')
|
||||||
const field = bagPicker(p).getByPlaceholder('Bag name...')
|
|
||||||
await typeInto(p, field, BAG)
|
await typeInto(p, field, BAG)
|
||||||
await field.press('Enter')
|
await field.press('Enter')
|
||||||
|
await expect(windowLine(p, 'Bag')).toContainText(BAG, { timeout: 30_000 })
|
||||||
|
// The window repeats Total weight and the bag's name, so it goes before the card is looked for.
|
||||||
|
await closeItem(p)
|
||||||
await expect(bagSidebar(p)).toBeVisible({ timeout: 30_000 })
|
await expect(bagSidebar(p)).toBeVisible({ timeout: 30_000 })
|
||||||
await expect(bagPicker(p)).toHaveCount(0)
|
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -722,7 +886,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await bagSidebar(p).locator('button[style*="dashed"]').first().click()
|
await bagSidebar(p).locator('button[style*="dashed"]').first().click()
|
||||||
await bagMemberPicker(p).getByRole('button', { name: MEMBER }).click()
|
await bagMemberPicker(p).getByRole('button', { name: MEMBER }).click()
|
||||||
// The picker closes on a click anywhere beside it.
|
// The picker closes on a click anywhere beside it.
|
||||||
await p.mouse.click(20, VIEWPORT.height - 40)
|
await clickAside(p)
|
||||||
await expect(bagSidebar(p).getByRole('button', { name: MEMBER })).toBeVisible({ timeout: 20_000 })
|
await expect(bagSidebar(p).getByRole('button', { name: MEMBER })).toBeVisible({ timeout: 20_000 })
|
||||||
// A bag with someone on it fills Per person at the foot of the card.
|
// A bag with someone on it fills Per person at the foot of the card.
|
||||||
await expect(p.getByText('Per person', { exact: true })).toBeVisible({ timeout: 20_000 })
|
await expect(p.getByText('Per person', { exact: true })).toBeVisible({ timeout: 20_000 })
|
||||||
|
|||||||
@@ -310,6 +310,32 @@ interface TrekGlMap {
|
|||||||
easeTo: (o: { bearing: number; pitch: number; duration: number }) => unknown
|
easeTo: (o: { bearing: number; pitch: number; duration: number }) => unknown
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Turn the GL map to a bearing at once, and wait until it has painted it. */
|
||||||
|
/**
|
||||||
|
* How far the compass guide turns the map. The vector labels stay level at any
|
||||||
|
* bearing, and the compass icon is drawn leaning 45° to the right, so at 35°
|
||||||
|
* the map read as north up and the arrow as upright. At 70° the coast lies
|
||||||
|
* visibly askew and the arrow leans the other way.
|
||||||
|
*/
|
||||||
|
const TURN = 70
|
||||||
|
|
||||||
|
async function turnMap(page: Page, bearing: number): Promise<void> {
|
||||||
|
await page.evaluate(b => {
|
||||||
|
const m = (window as unknown as { __trek_map?: TrekGlMap }).__trek_map
|
||||||
|
if (!m) throw new Error('no GL map on the page')
|
||||||
|
m.easeTo({ bearing: b, pitch: 0, duration: 0 })
|
||||||
|
}, bearing)
|
||||||
|
await page.waitForFunction(b => {
|
||||||
|
const m = (window as unknown as { __trek_map?: TrekGlMap }).__trek_map
|
||||||
|
return !!m && Math.abs(m.getBearing() - b) < 0.5 && !m.isMoving()
|
||||||
|
}, bearing)
|
||||||
|
await page.evaluate(() => new Promise(r => requestAnimationFrame(() => requestAnimationFrame(r))))
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The GL map's bearing now. */
|
||||||
|
const mapBearing = (page: Page): Promise<number> =>
|
||||||
|
page.evaluate(() => (window as unknown as { __trek_map?: TrekGlMap }).__trek_map?.getBearing() ?? 0)
|
||||||
|
|
||||||
/** Wait until the GL map has its style, its tiles and a still camera. */
|
/** Wait until the GL map has its style, its tiles and a still camera. */
|
||||||
async function glMapIdle(page: Page): Promise<void> {
|
async function glMapIdle(page: Page): Promise<void> {
|
||||||
await page.waitForFunction(
|
await page.waitForFunction(
|
||||||
@@ -369,6 +395,8 @@ let found = ''
|
|||||||
let tourOnDay: TourOnDay | null = null
|
let tourOnDay: TourOnDay | null = null
|
||||||
let line = { index: 0, x: 0, y: 0 }
|
let line = { index: 0, x: 0, y: 0 }
|
||||||
let clickedTour = ''
|
let clickedTour = ''
|
||||||
|
/** Why the Dawarich connection could not be made (no media.env), for the one guide that needs it. */
|
||||||
|
let dawarichMissing: Error | null = null
|
||||||
|
|
||||||
const NEW_PLACE = 'Lunch stop'
|
const NEW_PLACE = 'Lunch stop'
|
||||||
|
|
||||||
@@ -421,6 +449,28 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// captureGuide hovers the target itself; this only makes sure the card
|
// captureGuide hovers the target itself; this only makes sure the card
|
||||||
// is up before the shot rather than a frame after it.
|
// is up before the shot rather than a frame after it.
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
|
// The card asks for the full photo, not the pin's thumb, and for some
|
||||||
|
// seeded places the photo proxy answers nothing: the card then shows a
|
||||||
|
// broken image. Walk the reachable photo pins until one card shows its
|
||||||
|
// photo, and keep that pin for the steps after this one.
|
||||||
|
const total = await photoPins(p).count()
|
||||||
|
for (let i = 0; i < total; i++) {
|
||||||
|
const candidate = photoPins(p).nth(i)
|
||||||
|
try {
|
||||||
|
await candidate.hover({ timeout: 1500 })
|
||||||
|
} catch {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if (!(await hoverCard(p).isVisible().catch(() => false))) continue
|
||||||
|
const loaded = await expect.poll(
|
||||||
|
() => hoverCard(p).locator('img').evaluateAll(imgs => imgs.length > 0 && imgs.every(img => (img as HTMLImageElement).complete && (img as HTMLImageElement).naturalWidth > 0)),
|
||||||
|
{ timeout: 6_000 },
|
||||||
|
).toBe(true).then(() => true, () => false)
|
||||||
|
if (!loaded) continue
|
||||||
|
await p.locator('#trek-map [data-help-pin]').evaluateAll(els => els.forEach(el => el.removeAttribute('data-help-pin')))
|
||||||
|
await candidate.evaluate(el => el.setAttribute('data-help-pin', ''))
|
||||||
|
break
|
||||||
|
}
|
||||||
await markerPin(p).hover()
|
await markerPin(p).hover()
|
||||||
await expect(hoverCard(p)).toBeVisible({ timeout: 10_000 })
|
await expect(hoverCard(p)).toBeVisible({ timeout: 10_000 })
|
||||||
},
|
},
|
||||||
@@ -451,6 +501,13 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: p => badged(p, 1),
|
target: p => badged(p, 1),
|
||||||
|
// The badge is the subject, not the pin's card: the pointer waits on
|
||||||
|
// an empty spot, so no hover card covers the numbers.
|
||||||
|
hover: async p => {
|
||||||
|
const box = await map(p).boundingBox()
|
||||||
|
if (!box) throw new Error('the map has no box')
|
||||||
|
await p.mouse.move(box.x + EMPTY.x, box.y + EMPTY.y)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Picture only, like the other drags in this family: HTML5 drag is what
|
// Picture only, like the other drags in this family: HTML5 drag is what
|
||||||
@@ -726,7 +783,10 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// along the Shinkansen and the walks through the cities vanish under the
|
// along the Shinkansen and the walks through the cities vanish under the
|
||||||
// pins, so the map is framed on a day before the button is pressed;
|
// pins, so the map is framed on a day before the button is pressed;
|
||||||
// nothing fits the map to the trail.
|
// nothing fits the map to the trail.
|
||||||
start: openOnTokyo,
|
start: async p => {
|
||||||
|
if (dawarichMissing) throw dawarichMissing
|
||||||
|
await openOnTokyo(p)
|
||||||
|
},
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
target: trailPill,
|
target: trailPill,
|
||||||
@@ -873,22 +933,28 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
{
|
{
|
||||||
// The turn itself is the map's own camera move rather than a synthetic
|
// The turn itself is the map's own camera move rather than a synthetic
|
||||||
// right-button drag: a drag has to start on bare canvas, and the pins,
|
// right-button drag: a drag has to start on bare canvas, and the pins,
|
||||||
// the two floating columns and the explore pill all sit over it. 35°
|
// the two floating columns and the explore pill all sit over it. 70°
|
||||||
// is enough for the streets to lie visibly askew and the arrow to lean.
|
// is enough for the streets to lie visibly askew and the arrow to lean.
|
||||||
|
// A fit of the map to the day (MapLibre's fitBounds) also puts the
|
||||||
|
// bearing back to north, and one can still land after the turn while the
|
||||||
|
// trip's data settles: the earlier pictures caught the map upright for
|
||||||
|
// exactly that reason. So the turn is made again until it holds through
|
||||||
|
// a settle, and once more right before the shot.
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await p.evaluate(() => {
|
for (let attempt = 0; attempt < 4; attempt++) {
|
||||||
const m = (window as unknown as { __trek_map?: TrekGlMap }).__trek_map
|
await turnMap(p, TURN)
|
||||||
if (!m) throw new Error('no GL map on the page')
|
await settle(p)
|
||||||
m.easeTo({ bearing: 35, pitch: 0, duration: 0 })
|
if (Math.abs((await mapBearing(p)) - TURN) < 0.5) break
|
||||||
})
|
}
|
||||||
await p.waitForFunction(() => {
|
|
||||||
const m = (window as unknown as { __trek_map?: TrekGlMap }).__trek_map
|
|
||||||
return !!m && Math.abs(m.getBearing() - 35) < 0.5 && !m.isMoving()
|
|
||||||
})
|
|
||||||
await settle(p)
|
|
||||||
},
|
},
|
||||||
target: compassPill,
|
target: compassPill,
|
||||||
// The loop: the map turning from north to the still's 35°, the arrow
|
hover: async p => {
|
||||||
|
await resetNorth(p).hover()
|
||||||
|
if (Math.abs((await mapBearing(p)) - TURN) >= 0.5) await turnMap(p, TURN)
|
||||||
|
// The arrow follows the bearing with a 100 ms transition.
|
||||||
|
await p.waitForTimeout(300)
|
||||||
|
},
|
||||||
|
// The loop: the map turning from north to the still's bearing, the arrow
|
||||||
// leaning with it, and a pointer dragging sideways as a right-button
|
// leaning with it, and a pointer dragging sideways as a right-button
|
||||||
// turn would. The camera is moved by the map's own API, a notch a
|
// turn would. The camera is moved by the map's own API, a notch a
|
||||||
// frame, for the reason the still's preparation gives.
|
// frame, for the reason the still's preparation gives.
|
||||||
@@ -915,7 +981,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
for (let i = 0; i < 3; i++) await frame()
|
for (let i = 0; i < 3; i++) await frame()
|
||||||
for (let i = 1; i <= 14; i++) {
|
for (let i = 1; i <= 14; i++) {
|
||||||
await p.mouse.move(x + (120 * i) / 14, y)
|
await p.mouse.move(x + (120 * i) / 14, y)
|
||||||
await turnTo((35 * i) / 14)
|
await turnTo((TURN * i) / 14)
|
||||||
await frame()
|
await frame()
|
||||||
}
|
}
|
||||||
for (let i = 0; i < 4; i++) await frame()
|
for (let i = 0; i < 4; i++) await frame()
|
||||||
@@ -952,7 +1018,13 @@ test.beforeAll(async ({ request }) => {
|
|||||||
tourOnDay = await ensureTourOnDay(request)
|
tourOnDay = await ensureTourOnDay(request)
|
||||||
// The recorded route: the addon on, the signed-in user connected to the
|
// The recorded route: the addon on, the signed-in user connected to the
|
||||||
// Dawarich from media.env, the synthetic recording of the trip uploaded.
|
// Dawarich from media.env, the synthetic recording of the trip uploaded.
|
||||||
await ensureDawarichConnection(request)
|
// Without media.env it cannot be made; the Dawarich guide then fails at its
|
||||||
|
// start with the reason, and every other guide of the file still runs.
|
||||||
|
try {
|
||||||
|
await ensureDawarichConnection(request)
|
||||||
|
} catch (err) {
|
||||||
|
dawarichMissing = err instanceof Error ? err : new Error(String(err))
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
test.afterAll(async ({ request }) => {
|
test.afterAll(async ({ request }) => {
|
||||||
|
|||||||
@@ -85,10 +85,25 @@ const weekday = (offset: number) => long(offset).split(',')[0]
|
|||||||
const hoursRow = (page: Page) => card(page).locator('button:has(svg.lucide-clock)')
|
const hoursRow = (page: Page) => card(page).locator('button:has(svg.lucide-clock)')
|
||||||
/** The hours block: the row and, once unfolded, the week in its place. */
|
/** The hours block: the row and, once unfolded, the week in its place. */
|
||||||
const hoursBox = (page: Page) => section(page, 'Opening Hours')
|
const hoursBox = (page: Page) => section(page, 'Opening Hours')
|
||||||
/** The round picture in the head; its name says whether a picture of your own is set. */
|
/** Edit, the dark button at the right end of the card's footer. */
|
||||||
const avatar = (page: Page) => card(page).getByRole('button', { name: /^(Upload image|Change image)$/ })
|
const editButton = (page: Page) => footer(page).getByRole('button', { name: 'Edit', exact: true })
|
||||||
/** The popover the picture opens when the place has photos among its files. */
|
/** Update, the place form's save button once the place exists. */
|
||||||
const imageChooser = (page: Page) => page.getByRole('dialog', { name: 'Choose a picture' })
|
const updateButton = (page: Page) => modal(page).getByRole('button', { name: 'Update', exact: true })
|
||||||
|
/** The three dots of the footer: Remove from Day and Delete live there. */
|
||||||
|
const moreButton = (page: Page) => footer(page).getByRole('button', { name: 'More options', exact: true })
|
||||||
|
/** Pick a picture in the place form: the tiles and the credit line under them. */
|
||||||
|
const picker = (page: Page) =>
|
||||||
|
modal(page).getByText('Pick a picture', { exact: true }).first().locator('xpath=ancestor::section[1]')
|
||||||
|
/** The picker's first tile, which takes a picture from the device. */
|
||||||
|
const uploadTile = (page: Page) => picker(page).getByRole('button', { name: 'Upload image', exact: true })
|
||||||
|
/** The fold chevron in the card's head; its name follows the state. */
|
||||||
|
const foldButton = (page: Page, name: 'Collapse' | 'Expand') => head(page).getByRole('button', { name, exact: true })
|
||||||
|
/** The place the off-map guide puts in: an address a traveller typed, no pick from the search. */
|
||||||
|
const OFF_MAP = { name: 'Ramen at Karasuma Oike', address: 'Karasuma Oike, Nakagyo Ward, Kyoto', lat: '35.0107', lng: '135.7596' }
|
||||||
|
const NO_COORDINATES = 'No coordinates, so not on the map'
|
||||||
|
/** The form's location block: the address with its hint, and the two coordinate fields. */
|
||||||
|
const coordinates = (page: Page) => modal(page).getByRole('group', { name: 'Coordinates', exact: true })
|
||||||
|
const locationPanel = (page: Page) => coordinates(page).locator('xpath=..')
|
||||||
/** The place form's hours editor, found by its remove button (only there while editing). */
|
/** The place form's hours editor, found by its remove button (only there while editing). */
|
||||||
const hoursEditor = (page: Page) =>
|
const hoursEditor = (page: Page) =>
|
||||||
modal(page).getByRole('button', { name: 'Remove opening hours' }).locator('xpath=ancestor::section[1]')
|
modal(page).getByRole('button', { name: 'Remove opening hours' }).locator('xpath=ancestor::section[1]')
|
||||||
@@ -175,7 +190,7 @@ async function openStop(page: Page, name: string): Promise<void> {
|
|||||||
|
|
||||||
// ── The seed over the API, for the cleanups ──────────────────────────────────
|
// ── The seed over the API, for the cleanups ──────────────────────────────────
|
||||||
|
|
||||||
type ApiPlace = { id: number; name: string; lat?: number | null; lng?: number | null }
|
type ApiPlace = { id: number; name: string; lat?: number | null; lng?: number | null; image_url?: string | null }
|
||||||
type ApiAssignment = { id: number; place_id: number }
|
type ApiAssignment = { id: number; place_id: number }
|
||||||
|
|
||||||
async function tripPlaces(page: Page): Promise<ApiPlace[]> {
|
async function tripPlaces(page: Page): Promise<ApiPlace[]> {
|
||||||
@@ -216,6 +231,28 @@ const closeModal = async (page: Page): Promise<void> => {
|
|||||||
|
|
||||||
const only = (target: (p: Page) => Locator) => ({ target })
|
const only = (target: (p: Page) => Locator) => ({ target })
|
||||||
|
|
||||||
|
/** Open the place's form from the card. */
|
||||||
|
async function openEditor(page: Page): Promise<void> {
|
||||||
|
await editButton(page).click()
|
||||||
|
await expect(updateButton(page)).toBeVisible()
|
||||||
|
await settle(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Save the form and wait until the place carries a picture of its own. */
|
||||||
|
async function saveWithPicture(page: Page, name: string): Promise<void> {
|
||||||
|
await updateButton(page).click()
|
||||||
|
await expect(modal(page)).toHaveCount(0, { timeout: 30_000 })
|
||||||
|
await expect.poll(async () => (await findPlace(page, name))?.image_url ?? null, { timeout: 30_000 }).toBeTruthy()
|
||||||
|
await settle(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
async function removeOffMapPlace(page: Page): Promise<void> {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
for (const place of (await tripPlaces(page)).filter(p => p.name === OFF_MAP.name)) {
|
||||||
|
await page.request.delete(`/api/trips/${tripId}/places/${place.id}`)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Take a place out of every collection it sits in.
|
* Take a place out of every collection it sits in.
|
||||||
*
|
*
|
||||||
@@ -300,26 +337,70 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
if (place) await p.request.delete(`/api/trips/${tripId}/places/${place.id}/rating`)
|
if (place) await p.request.delete(`/api/trips/${tripId}/places/${place.id}/rating`)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'place-image': {
|
'fold-place-card': {
|
||||||
guide: guide('place-image'),
|
guide: guide('fold-place-card'),
|
||||||
start: p => openTrip(p, { day: null }),
|
// From the stop, like the hero: the map then sits close enough that the
|
||||||
|
// highlighted marker is in the folded bar's picture.
|
||||||
|
start: async p => {
|
||||||
|
await openTrip(p, { day: null })
|
||||||
|
await selectDay(p, 1)
|
||||||
|
await openStop(p, 'Senso-ji Temple')
|
||||||
|
},
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
target: p => row(p, 'Arashiyama Bamboo Grove'),
|
target: p => foldButton(p, 'Collapse'),
|
||||||
act: p => openPlace(p, 'Arashiyama Bamboo Grove'),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
target: avatar,
|
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await card(p).locator('input[accept*="image/jpeg"]').setInputFiles(await coverFixture())
|
await foldButton(p, 'Collapse').click()
|
||||||
await expect(card(p).getByRole('button', { name: 'Remove image' })).toBeVisible({ timeout: 30_000 })
|
await expect(foldButton(p, 'Expand')).toBeVisible()
|
||||||
|
await expect(footer(p)).toBeHidden()
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
only(head),
|
{
|
||||||
only(p => row(p, 'Arashiyama Bamboo Grove')),
|
// The map moved the way the step says, which brings the marker down to the bar.
|
||||||
|
prepare: async p => {
|
||||||
|
await p.mouse.move(960, 300)
|
||||||
|
await p.mouse.down()
|
||||||
|
await p.mouse.move(960, 450, { steps: 8 })
|
||||||
|
await p.mouse.move(960, 600, { steps: 8 })
|
||||||
|
await p.mouse.up()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: head,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => foldButton(p, 'Expand'),
|
||||||
|
act: async p => {
|
||||||
|
await foldButton(p, 'Expand').click()
|
||||||
|
await expect(footer(p)).toBeVisible()
|
||||||
|
},
|
||||||
|
},
|
||||||
],
|
],
|
||||||
cleanup: p => patchPlace(p, 'Arashiyama Bamboo Grove', { image_url: null }),
|
},
|
||||||
|
'place-image': {
|
||||||
|
guide: guide('place-image'),
|
||||||
|
start: async p => {
|
||||||
|
await openTrip(p, { day: null })
|
||||||
|
await openPlace(p, 'Arashiyama Bamboo Grove')
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{ target: editButton, act: openEditor },
|
||||||
|
{
|
||||||
|
target: uploadTile,
|
||||||
|
act: async p => {
|
||||||
|
await picker(p).locator('input[type="file"]').setInputFiles(await coverFixture())
|
||||||
|
await expect(uploadTile(p)).toHaveAttribute('aria-pressed', 'true', { timeout: 30_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Pointed at the label, not a tile: a hovered tile puts its own credit under the grid.
|
||||||
|
{ target: picker, hover: p => picker(p).getByText('Pick a picture', { exact: true }).hover() },
|
||||||
|
{ target: updateButton, act: p => saveWithPicture(p, 'Arashiyama Bamboo Grove') },
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
await patchPlace(p, 'Arashiyama Bamboo Grove', { image_url: null })
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'place-image-from-file': {
|
'place-image-from-file': {
|
||||||
guide: guide('place-image-from-file'),
|
guide: guide('place-image-from-file'),
|
||||||
@@ -337,27 +418,28 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
target: p => section(p, 'Files'),
|
target: p => section(p, 'Files'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: avatar,
|
prepare: async p => {
|
||||||
act: async p => {
|
await openEditor(p)
|
||||||
await avatar(p).click()
|
// The attached photo's tile loads as a blob one request later.
|
||||||
await expect(imageChooser(p)).toBeVisible()
|
await expect(picker(p).getByRole('button', { name: PHOTO_FILE, exact: true }).locator('img')).toBeVisible({ timeout: 20_000 })
|
||||||
// The thumbnails load as blobs one request later.
|
|
||||||
await expect(imageChooser(p).locator('img').first()).toBeVisible({ timeout: 20_000 })
|
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
|
target: picker,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => imageChooser(p).getByRole('button', { name: PHOTO_FILE, exact: true }),
|
target: p => picker(p).getByRole('button', { name: PHOTO_FILE, exact: true }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await imageChooser(p).getByRole('button', { name: PHOTO_FILE, exact: true }).click()
|
await picker(p).getByRole('button', { name: PHOTO_FILE, exact: true }).click()
|
||||||
await expect(imageChooser(p)).toHaveCount(0)
|
await expect(picker(p).getByRole('button', { name: PHOTO_FILE, exact: true })).toHaveAttribute('aria-pressed', 'true')
|
||||||
await expect(card(p).getByRole('button', { name: 'Remove image' })).toBeVisible({ timeout: 30_000 })
|
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
only(head),
|
{ target: updateButton, act: p => saveWithPicture(p, PHOTO_PLACE) },
|
||||||
],
|
],
|
||||||
cleanup: p => removePlacePhoto(p.request),
|
cleanup: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
await removePlacePhoto(p.request)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
'place-own-hours': {
|
'place-own-hours': {
|
||||||
guide: guide('place-own-hours'),
|
guide: guide('place-own-hours'),
|
||||||
@@ -426,6 +508,61 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await patchPlace(p, HOURS_PLACE, { phone: '', email: '', opening_hours: '' })
|
await patchPlace(p, HOURS_PLACE, { phone: '', email: '', opening_hours: '' })
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'place-off-map': {
|
||||||
|
guide: guide('place-off-map'),
|
||||||
|
// Put in over the API before the trip opens, the way a traveller leaves it:
|
||||||
|
// a name and a typed address, never picked from the search.
|
||||||
|
start: async p => {
|
||||||
|
await removeOffMapPlace(p)
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
const res = await p.request.post(`/api/trips/${tripId}/places`, { data: { name: OFF_MAP.name, address: OFF_MAP.address } })
|
||||||
|
if (!res.ok()) throw new Error(`could not add ${OFF_MAP.name}: ${res.status()} ${await res.text()}`)
|
||||||
|
await openTrip(p, { day: null })
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => row(p, OFF_MAP.name),
|
||||||
|
act: async p => {
|
||||||
|
await openPlace(p, OFF_MAP.name)
|
||||||
|
await expect(head(p).getByText(NO_COORDINATES)).toBeVisible()
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Hovered for the picture, which brings up the tooltip with the way out.
|
||||||
|
only(p => head(p).getByText(NO_COORDINATES)),
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await openEditor(p)
|
||||||
|
await expect(locationPanel(p).getByText(/has no coordinates yet/)).toBeVisible()
|
||||||
|
},
|
||||||
|
target: locationPanel,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Filled before the picture: the step is about the two values going in.
|
||||||
|
prepare: async p => {
|
||||||
|
await typeInto(p, coordinates(p).getByLabel('Latitude', { exact: true }), OFF_MAP.lat)
|
||||||
|
await typeInto(p, coordinates(p).getByLabel('Longitude', { exact: true }), OFF_MAP.lng)
|
||||||
|
await expect(locationPanel(p).getByText(/has no coordinates yet/)).toHaveCount(0)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: coordinates,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: updateButton,
|
||||||
|
act: async p => {
|
||||||
|
await updateButton(p).click()
|
||||||
|
await expect(modal(p)).toHaveCount(0, { timeout: 20_000 })
|
||||||
|
await expect(head(p).getByText(NO_COORDINATES)).toHaveCount(0)
|
||||||
|
// Picked again, so the map goes to the new marker for the result.
|
||||||
|
await closeCard(p)
|
||||||
|
await openPlace(p, OFF_MAP.name)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
await removeOffMapPlace(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
'place-day-assign': {
|
'place-day-assign': {
|
||||||
guide: guide('place-day-assign'),
|
guide: guide('place-day-assign'),
|
||||||
start: p => openTrip(p, { day: null }),
|
start: p => openTrip(p, { day: null }),
|
||||||
@@ -445,7 +582,8 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
target: p => footer(p).getByRole('button', { name: 'Add to Day' }),
|
target: p => footer(p).getByRole('button', { name: 'Add to Day' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await footer(p).getByRole('button', { name: 'Add to Day' }).click()
|
await footer(p).getByRole('button', { name: 'Add to Day' }).click()
|
||||||
await expect(footer(p).getByRole('button', { name: 'Remove from Day' })).toBeVisible({ timeout: 20_000 })
|
await expect(stop(p, SPARE)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await expect(footer(p).getByRole('button', { name: 'Add to Day' })).toHaveCount(0)
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -453,9 +591,15 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// last step's picture, and the arrow already says what to do.
|
// last step's picture, and the arrow already says what to do.
|
||||||
{ target: p => stop(p, SPARE), dropTo: p => stop(p, 'Arashiyama Bamboo Grove') },
|
{ target: p => stop(p, SPARE), dropTo: p => stop(p, 'Arashiyama Bamboo Grove') },
|
||||||
{
|
{
|
||||||
target: p => footer(p).getByRole('button', { name: 'Remove from Day' }),
|
// Remove from Day waits behind the three dots, so the menu is open for the picture.
|
||||||
|
prepare: async p => {
|
||||||
|
await moreButton(p).click()
|
||||||
|
await expect(p.getByRole('menu').getByRole('button', { name: 'Remove from Day' })).toBeVisible()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => p.getByRole('menu').getByRole('button', { name: 'Remove from Day' }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await footer(p).getByRole('button', { name: 'Remove from Day' }).click()
|
await p.getByRole('menu').getByRole('button', { name: 'Remove from Day' }).click()
|
||||||
await expect(footer(p).getByRole('button', { name: 'Add to Day' })).toBeVisible({ timeout: 20_000 })
|
await expect(footer(p).getByRole('button', { name: 'Add to Day' })).toBeVisible({ timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
@@ -623,6 +767,8 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
act: async p => {
|
act: async p => {
|
||||||
await p.keyboard.press('Escape')
|
await p.keyboard.press('Escape')
|
||||||
await expect(p.getByRole('menu')).toHaveCount(0)
|
await expect(p.getByRole('menu')).toHaveCount(0)
|
||||||
|
// Escape leaves the focus ring on Navigation, which the next picture would show.
|
||||||
|
await p.evaluate(() => (document.activeElement as HTMLElement | null)?.blur())
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
only(p => footer(p).getByRole('button', { name: 'Open Website' })),
|
only(p => footer(p).getByRole('button', { name: 'Open Website' })),
|
||||||
|
|||||||
@@ -3,7 +3,9 @@ import { captureGuide, captureHero, beat, typeInto, settle, dragLoop, VIEWPORT,
|
|||||||
import { seededTrip, gpxFixture } from './fixtures'
|
import { seededTrip, gpxFixture } from './fixtures'
|
||||||
import { openTrip, modal, dialog, confirmDialog } from './trip-shared'
|
import { openTrip, modal, dialog, confirmDialog } from './trip-shared'
|
||||||
import { disconnectDawarich } from './external'
|
import { disconnectDawarich } from './external'
|
||||||
import { ensureDawarichStays, undoDawarichStays, setTours } from './fixtures-trip-places'
|
import {
|
||||||
|
ensureDawarichStays, undoDawarichStays, setTours, pinsKmlFixture, KML_PINS, ensureGuideTags, removeGuideTags, NEW_TAG,
|
||||||
|
} from './fixtures-trip-places'
|
||||||
import { tripPlacesContext, tripPlacesGuides } from '../../src/help/contexts/tripPlaces'
|
import { tripPlacesContext, tripPlacesGuides } from '../../src/help/contexts/tripPlaces'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
|
|
||||||
@@ -11,10 +13,10 @@ import type { HelpGuide } from '../../src/help/types'
|
|||||||
* Actions for the places column of a trip, keyed by the ids in
|
* Actions for the places column of a trip, keyed by the ids in
|
||||||
* `src/help/contexts/tripPlaces.ts`. They run on the seeded "Autumn in Japan"
|
* `src/help/contexts/tripPlaces.ts`. They run on the seeded "Autumn in Japan"
|
||||||
* with the Tours add-on on, as on every install: the column has the Places and
|
* with the Tours add-on on, as on every install: the column has the Places and
|
||||||
* Tours switch, no Import file and no Tracks filter. The file import is
|
* Tours switch and no Tracks filter, and Import file sends a file with a line
|
||||||
* pictured with Tours off, and the Dawarich stays with a connection, each for
|
* to the Tours import first. The Dawarich stays are pictured with a connection
|
||||||
* its own guide only; what a guide creates or switches it takes back again in
|
* for their own guide only; what a guide creates or switches it takes back
|
||||||
* `cleanup`, so the next one starts the same.
|
* again in `cleanup`, so the next one starts the same.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
const guide = (id: string): HelpGuide => {
|
const guide = (id: string): HelpGuide => {
|
||||||
@@ -45,7 +47,7 @@ const head = (page: Page) =>
|
|||||||
page.getByRole('button', { name: 'Import Places' }).locator('xpath=ancestor::div[contains(@class,"flex-col")][1]')
|
page.getByRole('button', { name: 'Import Places' }).locator('xpath=ancestor::div[contains(@class,"flex-col")][1]')
|
||||||
/** The list import's entry: List Import, Google List while Google is the only list provider. */
|
/** The list import's entry: List Import, Google List while Google is the only list provider. */
|
||||||
const LIST_IMPORT = /^(Google List|List Import)$/
|
const LIST_IMPORT = /^(Google List|List Import)$/
|
||||||
/** The import button's menu: the list import, and Import file where Tours is off. */
|
/** The import button's menu: Import file and the list import. */
|
||||||
const importMenu = (page: Page) =>
|
const importMenu = (page: Page) =>
|
||||||
page.locator('.trek-popover-enter').filter({ has: page.getByRole('button', { name: LIST_IMPORT }) }).last()
|
page.locator('.trek-popover-enter').filter({ has: page.getByRole('button', { name: LIST_IMPORT }) }).last()
|
||||||
/** The Show dropdown (All, Unplanned, Planned; Tracks only with Tours off) and the list it opens. */
|
/** The Show dropdown (All, Unplanned, Planned; Tracks only with Tours off) and the list it opens. */
|
||||||
@@ -72,8 +74,30 @@ const importFileDialog = (page: Page) =>
|
|||||||
page.getByRole('dialog').filter({ has: page.locator('input[type="file"][accept*=".gpx"]') })
|
page.getByRole('dialog').filter({ has: page.locator('input[type="file"][accept*=".gpx"]') })
|
||||||
/** ListImportModal, recognised by the link box. */
|
/** ListImportModal, recognised by the link box. */
|
||||||
const listImportDialog = (page: Page) => page.getByRole('dialog').filter({ has: page.getByPlaceholder(/goo\.gl|naver/) })
|
const listImportDialog = (page: Page) => page.getByRole('dialog').filter({ has: page.getByPlaceholder(/goo\.gl|naver/) })
|
||||||
/** The drop box of the file dialog: the dashed button that opens the file picker. */
|
/** The Tours import preview a file with a line opens, recognised by its points switch. */
|
||||||
const dropBox = (page: Page) => importFileDialog(page).locator('button.border-dashed').first()
|
const tourPreview = (page: Page) => page.getByRole('dialog').filter({ has: page.getByTestId('gpx-preview-points') })
|
||||||
|
/**
|
||||||
|
* Import file with Tours on: the Tours import's own file picker, a detached
|
||||||
|
* input, so the file goes in through the chooser it opens.
|
||||||
|
*/
|
||||||
|
async function pickImportFile(page: Page, file: string): Promise<void> {
|
||||||
|
const [chooser] = await Promise.all([
|
||||||
|
page.waitForEvent('filechooser'),
|
||||||
|
importMenu(page).getByRole('button', { name: 'Import file' }).click(),
|
||||||
|
])
|
||||||
|
await chooser.setFiles(file)
|
||||||
|
}
|
||||||
|
/** The tag guide's place, and the places that carry Must see before it starts. */
|
||||||
|
const TAGGED = 'Shibuya Crossing'
|
||||||
|
const ALREADY_TAGGED = ['Senso-ji Temple', 'Kinkaku-ji']
|
||||||
|
/** The group of tag pills in the place form. */
|
||||||
|
const tagGroup = (page: Page) => modal(page).getByRole('group', { name: 'Tags', exact: true })
|
||||||
|
/** The Tags card of the place form: the panel around the section with the pills. */
|
||||||
|
const tagsCard = (page: Page) => tagGroup(page).locator('xpath=ancestor::section[1]/..')
|
||||||
|
/** A tag's pill: its name button, which ticks it for the place. */
|
||||||
|
const tagPill = (page: Page, name: string) => tagGroup(page).getByRole('button', { name, exact: true })
|
||||||
|
const newTagField = (page: Page) => modal(page).getByRole('textbox', { name: 'New tag' })
|
||||||
|
const palette = (page: Page) => modal(page).getByRole('group', { name: 'Colour of Rainy day' })
|
||||||
/** The column itself: the header block around the search box. */
|
/** The column itself: the header block around the search box. */
|
||||||
const column = (page: Page) => searchBox(page).locator('xpath=ancestor::div[contains(@class,"scroll") or @data-places-sidebar][1]')
|
const column = (page: Page) => searchBox(page).locator('xpath=ancestor::div[contains(@class,"scroll") or @data-places-sidebar][1]')
|
||||||
|
|
||||||
@@ -496,11 +520,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
'import-places-file': {
|
'import-places-file': {
|
||||||
guide: guide('import-places-file'),
|
guide: guide('import-places-file'),
|
||||||
// Import file is only in the menu of an install with the Tours add-on off.
|
start: p => openTrip(p),
|
||||||
start: async p => {
|
|
||||||
await setTours(p.request, false)
|
|
||||||
await openTrip(p)
|
|
||||||
},
|
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
@@ -509,35 +529,125 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await beat(p, 300)
|
await beat(p, 300)
|
||||||
},
|
},
|
||||||
target: p => importMenu(p).getByRole('button', { name: 'Import file' }),
|
target: p => importMenu(p).getByRole('button', { name: 'Import file' }),
|
||||||
|
// A GPX with a track and two waypoints: the Tours import takes it first.
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await importMenu(p).getByRole('button', { name: 'Import file' }).click()
|
await pickImportFile(p, gpxFixture('arashiyama-loop'))
|
||||||
await expect(importFileDialog(p)).toBeVisible()
|
await expect(tourPreview(p)).toBeVisible({ timeout: 30_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => p.getByTestId('gpx-preview-points'),
|
||||||
|
// Closing the preview stores nothing; the pins of the next step are what gets imported.
|
||||||
|
act: async p => {
|
||||||
|
await tourPreview(p).getByRole('button', { name: 'Cancel', exact: true }).click()
|
||||||
|
await expect(tourPreview(p)).toHaveCount(0)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// A KML of pins only has no line for the Tours import, so Import file opens with it.
|
||||||
|
prepare: async p => {
|
||||||
|
await p.getByRole('button', { name: 'Import Places' }).click()
|
||||||
|
await expect(importMenu(p)).toBeVisible()
|
||||||
|
await pickImportFile(p, pinsKmlFixture())
|
||||||
|
await expect(importFileDialog(p).getByText('Points (Placemarks)')).toBeVisible({ timeout: 30_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: importFileDialog,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => importFileDialog(p).getByRole('button', { name: 'Import', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await importFileDialog(p).getByRole('button', { name: 'Import', exact: true }).click()
|
||||||
|
// A KML answer keeps the dialog open with its summary; close it to show the new rows.
|
||||||
|
await expect(row(p, KML_PINS[0][0]).or(importFileDialog(p).getByText(/^Placemarks: /)).first())
|
||||||
|
.toBeVisible({ timeout: 60_000 })
|
||||||
|
if (await importFileDialog(p).isVisible().catch(() => false)) {
|
||||||
|
await importFileDialog(p).getByRole('button', { name: 'Cancel', exact: true }).click()
|
||||||
|
await expect(importFileDialog(p)).toHaveCount(0)
|
||||||
|
}
|
||||||
|
await expect(row(p, KML_PINS[0][0])).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: p => deleteByName(p, ...KML_PINS.map(([name]) => name)),
|
||||||
|
},
|
||||||
|
'place-tags': {
|
||||||
|
guide: guide('place-tags'),
|
||||||
|
start: async p => {
|
||||||
|
await ensureGuideTags(p.request, seededTrip().tripId, ALREADY_TAGGED)
|
||||||
|
await openTrip(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await row(p, TAGGED).click({ button: 'right' })
|
||||||
|
await menu(p).getByRole('button', { name: 'Edit' }).click()
|
||||||
|
await expect(modal(p).getByPlaceholder('e.g. Eiffel Tower')).toHaveValue(TAGGED)
|
||||||
|
await tagPill(p, 'Must see').click()
|
||||||
|
await expect(tagPill(p, 'Must see')).toHaveAttribute('aria-pressed', 'true')
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: tagsCard,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await typeInto(p, newTagField(p), NEW_TAG)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => newTagField(p).locator('xpath=..'),
|
||||||
|
act: async p => {
|
||||||
|
await newTagField(p).press('Enter')
|
||||||
|
await expect(tagPill(p, NEW_TAG)).toHaveAttribute('aria-pressed', 'true', { timeout: 15_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
await importFileDialog(p).locator('input[type="file"]').setInputFiles(gpxFixture('arashiyama-loop'))
|
await modal(p).getByRole('button', { name: 'Colour of Rainy day' }).click()
|
||||||
await expect(importFileDialog(p).getByText('Tracks (with path geometry)')).toBeVisible({ timeout: 15_000 })
|
await expect(palette(p)).toBeVisible()
|
||||||
|
await beat(p, 300)
|
||||||
|
},
|
||||||
|
// The palette; the pill it colours sits right above it in the frame.
|
||||||
|
target: palette,
|
||||||
|
hover: p => palette(p).getByRole('button', { name: '#06b6d4' }).hover(),
|
||||||
|
act: async p => {
|
||||||
|
await palette(p).getByRole('button', { name: '#06b6d4' }).click()
|
||||||
|
await expect(palette(p)).toHaveCount(0)
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: importFileDialog,
|
|
||||||
},
|
},
|
||||||
only(dropBox),
|
|
||||||
{
|
{
|
||||||
target: p => importFileDialog(p).getByRole('button', { name: 'Import', exact: true }),
|
target: p => modal(p).getByRole('button', { name: 'Update', exact: true }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await importFileDialog(p).getByRole('button', { name: 'Import', exact: true }).click()
|
await modal(p).getByRole('button', { name: 'Update', exact: true }).click()
|
||||||
await expect(importFileDialog(p)).toHaveCount(0, { timeout: 30_000 })
|
await expect(modal(p)).toHaveCount(0, { timeout: 15_000 })
|
||||||
await expect(row(p, 'Arashiyama loop')).toBeVisible({ timeout: 20_000 })
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await categoryTrigger(p).click()
|
||||||
|
await expect(categoryList(p)).toBeVisible()
|
||||||
|
await categoryList(p).getByRole('button', { name: 'Must see', exact: true }).click()
|
||||||
|
await expect(categoryList(p).getByRole('button', { name: 'Clear filter' })).toBeVisible()
|
||||||
|
// The tags are at the foot of the list, under the categories.
|
||||||
|
await categoryList(p).evaluate(el => { el.scrollTop = el.scrollHeight })
|
||||||
|
await beat(p, 300)
|
||||||
|
},
|
||||||
|
target: categoryList,
|
||||||
|
// The list closes on a second click of its trigger; the filter stays.
|
||||||
|
act: async p => {
|
||||||
|
await categoryTrigger(p).click()
|
||||||
|
await expect(categoryList(p)).toHaveCount(0)
|
||||||
|
await expect(row(p, TAGGED)).toBeVisible()
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
cleanup: async p => {
|
cleanup: p => removeGuideTags(p.request, seededTrip().tripId),
|
||||||
await deleteByName(p, 'Arashiyama loop', 'Togetsukyo Bridge', 'Okochi Sanso Villa')
|
|
||||||
await setTours(p.request, true)
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
'import-places-list': {
|
'import-places-list': {
|
||||||
guide: guide('import-places-list'),
|
guide: guide('import-places-list'),
|
||||||
@@ -549,7 +659,6 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await expect(importMenu(p)).toBeVisible()
|
await expect(importMenu(p)).toBeVisible()
|
||||||
await beat(p, 300)
|
await beat(p, 300)
|
||||||
},
|
},
|
||||||
// With Tours on, the list import is the menu's only entry.
|
|
||||||
target: p => importMenu(p).getByRole('button', { name: LIST_IMPORT }),
|
target: p => importMenu(p).getByRole('button', { name: LIST_IMPORT }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await importMenu(p).getByRole('button', { name: LIST_IMPORT }).click()
|
await importMenu(p).getByRole('button', { name: LIST_IMPORT }).click()
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import { captureGuide, captureHero, settle, dragLoop, nudgeClock, VIEWPORT, type
|
|||||||
import { seededTrip, ensureRoadtripFixtures } from './fixtures'
|
import { seededTrip, ensureRoadtripFixtures } from './fixtures'
|
||||||
import { openTrip, modal, dialog } from './trip-shared'
|
import { openTrip, modal, dialog } from './trip-shared'
|
||||||
import {
|
import {
|
||||||
FERRY, FUEL_STOP, GOOGLE_ROUTE, HAZARD_TITLE, assignmentsOn, ensureFerry, ensureFuelStop, hideHazards, overnightFlight, placeIdOf,
|
FERRY, FUEL_STOP, GOOGLE_ROUTE, HAZARD_TITLE, PHOTO_STOP, assignmentsOn, ensureFerry, ensureFuelStop, ensurePhotoStop, hideHazards,
|
||||||
removeFerry, removeFuelStop, removeImportedStops, removeNightAt, restoreFlight, stubGooglePreview, stubHazards,
|
overnightFlight, placeIdOf, removeFerry, removeFuelStop, removeImportedStops, removeNightAt, removePhotoStop, restoreFlight,
|
||||||
|
stubGooglePreview, stubHazards,
|
||||||
} from './fixtures-trip-roadtrip'
|
} from './fixtures-trip-roadtrip'
|
||||||
import { tripRoadtripContext, tripRoadtripGuides } from '../../src/help/contexts/tripRoadtrip'
|
import { tripRoadtripContext, tripRoadtripGuides } from '../../src/help/contexts/tripRoadtrip'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
@@ -89,14 +90,18 @@ const addFuelStop = (page: Page) => dryBand(page).getByRole('button', { name: /a
|
|||||||
const viaHandle = (page: Page) => page.locator('.leaflet-marker-icon.leaflet-marker-draggable').first()
|
const viaHandle = (page: Page) => page.locator('.leaflet-marker-icon.leaflet-marker-draggable').first()
|
||||||
/** The Search button's card: Looking for, the day, Within, Search and Manual. */
|
/** The Search button's card: Looking for, the day, Within, Search and Manual. */
|
||||||
const searchCard = (page: Page) => corridor(page).getByRole('button', { name: 'Search', exact: true }).locator('xpath=../..')
|
const searchCard = (page: Page) => corridor(page).getByRole('button', { name: 'Search', exact: true }).locator('xpath=../..')
|
||||||
/** A hotel hit: its add button is the bed, Add as an overnight stay. */
|
/**
|
||||||
|
* A hotel hit: its add button is the bed, Add as an overnight stay. The last one,
|
||||||
|
* because the hits run in the order the drive passes them: the first lies a few
|
||||||
|
* kilometres into the morning, and a night there would read as a hotel at 10:30.
|
||||||
|
*/
|
||||||
const nightButton = (page: Page) =>
|
const nightButton = (page: Page) =>
|
||||||
corridor(page).getByRole('button', { name: 'Add as an overnight stay', exact: true }).first()
|
corridor(page).getByRole('button', { name: 'Add as an overnight stay', exact: true }).last()
|
||||||
const nightRow = (page: Page) =>
|
const nightRow = (page: Page) =>
|
||||||
corridor(page)
|
corridor(page)
|
||||||
.getByRole('listitem')
|
.getByRole('listitem')
|
||||||
.filter({ has: page.getByRole('button', { name: 'Add as an overnight stay', exact: true }) })
|
.filter({ has: page.getByRole('button', { name: 'Add as an overnight stay', exact: true }) })
|
||||||
.first()
|
.last()
|
||||||
/**
|
/**
|
||||||
* The battery badge of a refuelling stop. It has no label of its own: its name
|
* The battery badge of a refuelling stop. It has no label of its own: its name
|
||||||
* is its figure, "80 %", or the "+" it shows while nothing says how full.
|
* is its figure, "80 %", or the "+" it shows while nothing says how full.
|
||||||
@@ -112,6 +117,15 @@ const selectMenu = (page: Page) => page.locator('body > div[style*="99999"]').la
|
|||||||
/** A warning area drawn by the hazard layer, in the warning colour. */
|
/** A warning area drawn by the hazard layer, in the warning colour. */
|
||||||
const hazardArea = (page: Page) => page.locator('.leaflet-overlay-pane path[stroke="var(--warning)"]').first()
|
const hazardArea = (page: Page) => page.locator('.leaflet-overlay-pane path[stroke="var(--warning)"]').first()
|
||||||
const hazardPopup = (page: Page) => page.locator('.leaflet-popup.trek-hazard-popup')
|
const hazardPopup = (page: Page) => page.locator('.leaflet-popup.trek-hazard-popup')
|
||||||
|
/** Edit in the footer of the card the photo stop opens over the map. */
|
||||||
|
const cardEdit = (page: Page) =>
|
||||||
|
placeCardHead(page, PHOTO_STOP)
|
||||||
|
.locator('xpath=ancestor::*[.//button[@aria-label="Edit"]][1]')
|
||||||
|
.getByRole('button', { name: 'Edit', exact: true })
|
||||||
|
/** The picture in the stop dialog's head: the gallery trigger, named Show photos. */
|
||||||
|
const stopDialogPhoto = (page: Page) => modal(page).getByRole('button', { name: 'Show photos', exact: true })
|
||||||
|
/** The full-screen gallery the picture opens; portalled to the body, labelled like its trigger. */
|
||||||
|
const lightbox = (page: Page) => page.locator('div[role="dialog"][aria-modal="true"][aria-label="Show photos"]')
|
||||||
|
|
||||||
// ── Getting there ─────────────────────────────────────────────────────────────
|
// ── Getting there ─────────────────────────────────────────────────────────────
|
||||||
|
|
||||||
@@ -182,8 +196,8 @@ type RoutePoint = { leg: number; x: number; y: number }
|
|||||||
* what sits in the middle of it is usually somebody else's pin.
|
* what sits in the middle of it is usually somebody else's pin.
|
||||||
*
|
*
|
||||||
* The drawn casing is not what takes the click: it is non-interactive, and an
|
* The drawn casing is not what takes the click: it is non-interactive, and an
|
||||||
* invisible band over the same line (`RouteHitBand`, a transparent stroke with
|
* invisible band over the same line (`RouteHitBand`, a transparent stroke)
|
||||||
* the class `cursor-copy`) catches it instead. So the point is read off the
|
* catches it instead. So the point is read off the
|
||||||
* casing, which is the line the reader sees and the one the ring sits on, and
|
* casing, which is the line the reader sees and the one the ring sits on, and
|
||||||
* the hit test asks for the band of that same leg. Both are drawn from the same
|
* the hit test asks for the band of that same leg. Both are drawn from the same
|
||||||
* positions, so their `d` is the same string.
|
* positions, so their `d` is the same string.
|
||||||
@@ -206,7 +220,8 @@ async function routePoints(page: Page): Promise<RoutePoint[]> {
|
|||||||
// The two panels float over the map; a point under one of them is not clickable.
|
// The two panels float over the map; a point under one of them is not clickable.
|
||||||
if (x < 430 || x > 1550 || y < 220 || y > 950) continue
|
if (x < 430 || x > 1550 || y < 220 || y > 950) continue
|
||||||
const hit = document.elementFromPoint(x, y)
|
const hit = document.elementFromPoint(x, y)
|
||||||
const ownBand = hit instanceof SVGPathElement && hit.classList.contains('cursor-copy') && hit.getAttribute('d') === d
|
// By its transparent stroke: react-leaflet no longer carries the band's class onto the path.
|
||||||
|
const ownBand = hit instanceof SVGPathElement && hit.getAttribute('stroke') === 'transparent' && hit.getAttribute('d') === d
|
||||||
if (hit === path || ownBand) found.push({ leg, x, y })
|
if (hit === path || ownBand) found.push({ leg, x, y })
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
@@ -229,8 +244,11 @@ async function aimAtLeg(page: Page): Promise<void> {
|
|||||||
const points = await routePoints(page)
|
const points = await routePoints(page)
|
||||||
if (points.length === 0) {
|
if (points.length === 0) {
|
||||||
const legs = await page.locator('.leaflet-overlay-pane svg path[stroke="#0a5cc2"]').count()
|
const legs = await page.locator('.leaflet-overlay-pane svg path[stroke="#0a5cc2"]').count()
|
||||||
const bands = await page.locator('.leaflet-overlay-pane svg path.cursor-copy').count()
|
const bands = await page.locator('.leaflet-overlay-pane svg path[stroke="transparent"]').count()
|
||||||
throw new Error(`no drawn leg is reachable on the map (${legs} drawn legs, ${bands} click bands)`)
|
const kinds = await page.evaluate(() =>
|
||||||
|
[...new Set(Array.from(document.querySelectorAll('.leaflet-overlay-pane svg path')).map(el => `${el.getAttribute('stroke')}|${el.getAttribute('class')}`))].join(', '),
|
||||||
|
)
|
||||||
|
throw new Error(`no drawn leg is reachable on the map (${legs} drawn legs, ${bands} click bands; paths: ${kinds})`)
|
||||||
}
|
}
|
||||||
const counts = new Map<number, number>()
|
const counts = new Map<number, number>()
|
||||||
for (const point of points) counts.set(point.leg, (counts.get(point.leg) ?? 0) + 1)
|
for (const point of points) counts.set(point.leg, (counts.get(point.leg) ?? 0) + 1)
|
||||||
@@ -270,12 +288,53 @@ async function aimAtHazard(page: Page): Promise<void> {
|
|||||||
const top = document.elementFromPoint(box.left + box.width / 2, box.top + box.height / 2)
|
const top = document.elementFromPoint(box.left + box.width / 2, box.top + box.height / 2)
|
||||||
const why = `area at ${Math.round(box.left)},${Math.round(box.top)} ${Math.round(box.width)}x${Math.round(box.height)}, ` +
|
const why = `area at ${Math.round(box.left)},${Math.round(box.top)} ${Math.round(box.width)}x${Math.round(box.height)}, ` +
|
||||||
`on top at its centre: ${top ? `${top.tagName.toLowerCase()}.${String(top.getAttribute('class') ?? '')}` : 'nothing'}`
|
`on top at its centre: ${top ? `${top.tagName.toLowerCase()}.${String(top.getAttribute('class') ?? '')}` : 'nothing'}`
|
||||||
return { point: found[Math.floor(found.length / 2)] ?? null, why }
|
// Low in the area, not its middle: the popup opens above the click, and from the
|
||||||
|
// middle its title ends up under the map's category pills.
|
||||||
|
return { point: found[Math.floor(found.length * 0.8)] ?? null, why }
|
||||||
})
|
})
|
||||||
if (!aim.point) throw new Error(`no part of the warning area is reachable on the map (${aim.why})`)
|
if (!aim.point) throw new Error(`no part of the warning area is reachable on the map (${aim.why})`)
|
||||||
hazardAt = aim.point
|
hazardAt = aim.point
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drag the map so the warning area sits low enough for its popup. The popup
|
||||||
|
* opens above the click and is taller than the room left under the category
|
||||||
|
* pills when the area stays where framing on Hakone puts it, and Leaflet's own
|
||||||
|
* auto pan does not reliably clear the pills. The drag starts on bare map.
|
||||||
|
*/
|
||||||
|
async function lowerHazardArea(page: Page): Promise<void> {
|
||||||
|
const plan = await page.evaluate(() => {
|
||||||
|
const path = document.querySelector<SVGPathElement>('.leaflet-overlay-pane path[stroke="var(--warning)"]')
|
||||||
|
if (!path) return null
|
||||||
|
const box = path.getBoundingClientRect()
|
||||||
|
const dy = Math.round(760 - box.bottom)
|
||||||
|
for (let y = 300; y <= 700; y += 40) {
|
||||||
|
for (let x = 700; x <= 1400; x += 50) {
|
||||||
|
// Bare map: inside the map, but not a pin, a popup, a control or a drawn line.
|
||||||
|
const el = document.elementFromPoint(x, y)
|
||||||
|
const bare =
|
||||||
|
!!el?.closest('.leaflet-container') &&
|
||||||
|
!el.closest('.leaflet-marker-pane, .leaflet-popup-pane, .leaflet-tooltip-pane, .leaflet-control-container') &&
|
||||||
|
!(el instanceof SVGPathElement)
|
||||||
|
if (bare) return { x, y, dy }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return { x: 0, y: 0, dy }
|
||||||
|
})
|
||||||
|
if (!plan || plan.dy <= 0) return
|
||||||
|
if (plan.x === 0) {
|
||||||
|
console.warn('[roadtrip-hazards] no bare map to drag the warning area down from')
|
||||||
|
return
|
||||||
|
}
|
||||||
|
await page.mouse.move(plan.x, plan.y)
|
||||||
|
await page.mouse.down()
|
||||||
|
for (let i = 1; i <= 12; i++) await page.mouse.move(plan.x, plan.y + (plan.dy * i) / 12)
|
||||||
|
// Hold still before letting go, so the drag ends without a fling.
|
||||||
|
await page.waitForTimeout(400)
|
||||||
|
await page.mouse.up()
|
||||||
|
await finishMapPan(page)
|
||||||
|
}
|
||||||
|
|
||||||
/** Hold the loop's last frame a moment, on the state the gesture left. */
|
/** Hold the loop's last frame a moment, on the state the gesture left. */
|
||||||
async function holdResult(page: Page, frame: () => Promise<void>): Promise<void> {
|
async function holdResult(page: Page, frame: () => Promise<void>): Promise<void> {
|
||||||
await settle(page)
|
await settle(page)
|
||||||
@@ -283,6 +342,14 @@ async function holdResult(page: Page, frame: () => Promise<void>): Promise<void>
|
|||||||
await frame()
|
await frame()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On the stop's name, the handle a reader grabs: the item's centre can be its drive
|
||||||
|
* band, whose Other ways tooltip would lie over the picture.
|
||||||
|
*/
|
||||||
|
async function hoverShrineName(page: Page): Promise<void> {
|
||||||
|
await stopRow(page, 'Hakone Shrine').hover({ position: { x: 70, y: 12 } })
|
||||||
|
}
|
||||||
|
|
||||||
// ── Day 4 as the fixtures left it, for the guide that moves its stops ─────────
|
// ── Day 4 as the fixtures left it, for the guide that moves its stops ─────────
|
||||||
|
|
||||||
let day4Order: number[] = []
|
let day4Order: number[] = []
|
||||||
@@ -386,6 +453,18 @@ async function restorePlace(page: Page, name: string, data: Record<string, unkno
|
|||||||
if (place) await page.request.put(`/api/trips/${tripId}/places/${place.id}`, { data })
|
if (place) await page.request.put(`/api/trips/${tripId}/places/${place.id}`, { data })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Every visit of the place back on the place's own stay, the hour a new place starts with. */
|
||||||
|
async function clearVisitStays(page: Page, name: string): Promise<void> {
|
||||||
|
const { tripId, dayIds } = seededTrip()
|
||||||
|
const placeId = await placeIdOf(page.request, name)
|
||||||
|
if (placeId === null) return
|
||||||
|
for (let i = 0; i < dayIds.length; i++) {
|
||||||
|
for (const visit of (await assignmentsOn(page.request, i)).filter(a => a.place_id === placeId)) {
|
||||||
|
await page.request.put(`/api/trips/${tripId}/assignments/${visit.id}/stay`, { data: { stay_minutes: null } })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const closeModal = async (page: Page): Promise<void> => {
|
const closeModal = async (page: Page): Promise<void> => {
|
||||||
if (await modal(page).isVisible().catch(() => false)) {
|
if (await modal(page).isVisible().catch(() => false)) {
|
||||||
await page.keyboard.press('Escape')
|
await page.keyboard.press('Escape')
|
||||||
@@ -409,7 +488,15 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
only(p => p.getByText('Driving time', { exact: true }).locator('xpath=ancestor::header[1]')),
|
only(p => p.getByText('Driving time', { exact: true }).locator('xpath=ancestor::header[1]')),
|
||||||
only(p => dayCard(p, 2).locator('header')),
|
only(p => dayCard(p, 2).locator('header')),
|
||||||
only(p => dayCard(p, 2).getByRole('list').first()),
|
{
|
||||||
|
target: p => dayCard(p, 2).getByRole('list').first(),
|
||||||
|
// In the list's top corner: its centre is the drive band, whose Other ways
|
||||||
|
// tooltip would cover the next stop's name.
|
||||||
|
hover: async p => {
|
||||||
|
const box = await dayCard(p, 2).getByRole('list').first().boundingBox()
|
||||||
|
if (box) await p.mouse.move(box.x + 12, box.y + 8)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
// Day 2, like the two steps above: the rail leaves out a day with
|
// Day 2, like the two steps above: the rail leaves out a day with
|
||||||
// nothing to drive, and day 1 is one of them.
|
// nothing to drive, and day 1 is one of them.
|
||||||
@@ -473,7 +560,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// Hakone Shrine, not a seeded stop: every seeded visit has an end time
|
// Hakone Shrine, not a seeded stop: every seeded visit has an end time
|
||||||
// from the day plan, and a stop with one opens the read-only "until"
|
// from the day plan, and a stop with one opens the read-only "until"
|
||||||
// version of the dialog, which has no slider and no Save. The drive's
|
// version of the dialog, which has no slider and no Save. The drive's
|
||||||
// own fixture places carry no times, so the badge is the plus of Add a stay.
|
// own fixture places carry no times, only the hour a new place starts with.
|
||||||
target: p => stopItem(p, 'Hakone Shrine').getByRole('button', { name: /^(Time at this stop|Add a stay)/ }),
|
target: p => stopItem(p, 'Hakone Shrine').getByRole('button', { name: /^(Time at this stop|Add a stay)/ }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await stopItem(p, 'Hakone Shrine').getByRole('button', { name: /^(Time at this stop|Add a stay)/ }).click()
|
await stopItem(p, 'Hakone Shrine').getByRole('button', { name: /^(Time at this stop|Add a stay)/ }).click()
|
||||||
@@ -484,21 +571,63 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
{
|
{
|
||||||
target: dialog,
|
target: dialog,
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: '1 h', exact: true }).click()
|
// Not 1 h: a new place starts with an hour, so that preset would change nothing.
|
||||||
await expect(modal(p).getByRole('slider', { name: 'Minutes' })).toHaveValue('60')
|
await modal(p).getByRole('button', { name: '45 min', exact: true }).click()
|
||||||
|
await expect(modal(p).getByRole('slider', { name: 'Minutes' })).toHaveValue('45')
|
||||||
await modal(p).getByRole('button', { name: 'Save', exact: true }).click()
|
await modal(p).getByRole('button', { name: 'Save', exact: true }).click()
|
||||||
await expect(modal(p)).toHaveCount(0)
|
await expect(modal(p)).toHaveCount(0)
|
||||||
await expect(stopItem(p, 'Hakone Shrine')).toContainText('1 h', { timeout: 20_000 })
|
await expect(stopItem(p, 'Hakone Shrine')).toContainText('45 min', { timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
cleanup: async p => {
|
cleanup: async p => {
|
||||||
// Zero, not null: the update folds a null into "leave it alone".
|
// The stay lands on the visit (#3092); null hands it back to the place, which has none.
|
||||||
await restorePlace(p, 'Hakone Shrine', { duration_minutes: 0 })
|
await clearVisitStays(p, 'Hakone Shrine')
|
||||||
await restorePlace(p, 'Meiji Jingu', { stop_type: null })
|
await restorePlace(p, 'Meiji Jingu', { stop_type: null })
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'roadtrip-stop-photo': {
|
||||||
|
guide: guide('roadtrip-stop-photo'),
|
||||||
|
start: async p => {
|
||||||
|
await ensurePhotoStop(p.request)
|
||||||
|
await openRoadtrip(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => stopRow(p, PHOTO_STOP),
|
||||||
|
act: async p => {
|
||||||
|
await stopRow(p, PHOTO_STOP).click({ position: { x: 70, y: 12 } })
|
||||||
|
await expect(placeCardHead(p, PHOTO_STOP)).toBeVisible({ timeout: 15_000 })
|
||||||
|
await finishMapPan(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Edit is the primary action at the right end of the card's footer.
|
||||||
|
target: cardEdit,
|
||||||
|
act: async p => {
|
||||||
|
await cardEdit(p).click()
|
||||||
|
await expect(stopDialogPhoto(p)).toBeVisible({ timeout: 15_000 })
|
||||||
|
await expect(stopDialogPhoto(p).locator('img')).toHaveJSProperty('complete', true)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: stopDialogPhoto,
|
||||||
|
act: async p => {
|
||||||
|
await stopDialogPhoto(p).click()
|
||||||
|
await expect(lightbox(p)).toBeVisible({ timeout: 15_000 })
|
||||||
|
await expect(lightbox(p).locator('img').first()).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
if (await lightbox(p).isVisible().catch(() => false)) await p.keyboard.press('Escape')
|
||||||
|
await closeModal(p)
|
||||||
|
await removePhotoStop(p.request)
|
||||||
|
},
|
||||||
|
},
|
||||||
'roadtrip-reorder': {
|
'roadtrip-reorder': {
|
||||||
guide: guide('roadtrip-reorder'),
|
guide: guide('roadtrip-reorder'),
|
||||||
start: async p => {
|
start: async p => {
|
||||||
@@ -510,6 +639,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// Hakone Shrine onto Shinjuku Gyoen: the shrine moves up beside
|
// Hakone Shrine onto Shinjuku Gyoen: the shrine moves up beside
|
||||||
// Owakudani, and the day stops driving to Tokyo and back.
|
// Owakudani, and the day stops driving to Tokyo and back.
|
||||||
target: p => stopItem(p, 'Hakone Shrine'),
|
target: p => stopItem(p, 'Hakone Shrine'),
|
||||||
|
hover: hoverShrineName,
|
||||||
dropTo: p => stopItem(p, 'Shinjuku Gyoen'),
|
dropTo: p => stopItem(p, 'Shinjuku Gyoen'),
|
||||||
clip: async (p, frame) => {
|
clip: async (p, frame) => {
|
||||||
await dragLoop(p, stopItem(p, 'Hakone Shrine'), stopItem(p, 'Shinjuku Gyoen'), frame)
|
await dragLoop(p, stopItem(p, 'Hakone Shrine'), stopItem(p, 'Shinjuku Gyoen'), frame)
|
||||||
@@ -525,6 +655,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// head of day 4 between them day 2 then lies above the rail's window, so
|
// head of day 4 between them day 2 then lies above the rail's window, so
|
||||||
// the pointer let go off the rail and nothing moved.
|
// the pointer let go off the rail and nothing moved.
|
||||||
target: p => stopItem(p, 'Hakone Shrine'),
|
target: p => stopItem(p, 'Hakone Shrine'),
|
||||||
|
hover: hoverShrineName,
|
||||||
dropTo: p => stopItem(p, 'Hakone Open-Air Museum'),
|
dropTo: p => stopItem(p, 'Hakone Open-Air Museum'),
|
||||||
clip: async (p, frame) => {
|
clip: async (p, frame) => {
|
||||||
await dragLoop(p, stopItem(p, 'Hakone Shrine'), stopItem(p, 'Hakone Open-Air Museum'), frame)
|
await dragLoop(p, stopItem(p, 'Hakone Shrine'), stopItem(p, 'Hakone Open-Air Museum'), frame)
|
||||||
@@ -538,6 +669,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// Day 4 is Owakudani and Shinjuku Gyoen now; Alt and up puts the garden
|
// Day 4 is Owakudani and Shinjuku Gyoen now; Alt and up puts the garden
|
||||||
// first, and the day drives out of Tokyo to the valley.
|
// first, and the day drives out of Tokyo to the valley.
|
||||||
target: p => stopRow(p, 'Shinjuku Gyoen'),
|
target: p => stopRow(p, 'Shinjuku Gyoen'),
|
||||||
|
hover: async p => { await stopRow(p, 'Shinjuku Gyoen').hover({ position: { x: 70, y: 12 } }) },
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await stopRow(p, 'Shinjuku Gyoen').focus()
|
await stopRow(p, 'Shinjuku Gyoen').focus()
|
||||||
await p.keyboard.press('Alt+ArrowUp')
|
await p.keyboard.press('Alt+ArrowUp')
|
||||||
@@ -879,6 +1011,11 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
target: p => modal(p).getByRole('group', { name: 'Daily travel times' }),
|
target: p => modal(p).getByRole('group', { name: 'Daily travel times' }),
|
||||||
|
// In the group's corner: its centre carries the note's tooltip over Day end time.
|
||||||
|
hover: async p => {
|
||||||
|
const box = await modal(p).getByRole('group', { name: 'Daily travel times' }).boundingBox()
|
||||||
|
if (box) await p.mouse.move(box.x + 6, box.y + 6)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => modal(p).getByRole('textbox', { name: 'Day start time' }),
|
target: p => modal(p).getByRole('textbox', { name: 'Day start time' }),
|
||||||
@@ -939,7 +1076,14 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await settle(p)
|
await settle(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
only(p => dryBand(p).getByRole('list').first()),
|
{
|
||||||
|
target: p => dryBand(p).getByRole('list').first(),
|
||||||
|
// In the list's corner: a badge under its centre would lay its tooltip over a name.
|
||||||
|
hover: async p => {
|
||||||
|
const box = await dryBand(p).getByRole('list').first().boundingBox()
|
||||||
|
if (box) await p.mouse.move(box.x + 6, box.y + 6)
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
const label = (await addFuelStop(p).getAttribute('aria-label')) ?? ''
|
const label = (await addFuelStop(p).getAttribute('aria-label')) ?? ''
|
||||||
@@ -1161,6 +1305,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// that stop (the way the via guide brings its leg into view) puts the
|
// that stop (the way the via guide brings its leg into view) puts the
|
||||||
// area in the middle of the map at the same zoom, outline and all.
|
// area in the middle of the map at the same zoom, outline and all.
|
||||||
await frameOnStop(p, 'Hakone Shrine')
|
await frameOnStop(p, 'Hakone Shrine')
|
||||||
|
await lowerHazardArea(p)
|
||||||
await aimAtHazard(p)
|
await aimAtHazard(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -1170,7 +1315,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
act: async p => {
|
act: async p => {
|
||||||
await p.mouse.click(hazardAt.x, hazardAt.y)
|
await p.mouse.click(hazardAt.x, hazardAt.y)
|
||||||
await expect(hazardPopup(p)).toContainText(HAZARD_TITLE, { timeout: 15_000 })
|
await expect(hazardPopup(p)).toContainText(HAZARD_TITLE, { timeout: 15_000 })
|
||||||
await settle(p)
|
// The popup pans the map to fit itself, on Leaflet's clock: let that pan land,
|
||||||
|
// or its title stays under the map's category pills.
|
||||||
|
await finishMapPan(p)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -218,6 +218,39 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
|
||||||
|
'tour-route-in-app': {
|
||||||
|
guide: guide('tour-route-in-app'),
|
||||||
|
// The hut trek: a hike, so the map apps follow it on foot.
|
||||||
|
start: async (p) => {
|
||||||
|
await openTourTrip(p, { day: null });
|
||||||
|
await toursTab(p).click();
|
||||||
|
await expect(row(p, TOUR_NAMES.hutToHut)).toBeVisible({ timeout: 30_000 });
|
||||||
|
await settle(p);
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: (p) => row(p, TOUR_NAMES.hutToHut),
|
||||||
|
act: async (p) => {
|
||||||
|
await row(p, TOUR_NAMES.hutToHut).click();
|
||||||
|
await expect(head(p).getByRole('heading', { name: TOUR_NAMES.hutToHut, exact: true })).toBeVisible({
|
||||||
|
timeout: 30_000,
|
||||||
|
});
|
||||||
|
await settle(p);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: (p) => footer(p).getByTestId('tour-route-apps'),
|
||||||
|
act: async (p) => {
|
||||||
|
await footer(p).getByTestId('tour-route-apps').click();
|
||||||
|
await expect(p.getByRole('menu')).toBeVisible();
|
||||||
|
await settle(p);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// No click: each entry hands the route to another app in a new tab.
|
||||||
|
only((p) => p.getByRole('menu')),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
|
||||||
'tour-copy-keep': {
|
'tour-copy-keep': {
|
||||||
guide: guide('tour-copy-keep'),
|
guide: guide('tour-copy-keep'),
|
||||||
start: async (p) => {
|
start: async (p) => {
|
||||||
|
|||||||
@@ -180,7 +180,12 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await openTours(p);
|
await openTours(p);
|
||||||
},
|
},
|
||||||
steps: [
|
steps: [
|
||||||
{ target: (p) => tourRow(p, RECORDED_NAME), act: viewRecorded },
|
{
|
||||||
|
target: (p) => tourRow(p, RECORDED_NAME),
|
||||||
|
// On the name: the centre of the row is its time badge, whose tooltip would cover the next row.
|
||||||
|
hover: (p) => tourRow(p, RECORDED_NAME).getByText(RECORDED_NAME, { exact: true }).hover(),
|
||||||
|
act: viewRecorded,
|
||||||
|
},
|
||||||
{ target: (p) => railCard(p, RECORDED_NAME, 'Tour summary') },
|
{ target: (p) => railCard(p, RECORDED_NAME, 'Tour summary') },
|
||||||
{
|
{
|
||||||
target: (p) => importRail(p, RECORDED_NAME).getByRole('button', { name: 'Back to Tours' }),
|
target: (p) => importRail(p, RECORDED_NAME).getByRole('button', { name: 'Back to Tours' }),
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import {
|
|||||||
reliefSlider,
|
reliefSlider,
|
||||||
restartButton,
|
restartButton,
|
||||||
seamarksToggle,
|
seamarksToggle,
|
||||||
|
searchAgainWhileUnavailable,
|
||||||
searchAlong,
|
searchAlong,
|
||||||
speedGroup,
|
speedGroup,
|
||||||
terrainToggle,
|
terrainToggle,
|
||||||
@@ -158,6 +159,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
act: async (p) => {
|
act: async (p) => {
|
||||||
await alongSearch(p).click();
|
await alongSearch(p).click();
|
||||||
await expect(alongSearch(p)).toHaveText(/Search again/, { timeout: 90_000 });
|
await expect(alongSearch(p)).toHaveText(/Search again/, { timeout: 90_000 });
|
||||||
|
await searchAgainWhileUnavailable(p);
|
||||||
await settle(p);
|
await settle(p);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -145,8 +145,39 @@ async function searchTheHut(page: Page): Promise<void> {
|
|||||||
const local = options.filter({
|
const local = options.filter({
|
||||||
hasText: /Santa Cristina|Gardena|Gröden|Bolzano|Bozen|Südtirol|Alto Adige|Trentino/i,
|
hasText: /Santa Cristina|Gardena|Gröden|Bolzano|Bozen|Südtirol|Alto Adige|Trentino/i,
|
||||||
});
|
});
|
||||||
await ((await local.count()) ? local.first() : options.first()).click();
|
const hut = local.filter({ hasText: /Regensburger|Firenze/i });
|
||||||
|
await ((await hut.count()) ? hut.first() : (await local.count()) ? local.first() : options.first()).click();
|
||||||
await landMap(page);
|
await landMap(page);
|
||||||
|
await fitTheDrawing(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The search lands on whatever the place search answers for the hut, and as
|
||||||
|
* close in as that answer is small: an area mapped as a building lands so far
|
||||||
|
* in that the spots of the drawing are off the screen. Out with the wheel, on
|
||||||
|
* the middle of the map, until the first and the last spot are both in sight.
|
||||||
|
*/
|
||||||
|
async function fitTheDrawing(page: Page): Promise<void> {
|
||||||
|
const g = await line(page);
|
||||||
|
const ends = [DRAWN_OFFSETS[0], DRAWN_OFFSETS[DRAWN_OFFSETS.length - 1]];
|
||||||
|
const inSight = async () => {
|
||||||
|
for (const offset of ends) {
|
||||||
|
if (
|
||||||
|
!(await screenOf(page, spotAt(g, offset)).then(
|
||||||
|
() => true,
|
||||||
|
() => false
|
||||||
|
))
|
||||||
|
)
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
};
|
||||||
|
for (let i = 0; i < 6 && !(await inSight()); i++) {
|
||||||
|
await page.mouse.move(VIEWPORT.width / 2, VIEWPORT.height / 2 + 40);
|
||||||
|
await page.mouse.wheel(0, 120);
|
||||||
|
await landMap(page);
|
||||||
|
}
|
||||||
|
expect(await inSight(), 'the drawing does not fit on the map after the search').toBe(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Click spot `i` of the drawing onto the map and wait for its row. */
|
/** Click spot `i` of the drawing onto the map and wait for its row. */
|
||||||
@@ -230,12 +261,16 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await p.getByTestId('tour-rail-add').click();
|
await p.getByTestId('tour-rail-add').click();
|
||||||
}
|
}
|
||||||
await expect(p.getByRole('group', { name: 'Add tour', exact: true })).toHaveCount(0);
|
await expect(p.getByRole('group', { name: 'Add tour', exact: true })).toHaveCount(0);
|
||||||
|
// The plus keeps the focus, and with it its tooltip, into the pictures after it.
|
||||||
|
await p.evaluate(() => (document.activeElement as HTMLElement | null)?.blur());
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ target: mapSearch },
|
{ target: mapSearch },
|
||||||
{ target: layerPill },
|
{ target: layerPill },
|
||||||
{
|
{
|
||||||
target: (p) => tourRow(p, TOUR_NAMES.recorded),
|
target: (p) => tourRow(p, TOUR_NAMES.recorded),
|
||||||
|
// On the name: the centre of the row is its time badge, whose tooltip would cover the next row.
|
||||||
|
hover: (p) => tourRow(p, TOUR_NAMES.recorded).getByText(TOUR_NAMES.recorded, { exact: true }).hover(),
|
||||||
act: async (p) => {
|
act: async (p) => {
|
||||||
await tourRow(p, TOUR_NAMES.recorded).click();
|
await tourRow(p, TOUR_NAMES.recorded).click();
|
||||||
await expect(p.getByRole('heading', { name: 'GPX tour', exact: true })).toBeVisible({ timeout: 30_000 });
|
await expect(p.getByRole('heading', { name: 'GPX tour', exact: true })).toBeVisible({ timeout: 30_000 });
|
||||||
@@ -562,12 +597,16 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
target: breaks,
|
target: breaks,
|
||||||
act: async (p) => {
|
act: async (p) => {
|
||||||
await typeInto(p, breaks(p), '0:45');
|
await typeInto(p, breaks(p), '0:45');
|
||||||
await breaks(p).press('Tab');
|
// Blurred rather than tabbed away from: Tab would focus Planned, whose
|
||||||
|
// tooltip then covers the field the next step is about.
|
||||||
|
await breaks(p).blur();
|
||||||
await settle(p);
|
await settle(p);
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: planned,
|
target: planned,
|
||||||
|
// Not on the field itself: its tooltip would cover the time the step is about.
|
||||||
|
hover: (p) => p.getByText('Breaks', { exact: true }).first().hover(),
|
||||||
act: async (p) => {
|
act: async (p) => {
|
||||||
await typeInto(p, planned(p), '3:30');
|
await typeInto(p, planned(p), '3:30');
|
||||||
await planned(p).press('Enter');
|
await planned(p).press('Enter');
|
||||||
|
|||||||
@@ -505,8 +505,32 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await tourRow(p, /Vallunga cross-country/).click();
|
await tourRow(p, /Vallunga cross-country/).click();
|
||||||
await expect(p.getByTestId('ski-track-card')).toBeVisible({ timeout: 30_000 });
|
await expect(p.getByTestId('ski-track-card')).toBeVisible({ timeout: 30_000 });
|
||||||
await settle(p);
|
await settle(p);
|
||||||
|
// The card lies below the fold of its panel while the panel still grows; the picture
|
||||||
|
// was taken of the empty space below the window. Wait until the button sits inside it.
|
||||||
|
const change = p.getByTestId('ski-track-card').getByRole('button', { name: 'Change' });
|
||||||
|
await expect
|
||||||
|
.poll(
|
||||||
|
async () => {
|
||||||
|
await change.evaluate((el) => el.scrollIntoView({ block: 'center', inline: 'nearest' }));
|
||||||
|
await p.evaluate(() => window.scrollTo(0, 0));
|
||||||
|
const box = await change.boundingBox();
|
||||||
|
const vp = p.viewportSize();
|
||||||
|
return !!box && !!vp && box.y > 0 && box.y + box.height < vp.height && box.x > 0;
|
||||||
|
},
|
||||||
|
{ timeout: 20_000 }
|
||||||
|
)
|
||||||
|
.toBe(true);
|
||||||
|
await p.waitForTimeout(800);
|
||||||
|
await settle(p);
|
||||||
},
|
},
|
||||||
target: (p) => p.getByTestId('ski-track-card').getByRole('button', { name: 'Change' }),
|
target: (p) => p.getByTestId('ski-track-card').getByRole('button', { name: 'Change' }),
|
||||||
|
hover: async (p) => {
|
||||||
|
const change = p.getByTestId('ski-track-card').getByRole('button', { name: 'Change' });
|
||||||
|
// A throwaway full screenshot first: the one render that came out right had one here, and
|
||||||
|
// the clipped shot alone has come out as an empty, shifted frame without the ring.
|
||||||
|
await p.screenshot();
|
||||||
|
await change.hover();
|
||||||
|
},
|
||||||
act: async (p) => {
|
act: async (p) => {
|
||||||
await p.getByTestId('ski-track-card').getByRole('button', { name: 'Change' }).click();
|
await p.getByTestId('ski-track-card').getByRole('button', { name: 'Change' }).click();
|
||||||
await expect(classifyDialog(p)).toBeVisible();
|
await expect(classifyDialog(p)).toBeVisible();
|
||||||
|
|||||||
@@ -184,6 +184,12 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// The hut trek has three stages, so the day it is given asks how next.
|
// The hut trek has three stages, so the day it is given asks how next.
|
||||||
prepare: async (p) => {
|
prepare: async (p) => {
|
||||||
await hoverRow(p, TOUR_NAMES.hutToHut);
|
await hoverRow(p, TOUR_NAMES.hutToHut);
|
||||||
|
// The second menu opens at the Add to day button, which only shows while the row is
|
||||||
|
// hovered or focused. Choosing the day moves both away, so the button would have no box
|
||||||
|
// and the menu would open in the window's top left corner; kept in sight, it anchors there.
|
||||||
|
await tourRow(p, TOUR_NAMES.hutToHut)
|
||||||
|
.getByTestId('tour-action-row')
|
||||||
|
.evaluate((el) => ((el as HTMLElement).style.display = 'flex'));
|
||||||
await tourRow(p, TOUR_NAMES.hutToHut).getByRole('button', { name: 'Add to day', exact: true }).click();
|
await tourRow(p, TOUR_NAMES.hutToHut).getByRole('button', { name: 'Add to day', exact: true }).click();
|
||||||
await expect(dayMenu(p)).toBeVisible();
|
await expect(dayMenu(p)).toBeVisible();
|
||||||
await dayMenu(p)
|
await dayMenu(p)
|
||||||
@@ -196,7 +202,12 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
target: dayMenu,
|
target: dayMenu,
|
||||||
// Nothing chosen: the hut trek keeps its days 4 to 6.
|
// Nothing chosen: the hut trek keeps its days 4 to 6.
|
||||||
act: closeMenu,
|
act: async (p) => {
|
||||||
|
await closeMenu(p);
|
||||||
|
await tourRow(p, TOUR_NAMES.hutToHut)
|
||||||
|
.getByTestId('tour-action-row')
|
||||||
|
.evaluate((el) => (el as HTMLElement).style.removeProperty('display'));
|
||||||
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
cleanup: noDayTours,
|
cleanup: noDayTours,
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
import { test, expect, type Locator, type Page } from '@playwright/test'
|
import { test, expect, type Locator, type Page } from '@playwright/test'
|
||||||
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
||||||
import { seededTrip, ensureTransportFixtures, TRANSIT_JOURNEY, flightEmlFixture, FLIGHT_EML, FLIGHT_TO_IMPORT } from './fixtures'
|
import { seededTrip, ensureTransportFixtures, TRANSIT_JOURNEY, flightEmlFixture, FLIGHT_EML, FLIGHT_TO_IMPORT } from './fixtures'
|
||||||
import { openTrip, openTripOnDay, selectDay, modal, dialog, portalDialog, importSteps, importTask, dismissImportTask, deleteTripFiles } from './trip-shared'
|
import { openTrip, openTripOnDay, selectDay, closeDayDetails, modal, dialog, portalDialog, importSteps, importTask, dismissImportTask, deleteTripFiles } from './trip-shared'
|
||||||
import { ensureAirtrailConnection, disconnectAirtrail, AIRTRAIL_FLIGHTS, requireExtractor, allowEmlUploads } from './external'
|
import { ensureAirtrailConnection, disconnectAirtrail, AIRTRAIL_FLIGHTS, requireExtractor, allowEmlUploads } from './external'
|
||||||
import { tripTransportsContext, tripTransportsGuides } from '../../src/help/contexts/tripTransports'
|
import { tripTransportsContext, tripTransportsGuides } from '../../src/help/contexts/tripTransports'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
|
import { at, day } from '../dates'
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions for the Transports tab of a trip, keyed by the ids in
|
* Actions for the Transports tab of a trip, keyed by the ids in
|
||||||
@@ -200,6 +201,67 @@ const joinToggle = (page: Page) =>
|
|||||||
const connectionGroup = (page: Page) => joinToggle(page).locator('xpath=..')
|
const connectionGroup = (page: Page) => joinToggle(page).locator('xpath=..')
|
||||||
const importCta = (page: Page) => airtrailPicker(page).getByRole('button', { name: /^Import \d+$/ })
|
const importCta = (page: Page) => airtrailPicker(page).getByRole('button', { name: /^Import \d+$/ })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The flight home on the trip's last day, the picture day, for flight-live-status.
|
||||||
|
* Departure 15:20 in Tokyo (06:20 UTC) and arrival 21:25 in Frankfurt (20:25
|
||||||
|
* UTC), so at the pinned 09:00 UTC it has been in the air for two and a half
|
||||||
|
* hours: 15 minutes late off the ground and 25 minutes late on the estimate.
|
||||||
|
*/
|
||||||
|
const LIVE = {
|
||||||
|
title: 'NH223 HND → FRA',
|
||||||
|
code: 'NH7QF2',
|
||||||
|
flightNumber: 'NH223',
|
||||||
|
from: { code: 'HND', name: 'Tokyo Haneda', lat: 35.5494, lng: 139.7798, timezone: 'Asia/Tokyo' },
|
||||||
|
to: { code: 'FRA', name: 'Frankfurt', lat: 50.0379, lng: 8.5622, timezone: 'Europe/Berlin' },
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Creates the flight home and answers its id. */
|
||||||
|
async function createLiveFlight(page: Page): Promise<number> {
|
||||||
|
const { tripId, dayIds } = seededTrip()
|
||||||
|
const res = await page.request.post(`/api/trips/${tripId}/reservations`, {
|
||||||
|
data: {
|
||||||
|
title: LIVE.title, type: 'flight', status: 'confirmed',
|
||||||
|
day_id: dayIds[dayIds.length - 1], end_day_id: dayIds[dayIds.length - 1],
|
||||||
|
reservation_time: at(0, '15:20'), reservation_end_time: at(0, '21:25'),
|
||||||
|
confirmation_number: LIVE.code, location: LIVE.from.name,
|
||||||
|
metadata: { airline: 'All Nippon Airways', flight_number: LIVE.flightNumber, departure_airport: 'HND', arrival_airport: 'FRA' },
|
||||||
|
endpoints: [
|
||||||
|
{ role: 'from', sequence: 0, name: LIVE.from.name, code: LIVE.from.code, lat: LIVE.from.lat, lng: LIVE.from.lng, timezone: LIVE.from.timezone, local_date: day(0), local_time: '15:20' },
|
||||||
|
{ role: 'to', sequence: 1, name: LIVE.to.name, code: LIVE.to.code, lat: LIVE.to.lat, lng: LIVE.to.lng, timezone: LIVE.to.timezone, local_date: day(0), local_time: '21:25' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
})
|
||||||
|
if (!res.ok()) throw new Error(`could not create the live flight: ${res.status()} ${await res.text()}`)
|
||||||
|
const body = (await res.json()) as { reservation?: { id: number }; id?: number }
|
||||||
|
const id = body.reservation?.id ?? body.id
|
||||||
|
if (!id) throw new Error('the live flight came back without an id')
|
||||||
|
return id
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the open ADS-B feeds would say about the flight two and a half hours
|
||||||
|
* after take-off, over north-east China on the great circle to Frankfurt. The
|
||||||
|
* feed cannot be asked from here (and the real NH223 may be anywhere), so the
|
||||||
|
* trip's live read answers this leg: the same shape the server sends.
|
||||||
|
*/
|
||||||
|
function liveLeg(reservationId: number) {
|
||||||
|
const utc = (hhmm: string) => `${day(0)}T${hhmm}:00.000Z`
|
||||||
|
return {
|
||||||
|
reservation_id: reservationId, leg_index: 0, callsign: 'ANA223', flight_number: 'NH 223', service_date: day(0),
|
||||||
|
origin: LIVE.from, destination: LIVE.to, phase: 'airborne',
|
||||||
|
scheduled_departure: utc('06:20'), scheduled_arrival: utc('20:25'),
|
||||||
|
departed_at: utc('06:35'), landed_at: null, estimated_arrival: utc('20:50'),
|
||||||
|
departure_delay_min: 15, arrival_delay_min: 25,
|
||||||
|
progress: 0.17, distance_total_km: 9361, distance_remaining_km: 7770,
|
||||||
|
position: { lat: 47.66, lng: 129.51, altitude_ft: 37000, ground_speed_kt: 486, track_deg: 304, vertical_rate_fpm: 0, on_ground: false },
|
||||||
|
aircraft: { registration: 'JA791A', type: 'B77W' },
|
||||||
|
last_seen_at: utc('08:59'), fetched_at: utc('08:59'), stale: false, source: 'adsb.lol',
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The live card in the open booking, named by the flight number and where it stands. */
|
||||||
|
const liveCard = (page: Page) => bookingDetail(page, LIVE.title).locator('section[aria-label^="NH 223 "]')
|
||||||
|
|
||||||
/** Give a day's legs back to the day's own mode, whichever stop carries the one that was set. */
|
/** Give a day's legs back to the day's own mode, whichever stop carries the one that was set. */
|
||||||
async function resetLegModes(page: Page, dayIndex: number): Promise<void> {
|
async function resetLegModes(page: Page, dayIndex: number): Promise<void> {
|
||||||
const { tripId, dayIds } = seededTrip()
|
const { tripId, dayIds } = seededTrip()
|
||||||
@@ -666,9 +728,9 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => bookingDetail(p, TRAIN.title).getByRole('button', { name: 'On map', exact: true }),
|
target: p => bookingDetail(p, TRAIN.title).getByRole('button', { name: 'Map', exact: true }),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await bookingDetail(p, TRAIN.title).getByRole('button', { name: 'On map', exact: true }).click()
|
await bookingDetail(p, TRAIN.title).getByRole('button', { name: 'Map', exact: true }).click()
|
||||||
// The Plan opens on day 5 with the train's line switched on.
|
// The Plan opens on day 5 with the train's line switched on.
|
||||||
await expect(transportRowTitled(p, TRAIN.title).getByRole('button', { name: 'Hide booking routes' })).toBeVisible({ timeout: 20_000 })
|
await expect(transportRowTitled(p, TRAIN.title).getByRole('button', { name: 'Hide booking routes' })).toBeVisible({ timeout: 20_000 })
|
||||||
await settle(p)
|
await settle(p)
|
||||||
@@ -801,6 +863,58 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
await p.evaluate(() => { try { sessionStorage.clear() } catch { /* a locked-down browser keeps its filters */ } })
|
await p.evaluate(() => { try { sessionStorage.clear() } catch { /* a locked-down browser keeps its filters */ } })
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'flight-live-status': {
|
||||||
|
guide: guide('flight-live-status'),
|
||||||
|
// The server's own poll is switched off for the guide, so no push from the
|
||||||
|
// real feed lands over the answer the page is given for this flight.
|
||||||
|
start: async p => {
|
||||||
|
await p.request.put('/api/auth/app-settings', { data: { flight_live_enabled: false } })
|
||||||
|
await deleteByTitle(p, LIVE.title)
|
||||||
|
const id = await createLiveFlight(p)
|
||||||
|
await p.context().route(/\/api\/trips\/\d+\/flights\/live$/, route =>
|
||||||
|
route.fulfill({ json: { enabled: true, attribution: 'adsb.lol', flights: [liveLeg(id)] } }))
|
||||||
|
await openTrip(p, { tab: 'transports' })
|
||||||
|
await expect(card(p, LIVE.title).getByText(/^In the air, Lands in /)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
only(p => card(p, LIVE.title)),
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await card(p, LIVE.title).click()
|
||||||
|
await expect(liveCard(p)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
// The route map under the pass is a vector map; its tiles land after idle.
|
||||||
|
await p.waitForTimeout(1500)
|
||||||
|
},
|
||||||
|
target: p => liveCard(p).locator('> header'),
|
||||||
|
},
|
||||||
|
only(p => liveCard(p).locator('> div > div').first()),
|
||||||
|
only(p => liveCard(p).locator('div.mt-3.grid')),
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await p.keyboard.press('Escape')
|
||||||
|
await expect(bookingDetail(p, LIVE.title)).toHaveCount(0)
|
||||||
|
// The tab is remembered, so the Plan is opened by its tab. It opens on
|
||||||
|
// today, the trip's last day, where the flight home is.
|
||||||
|
await p.getByRole('button', { name: 'Plan', exact: true }).click()
|
||||||
|
await expect(transportRowTitled(p, LIVE.title)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await closeDayDetails(p)
|
||||||
|
await transportRowTitled(p, LIVE.title).scrollIntoViewIfNeeded()
|
||||||
|
await expect(transportRowTitled(p, LIVE.title).getByText(/^In the air, Lands in /)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
await p.waitForTimeout(1500)
|
||||||
|
},
|
||||||
|
target: p => transportRowTitled(p, LIVE.title),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await p.context().unroute(/\/api\/trips\/\d+\/flights\/live$/)
|
||||||
|
await deleteByTitle(p, LIVE.title)
|
||||||
|
await p.request.put('/api/auth/app-settings', { data: { flight_live_enabled: true } })
|
||||||
|
await p.evaluate(() => { try { sessionStorage.clear() } catch { /* a locked-down browser keeps its tab */ } })
|
||||||
|
},
|
||||||
|
},
|
||||||
'airtrail-import': {
|
'airtrail-import': {
|
||||||
guide: guide('airtrail-import'),
|
guide: guide('airtrail-import'),
|
||||||
// The connection is made here and taken away in cleanup, so the hero and
|
// The connection is made here and taken away in cleanup, so the hero and
|
||||||
|
|||||||
+218
-12
@@ -1,14 +1,24 @@
|
|||||||
import { test, expect, type Page, type Locator } from '@playwright/test'
|
import { test, expect, type Page, type Locator } from '@playwright/test'
|
||||||
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
import { captureGuide, captureHero, beat, typeInto, settle, VIEWPORT, type GuideScript } from './guide'
|
||||||
import { ensureUsers, seededTrip, ADMIN_USERS, JOURNEY_TITLE } from './fixtures'
|
import { ensureUsers, seededTrip, ADMIN_USERS, JOURNEY_TITLE } from './fixtures'
|
||||||
import { openTrip, openTripOnDay, modal } from './trip-shared'
|
import { openTrip, openTripOnDay, modal, confirmDialog } from './trip-shared'
|
||||||
|
import { mockTripAssistant, resetTripAssistant, QUESTION, SUGGESTED, type AssistantRun } from './fixtures-assistant'
|
||||||
import { tripContext, tripGuides } from '../../src/help/contexts/trip'
|
import { tripContext, tripGuides } from '../../src/help/contexts/trip'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
|
|
||||||
|
/** The round button at the bottom of the planner, not the navbar's twin of the same name. */
|
||||||
|
const assistantLauncher = (page: Page) => page.locator('button.trek-assistant-pop')
|
||||||
|
const assistantWindow = (page: Page) => page.getByRole('dialog', { name: 'Assistant', exact: true })
|
||||||
|
/** The answer's card of changes: the last section inside the window, by its title while it waits. */
|
||||||
|
const changeCard = (page: Page) =>
|
||||||
|
assistantWindow(page).locator('section').filter({ has: page.getByText('Suggested changes', { exact: true }) }).last()
|
||||||
|
/** What the mocked chat made for real, for cleanup. */
|
||||||
|
let assistantRun: AssistantRun | null = null
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Actions for the trip frame, keyed by the ids in `src/help/contexts/trip.ts`:
|
* Actions for the trip frame, keyed by the ids in `src/help/contexts/trip.ts`:
|
||||||
* the trip's Settings (people, sharing, the linked journal), the columns and
|
* the trip's Settings (people, sharing, the linked journal, the trip's addons
|
||||||
* the undo. They run on the seeded "Autumn in Japan"; what a guide creates (a
|
* and its own form), the columns and the undo. They run on the seeded "Autumn in Japan"; what a guide creates (a
|
||||||
* member, a guest, a link, a linked journal) it leaves for the next one or
|
* member, a guest, a link, a linked journal) it leaves for the next one or
|
||||||
* takes away again in `cleanup`.
|
* takes away again in `cleanup`.
|
||||||
*/
|
*/
|
||||||
@@ -28,7 +38,8 @@ const block = (page: Page, opening: RegExp) => modal(page).locator('section').fi
|
|||||||
const inviteBlock = (page: Page) => block(page, /^Invite User/)
|
const inviteBlock = (page: Page) => block(page, /^Invite User/)
|
||||||
const accessBlock = (page: Page) => block(page, /^Access\s*\d/)
|
const accessBlock = (page: Page) => block(page, /^Access\s*\d/)
|
||||||
/** An area in the dialog's list on the left; each carries the area's name as its label. */
|
/** An area in the dialog's list on the left; each carries the area's name as its label. */
|
||||||
const area = (page: Page, name: 'People' | 'Sharing' | 'Journal') => modal(page).getByRole('button', { name, exact: true })
|
type AreaName = 'People' | 'Sharing' | 'Journal' | 'Addons' | 'Edit Trip'
|
||||||
|
const area = (page: Page, name: AreaName) => modal(page).getByRole('button', { name, exact: true })
|
||||||
/** The Trip settings pill beside the trip's name. */
|
/** The Trip settings pill beside the trip's name. */
|
||||||
const settingsPill = (page: Page) => page.getByRole('button', { name: 'Trip settings', exact: true })
|
const settingsPill = (page: Page) => page.getByRole('button', { name: 'Trip settings', exact: true })
|
||||||
/**
|
/**
|
||||||
@@ -52,7 +63,7 @@ async function openSettings(page: Page): Promise<void> {
|
|||||||
await clickSettings(page)
|
await clickSettings(page)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function pickArea(page: Page, name: 'Sharing' | 'Journal'): Promise<void> {
|
async function pickArea(page: Page, name: AreaName): Promise<void> {
|
||||||
await area(page, name).click()
|
await area(page, name).click()
|
||||||
await expect(area(page, name)).toHaveAttribute('aria-current', 'page')
|
await expect(area(page, name)).toHaveAttribute('aria-current', 'page')
|
||||||
await settle(page)
|
await settle(page)
|
||||||
@@ -61,6 +72,8 @@ async function pickArea(page: Page, name: 'Sharing' | 'Journal'): Promise<void>
|
|||||||
const closeModal = async (page: Page): Promise<void> => {
|
const closeModal = async (page: Page): Promise<void> => {
|
||||||
await page.keyboard.press('Escape')
|
await page.keyboard.press('Escape')
|
||||||
await expect(modal(page)).toHaveCount(0)
|
await expect(modal(page)).toHaveCount(0)
|
||||||
|
// The dialog hands the focus back to the pill, whose focus ring would stay in the picture.
|
||||||
|
await page.evaluate(() => (document.activeElement as HTMLElement | null)?.blur())
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Take the journal off the trip again; a trip without one answers that too, which is fine. */
|
/** Take the journal off the trip again; a trip without one answers that too, which is fine. */
|
||||||
@@ -71,6 +84,49 @@ async function unlinkJournal(page: Page): Promise<void> {
|
|||||||
|
|
||||||
const only = (target: (p: Page) => Locator) => ({ target })
|
const only = (target: (p: Page) => Locator) => ({ target })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Wait until the first rows of the places column show their photos. A photo
|
||||||
|
* that comes back late leaves the category icon in its place for good, so a
|
||||||
|
* page that does not get them in time is opened again, at most twice.
|
||||||
|
*/
|
||||||
|
async function placePhotos(page: Page): Promise<void> {
|
||||||
|
for (let attempt = 0; attempt < 3; attempt++) {
|
||||||
|
const loaded = await page
|
||||||
|
.waitForFunction(
|
||||||
|
() => {
|
||||||
|
const rows = [...document.querySelectorAll('[role="option"]')].slice(0, 8)
|
||||||
|
return rows.length > 0 && rows.every(row => row.querySelector('img')?.complete)
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
{ timeout: 15_000 },
|
||||||
|
)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false)
|
||||||
|
if (loaded) break
|
||||||
|
await openTrip(page)
|
||||||
|
}
|
||||||
|
await settle(page)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The addon the trip-addons guide switches; its row in the Addons area is the switch's row. */
|
||||||
|
const ADDON_ID = 'roadtrip'
|
||||||
|
const ADDON_NAME = 'Road trip'
|
||||||
|
const addonSwitch = (page: Page) => modal(page).getByRole('button', { name: ADDON_NAME, exact: true })
|
||||||
|
/** A row of the Addons area: the switch's parent, with the tile, the name, the badge and the line under it. */
|
||||||
|
const addonRow = (page: Page) => addonSwitch(page).locator('xpath=..')
|
||||||
|
/** The list of every trip addon, one row each. */
|
||||||
|
const addonList = (page: Page) => addonRow(page).locator('xpath=..')
|
||||||
|
|
||||||
|
/** Back to whatever the instance says for the addon the guide switched. */
|
||||||
|
async function resetAddon(page: Page): Promise<void> {
|
||||||
|
const { tripId } = seededTrip()
|
||||||
|
await page.request.put(`/api/trips/${tripId}/addons/${ADDON_ID}`, { data: { enabled: null } })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A panel of the trip's form by its heading: the heading, its CardHead, then the panel. */
|
||||||
|
const formPanel = (page: Page, heading: string) =>
|
||||||
|
modal(page).getByRole('heading', { name: heading, exact: true }).locator('xpath=../../..')
|
||||||
|
|
||||||
const SCRIPTS: Record<string, GuideScript> = {
|
const SCRIPTS: Record<string, GuideScript> = {
|
||||||
'add-member': {
|
'add-member': {
|
||||||
guide: guide('add-member'),
|
guide: guide('add-member'),
|
||||||
@@ -152,7 +208,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
act: p => pickArea(p, 'Sharing'),
|
act: p => pickArea(p, 'Sharing'),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// The first row of chips: Map & Plan, Bookings, Packing, Costs, Chat.
|
// The chips under Options: Map & Plan, Bookings, Packing, Costs, Chat, then the two options.
|
||||||
target: p => modal(p).getByRole('button', { name: 'Map & Plan' }).locator('xpath=..'),
|
target: p => modal(p).getByRole('button', { name: 'Map & Plan' }).locator('xpath=..'),
|
||||||
act: async p => {
|
act: async p => {
|
||||||
await modal(p).getByRole('button', { name: 'Packing', exact: true }).click()
|
await modal(p).getByRole('button', { name: 'Packing', exact: true }).click()
|
||||||
@@ -161,11 +217,8 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
// Options with its two chips; the pointer on the first shows what it leaves out.
|
// The first of the two options; the pointer on it shows what it leaves out.
|
||||||
target: p => modal(p).getByRole('button', { name: 'Travel & stays only' }).locator('xpath=../..'),
|
target: p => modal(p).getByRole('button', { name: 'Travel & stays only' }),
|
||||||
hover: async p => {
|
|
||||||
await modal(p).getByRole('button', { name: 'Travel & stays only' }).hover()
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
target: p => modal(p).getByRole('button', { name: 'Create link', exact: true }),
|
target: p => modal(p).getByRole('button', { name: 'Create link', exact: true }),
|
||||||
@@ -243,9 +296,71 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
],
|
],
|
||||||
cleanup: unlinkJournal,
|
cleanup: unlinkJournal,
|
||||||
},
|
},
|
||||||
|
'trip-addons': {
|
||||||
|
guide: guide('trip-addons'),
|
||||||
|
start: async p => {
|
||||||
|
await resetAddon(p)
|
||||||
|
await openSettings(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => area(p, 'Addons'),
|
||||||
|
act: async p => {
|
||||||
|
await pickArea(p, 'Addons')
|
||||||
|
await expect(addonSwitch(p)).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: addonList,
|
||||||
|
act: async p => {
|
||||||
|
const before = await addonSwitch(p).getAttribute('aria-pressed')
|
||||||
|
await addonSwitch(p).click()
|
||||||
|
await expect(addonSwitch(p)).not.toHaveAttribute('aria-pressed', before ?? '')
|
||||||
|
await expect(addonRow(p).getByText('This trip only', { exact: true })).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: addonRow,
|
||||||
|
// The result shows the trip with the addon switched.
|
||||||
|
act: async p => {
|
||||||
|
await closeModal(p)
|
||||||
|
await placePhotos(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: resetAddon,
|
||||||
|
},
|
||||||
|
'edit-trip-settings': {
|
||||||
|
guide: guide('edit-trip-settings'),
|
||||||
|
start: openSettings,
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => area(p, 'Edit Trip'),
|
||||||
|
act: async p => {
|
||||||
|
await pickArea(p, 'Edit Trip')
|
||||||
|
await expect(formPanel(p, 'Name and description')).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
only(p => formPanel(p, 'Name and description')),
|
||||||
|
{
|
||||||
|
target: p => modal(p).getByRole('button', { name: 'Update', exact: true }),
|
||||||
|
act: async p => {
|
||||||
|
await modal(p).getByRole('button', { name: 'Update', exact: true }).click()
|
||||||
|
await expect(modal(p)).toHaveCount(0, { timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
'collapse-columns': {
|
'collapse-columns': {
|
||||||
guide: guide('collapse-columns'),
|
guide: guide('collapse-columns'),
|
||||||
start: p => openTrip(p),
|
start: async p => {
|
||||||
|
await openTrip(p)
|
||||||
|
await placePhotos(p)
|
||||||
|
},
|
||||||
steps: [
|
steps: [
|
||||||
{
|
{
|
||||||
target: leftToggle,
|
target: leftToggle,
|
||||||
@@ -303,6 +418,30 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// The day has to stay open for that: the + at the end of a row belongs to
|
// The day has to stay open for that: the + at the end of a row belongs to
|
||||||
// the open day, and closing the day's details panel closes the day with it.
|
// the open day, and closing the day's details panel closes the day with it.
|
||||||
await openTripOnDay(p, 1)
|
await openTripOnDay(p, 1)
|
||||||
|
// The picture shows the rows around it, so their photos have to be in
|
||||||
|
// first; the spare place has none of its own and is left out of the wait.
|
||||||
|
for (let attempt = 0; attempt < 3; attempt++) {
|
||||||
|
const loaded = await p
|
||||||
|
.waitForFunction(
|
||||||
|
() => {
|
||||||
|
// A place's avatar is an <img> with the place's name as its alt
|
||||||
|
// while it has a photo, and the category icon once the photo is
|
||||||
|
// given up. Day 1's places sit in the day plan and in the places
|
||||||
|
// column, so each needs two loaded photos.
|
||||||
|
const names = ['Senso-ji Temple', 'teamLab Planets']
|
||||||
|
return names.every(name => {
|
||||||
|
const imgs = [...document.querySelectorAll('img')].filter(img => img.alt === name)
|
||||||
|
return imgs.length >= 2 && imgs.every(img => img.complete && img.naturalWidth > 0)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
null,
|
||||||
|
{ timeout: 20_000 },
|
||||||
|
)
|
||||||
|
.then(() => true)
|
||||||
|
.catch(() => false)
|
||||||
|
if (loaded) break
|
||||||
|
await openTripOnDay(p, 1)
|
||||||
|
}
|
||||||
const row = p.getByRole('option', { name: /^Tsukiji Outer Market/ })
|
const row = p.getByRole('option', { name: /^Tsukiji Outer Market/ })
|
||||||
await row.hover()
|
await row.hover()
|
||||||
const add = row.getByRole('button', { name: '+ Day' })
|
const add = row.getByRole('button', { name: '+ Day' })
|
||||||
@@ -331,6 +470,73 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
'trip-assistant': {
|
||||||
|
guide: guide('trip-assistant'),
|
||||||
|
// No provider answers in the run: fixtures-assistant.ts answers for it, and Apply plans the place for real.
|
||||||
|
start: async p => {
|
||||||
|
assistantRun = await mockTripAssistant(p)
|
||||||
|
await openTrip(p)
|
||||||
|
await expect(assistantLauncher(p)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
steps: [
|
||||||
|
{
|
||||||
|
target: p => assistantLauncher(p),
|
||||||
|
act: async p => {
|
||||||
|
await assistantLauncher(p).click()
|
||||||
|
await expect(assistantWindow(p).getByRole('textbox')).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
prepare: async p => {
|
||||||
|
await typeInto(p, assistantWindow(p).getByRole('textbox'), QUESTION)
|
||||||
|
await beat(p, 300)
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
target: p => assistantWindow(p).locator('form').last(),
|
||||||
|
hover: async p => { await assistantWindow(p).getByRole('button', { name: 'Send', exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await assistantWindow(p).getByRole('button', { name: 'Send', exact: true }).click()
|
||||||
|
await expect(changeCard(p)).toBeVisible({ timeout: 20_000 })
|
||||||
|
await expect(changeCard(p).getByRole('button', { name: 'Apply', exact: true })).toBeEnabled()
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => changeCard(p),
|
||||||
|
hover: async p => { await changeCard(p).getByRole('button', { name: 'Apply', exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await changeCard(p).getByRole('button', { name: 'Apply', exact: true }).click()
|
||||||
|
await expect(assistantWindow(p).getByRole('button', { name: 'Undo', exact: true }).first()).toBeVisible({ timeout: 20_000 })
|
||||||
|
// The place lands in day 1 of the plan behind the window, through the websocket.
|
||||||
|
await expect(p.getByText(SUGGESTED.name, { exact: true }).first()).toBeVisible({ timeout: 20_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => assistantWindow(p).getByRole('button', { name: 'Share in the trip chat' }).last(),
|
||||||
|
act: async p => {
|
||||||
|
await assistantWindow(p).getByRole('button', { name: 'Share in the trip chat' }).last().click()
|
||||||
|
await expect(confirmDialog(p).getByRole('button', { name: 'Share', exact: true })).toBeVisible({ timeout: 10_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
target: p => confirmDialog(p),
|
||||||
|
hover: async p => { await confirmDialog(p).getByRole('button', { name: 'Share', exact: true }).hover() },
|
||||||
|
act: async p => {
|
||||||
|
await confirmDialog(p).getByRole('button', { name: 'Share', exact: true }).click()
|
||||||
|
await expect(p.getByText('Shared in the trip chat').first()).toBeVisible({ timeout: 15_000 })
|
||||||
|
await settle(p)
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
cleanup: async p => {
|
||||||
|
await resetTripAssistant(p.request, assistantRun)
|
||||||
|
assistantRun = null
|
||||||
|
},
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
// ── Run ───────────────────────────────────────────────────────────────────────
|
// ── Run ───────────────────────────────────────────────────────────────────────
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { monthName, monthsAhead, year } from '../dates'
|
|||||||
import {
|
import {
|
||||||
PARTNER, ensureFused, ensureSeparate, clearPartnerDays, requestFusionFromPartner, clearFusionRequest,
|
PARTNER, ensureFused, ensureSeparate, clearPartnerDays, requestFusionFromPartner, clearFusionRequest,
|
||||||
shareWithAdmin, unshareWithAdmin, ownColor, setOwnColor, ensurePublicCalendar, calendarColors,
|
shareWithAdmin, unshareWithAdmin, ownColor, setOwnColor, ensurePublicCalendar, calendarColors,
|
||||||
restoreCalendarColors, companyHolidayFraction, setCompanyHoliday,
|
restoreCalendarColors, companyHolidayFraction, setCompanyHoliday, adminId, asMember,
|
||||||
} from './fixtures-vacay'
|
} from './fixtures-vacay'
|
||||||
import { vacayGuides, vacayContext } from '../../src/help/contexts/vacay'
|
import { vacayGuides, vacayContext } from '../../src/help/contexts/vacay'
|
||||||
import type { HelpGuide } from '../../src/help/types'
|
import type { HelpGuide } from '../../src/help/types'
|
||||||
@@ -218,8 +218,57 @@ const calendarRow = (page: Page): Locator => settings(page).getByPlaceholder('La
|
|||||||
/** The Fusion Request dialog, which opens by itself while an invite waits for an answer. */
|
/** The Fusion Request dialog, which opens by itself while an invite waits for an answer. */
|
||||||
const fusionDialog = (page: Page): Locator => page.getByRole('dialog', { name: 'Fusion Request' })
|
const fusionDialog = (page: Page): Locator => page.getByRole('dialog', { name: 'Fusion Request' })
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Log the admin's LOG_DAY through the API when it is not logged yet, and say
|
||||||
|
* whether it did. The colour guide's result shows logged days in the new
|
||||||
|
* colour; run on its own (a --grep re-render) the plan had none, so the
|
||||||
|
* result showed only the small dot in Persons changing.
|
||||||
|
*/
|
||||||
|
async function ensureOwnDay(page: Page): Promise<boolean> {
|
||||||
|
const date = nextMonthDate(LOG_DAY)
|
||||||
|
const res = await page.request.get(`/api/addons/vacay/entries/${YEAR}`)
|
||||||
|
if (!res.ok()) throw new Error(`could not load the entries: ${res.status()}`)
|
||||||
|
const me = await adminId(page)
|
||||||
|
const { entries } = (await res.json()) as { entries: { user_id: number; date: string }[] }
|
||||||
|
if (entries.some(e => e.user_id === me && e.date === date)) return false
|
||||||
|
await toggleOwnDay(page, date)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
async function toggleOwnDay(page: Page, date: string): Promise<void> {
|
||||||
|
const res = await page.request.post('/api/addons/vacay/entries/toggle', { data: { date, fraction: 1, kind: 'vacation' } })
|
||||||
|
if (!res.ok()) throw new Error(`could not toggle ${date}: ${res.status()}`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Days mira has off in her own plan while she shares it with the admin. Without
|
||||||
|
* them her shared calendar drew nothing on the grid, so the guide about rings
|
||||||
|
* on the grid showed none.
|
||||||
|
*/
|
||||||
|
const SHARED_DAYS = WORKDAYS.slice(6, 8).map(nextMonthDate)
|
||||||
|
|
||||||
|
/** Log (`on`) or clear mira's SHARED_DAYS in her own plan, leaving days already as wanted alone. */
|
||||||
|
async function setPartnerOwnDays(on: boolean): Promise<void> {
|
||||||
|
const member = await asMember()
|
||||||
|
try {
|
||||||
|
const me = (await (await member.get('/api/auth/me')).json()) as { user: { id: number } }
|
||||||
|
const res = await member.get(`/api/addons/vacay/entries/${YEAR}`)
|
||||||
|
if (!res.ok()) throw new Error(`could not load ${PARTNER.username}'s entries: ${res.status()}`)
|
||||||
|
const { entries } = (await res.json()) as { entries: { user_id: number; date: string }[] }
|
||||||
|
for (const date of SHARED_DAYS) {
|
||||||
|
const logged = entries.some(e => e.user_id === me.user.id && e.date === date)
|
||||||
|
if (logged === on) continue
|
||||||
|
const t = await member.post('/api/addons/vacay/entries/toggle', { data: { date, fraction: 1, kind: 'vacation' } })
|
||||||
|
if (!t.ok()) throw new Error(`could not toggle ${PARTNER.username}'s ${date}: ${t.status()}`)
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
await member.dispose()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** What a guide has to put back, read in its start and used in its cleanup. */
|
/** What a guide has to put back, read in its start and used in its cleanup. */
|
||||||
let savedColor = ''
|
let savedColor = ''
|
||||||
|
let loggedForColor = false
|
||||||
let savedCalendarColors = new Map<number, string>()
|
let savedCalendarColors = new Map<number, string>()
|
||||||
let christmasEveBefore: number | null = null
|
let christmasEveBefore: number | null = null
|
||||||
|
|
||||||
@@ -342,7 +391,12 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// The chip with its minus showing, rather than the minus alone: the step
|
// The chip with its minus showing, rather than the minus alone: the step
|
||||||
// says to hover the chip, and a ring round the tiny minus put its number
|
// says to hover the chip, and a ring round the tiny minus put its number
|
||||||
// on top of the year it belongs to.
|
// on top of the year it belongs to.
|
||||||
prepare: async p => { await yearChip(p, YEAR + 1).hover() },
|
// The chip clicked last keeps the focus, and a focused chip shows its
|
||||||
|
// minus too, so the picture had two minuses; the focus goes first.
|
||||||
|
prepare: async p => {
|
||||||
|
await p.evaluate(() => { (document.activeElement as HTMLElement | null)?.blur() })
|
||||||
|
await yearChip(p, YEAR + 1).hover()
|
||||||
|
},
|
||||||
target: p => yearChip(p, YEAR + 1),
|
target: p => yearChip(p, YEAR + 1),
|
||||||
// With the ring on the chip, this is what still fails the guide when the minus is gone.
|
// With the ring on the chip, this is what still fails the guide when the minus is gone.
|
||||||
act: async p => { await expect(yearChip(p, YEAR + 1).getByRole('button', { name: 'Remove year' })).toBeVisible() },
|
act: async p => { await expect(yearChip(p, YEAR + 1).getByRole('button', { name: 'Remove year' })).toBeVisible() },
|
||||||
@@ -552,6 +606,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
guide: guide('person-color'),
|
guide: guide('person-color'),
|
||||||
start: async p => {
|
start: async p => {
|
||||||
savedColor = await ownColor(p)
|
savedColor = await ownColor(p)
|
||||||
|
loggedForColor = await ensureOwnDay(p)
|
||||||
await openVacay(p)
|
await openVacay(p)
|
||||||
},
|
},
|
||||||
steps: [
|
steps: [
|
||||||
@@ -569,7 +624,10 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
cleanup: async p => { await setOwnColor(p, savedColor) },
|
cleanup: async p => {
|
||||||
|
await setOwnColor(p, savedColor)
|
||||||
|
if (loggedForColor) await toggleOwnDay(p, nextMonthDate(LOG_DAY))
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
invite: {
|
invite: {
|
||||||
@@ -725,6 +783,7 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
// so mira shares hers with the admin first. The page learns of it over
|
// so mira shares hers with the admin first. The page learns of it over
|
||||||
// the socket; a reload is the fallback should that message not come.
|
// the socket; a reload is the fallback should that message not come.
|
||||||
prepare: async p => {
|
prepare: async p => {
|
||||||
|
await setPartnerOwnDays(true)
|
||||||
await shareWithAdmin(p)
|
await shareWithAdmin(p)
|
||||||
const incoming = cardRow(p, 'Shared Calendars', PARTNER.username)
|
const incoming = cardRow(p, 'Shared Calendars', PARTNER.username)
|
||||||
if (!(await incoming.waitFor({ state: 'visible', timeout: 8_000 }).then(() => true, () => false))) await openVacay(p)
|
if (!(await incoming.waitFor({ state: 'visible', timeout: 8_000 }).then(() => true, () => false))) await openVacay(p)
|
||||||
@@ -735,7 +794,10 @@ const SCRIPTS: Record<string, GuideScript> = {
|
|||||||
hover: async p => { await cardRow(p, 'Shared Calendars', 'jonas').hover() },
|
hover: async p => { await cardRow(p, 'Shared Calendars', 'jonas').hover() },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
cleanup: unshareWithAdmin,
|
cleanup: async p => {
|
||||||
|
await unshareWithAdmin(p)
|
||||||
|
await setPartnerOwnDays(false)
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,18 @@
|
|||||||
|
// The chunk group that holds the lucide icons the app loads at startup (vite.config.js).
|
||||||
|
//
|
||||||
|
// Every lucide icon is a module of its own, and the plugin icon lookup
|
||||||
|
// (src/components/shared/PluginIcon.tsx) reaches all of them by name, from the navigation
|
||||||
|
// every page renders. Left to itself the bundler puts each icon that some other chunk
|
||||||
|
// also uses into a chunk of its own, so that neither side holds a copy: 187 files of a few
|
||||||
|
// hundred bytes each, every one a request of its own on a first visit and an entry of its
|
||||||
|
// own in the service worker's precache. In one group they are one file, whose hash changes
|
||||||
|
// only when lucide-react does.
|
||||||
|
//
|
||||||
|
// `tags: ['$initial']` for the reason the other groups carry it: without it the group would
|
||||||
|
// also take icons that today sit behind a lazy route and make them part of the first load.
|
||||||
|
export const ICON_CHUNK = {
|
||||||
|
name: 'vendor-icons',
|
||||||
|
priority: 20,
|
||||||
|
tags: ['$initial'],
|
||||||
|
test: /[\\/]node_modules[\\/]lucide-react[\\/]/,
|
||||||
|
};
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
512499AF65E091B2BBC9A7BB /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */; };
|
512499AF65E091B2BBC9A7BB /* UniformTypeIdentifiers.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = E45050B942C96E1ACCAB7CE9 /* UniformTypeIdentifiers.framework */; };
|
||||||
5480CCC12F42E9605044AB6B /* ShareHandoff.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56050CCA8DE4BEB4680D9E0B /* ShareHandoff.swift */; };
|
5480CCC12F42E9605044AB6B /* ShareHandoff.swift in Sources */ = {isa = PBXBuildFile; fileRef = 56050CCA8DE4BEB4680D9E0B /* ShareHandoff.swift */; };
|
||||||
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */; };
|
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */; };
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A01 /* FlightContent.swift in Sources */ = {isa = PBXBuildFile; fileRef = F11E0C0A9B7D4E2A8C3F5A02 /* FlightContent.swift */; };
|
||||||
5BBE9EE02A47EC67C31F5E21 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0A4B2C6C93971E884561CFA /* Localizable.strings */; };
|
5BBE9EE02A47EC67C31F5E21 /* Localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = D0A4B2C6C93971E884561CFA /* Localizable.strings */; };
|
||||||
612BB9680DC27BB8BF553060 /* TrekFamily.swift in Sources */ = {isa = PBXBuildFile; fileRef = A030A06726542A2D7F61C54B /* TrekFamily.swift */; };
|
612BB9680DC27BB8BF553060 /* TrekFamily.swift in Sources */ = {isa = PBXBuildFile; fileRef = A030A06726542A2D7F61C54B /* TrekFamily.swift */; };
|
||||||
634F4E63DC7C2A0027F0D118 /* Details.swift in Sources */ = {isa = PBXBuildFile; fileRef = F406A4A31BD875A880A7CA14 /* Details.swift */; };
|
634F4E63DC7C2A0027F0D118 /* Details.swift in Sources */ = {isa = PBXBuildFile; fileRef = F406A4A31BD875A880A7CA14 /* Details.swift */; };
|
||||||
@@ -305,6 +306,7 @@
|
|||||||
E5800E4ECECED54A47CDABAA /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
E5800E4ECECED54A47CDABAA /* tr */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = tr; path = tr.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
E6831E849332626BE8D54CEF /* ShareView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareView.swift; sourceTree = "<group>"; };
|
E6831E849332626BE8D54CEF /* ShareView.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = ShareView.swift; sourceTree = "<group>"; };
|
||||||
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BookingsContent.swift; sourceTree = "<group>"; };
|
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = BookingsContent.swift; sourceTree = "<group>"; };
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A02 /* FlightContent.swift */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = sourcecode.swift; path = FlightContent.swift; sourceTree = "<group>"; };
|
||||||
EAFBDD97043B34E4B64FDA86 /* pt-BR */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
EAFBDD97043B34E4B64FDA86 /* pt-BR */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = "pt-BR"; path = "pt-BR.lproj/Localizable.strings"; sourceTree = "<group>"; };
|
||||||
EC8D1292C9FC6430C059960A /* nl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
EC8D1292C9FC6430C059960A /* nl */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.plist.strings; name = nl; path = nl.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
ECC80E1314B31ED2D2347411 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
ECC80E1314B31ED2D2347411 /* ar */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = ar; path = ar.lproj/Localizable.strings; sourceTree = "<group>"; };
|
||||||
@@ -538,6 +540,7 @@
|
|||||||
DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */,
|
DE6873D246AC6B8E2CB6C8B4 /* TripContent.swift */,
|
||||||
24B175DE91E1E6E850DB0285 /* TodayContent.swift */,
|
24B175DE91E1E6E850DB0285 /* TodayContent.swift */,
|
||||||
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */,
|
E6D2F4930E5F152C8090C4F8 /* BookingsContent.swift */,
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A02 /* FlightContent.swift */,
|
||||||
AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */,
|
AEF7DCAA1AEE67F1291668D1 /* TodosContent.swift */,
|
||||||
);
|
);
|
||||||
name = TREKWidgets;
|
name = TREKWidgets;
|
||||||
@@ -849,6 +852,7 @@
|
|||||||
8FC5873BE6A8CB2AFB31A46A /* TripContent.swift in Sources */,
|
8FC5873BE6A8CB2AFB31A46A /* TripContent.swift in Sources */,
|
||||||
9A175689CFCC630BE9BB9EE1 /* TodayContent.swift in Sources */,
|
9A175689CFCC630BE9BB9EE1 /* TodayContent.swift in Sources */,
|
||||||
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */,
|
5A4D344328829E0F0B4D2B94 /* BookingsContent.swift in Sources */,
|
||||||
|
F11E0C0A9B7D4E2A8C3F5A01 /* FlightContent.swift in Sources */,
|
||||||
F1E29B18C5B1E75A5BC01B57 /* TodosContent.swift in Sources */,
|
F1E29B18C5B1E75A5BC01B57 /* TodosContent.swift in Sources */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
<key>CFBundleInfoDictionaryVersion</key>
|
<key>CFBundleInfoDictionaryVersion</key>
|
||||||
<string>6.0</string>
|
<string>6.0</string>
|
||||||
<key>CFBundleName</key>
|
<key>CFBundleName</key>
|
||||||
<string>$(PRODUCT_NAME)</string>
|
<string>TREK</string>
|
||||||
<key>CFBundlePackageType</key>
|
<key>CFBundlePackageType</key>
|
||||||
<string>APPL</string>
|
<string>APPL</string>
|
||||||
<key>CFBundleShortVersionString</key>
|
<key>CFBundleShortVersionString</key>
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user