Mientras tanto, una nueva imagen está disponible cicoub13/gladys:blinking-lights. Lo que se ha corregido es que la acción sea bloqueante.
Por ejemplo, si añades una acción « Enviar un mensaje », esto solo se hará después de que la luz haya terminado de parpadear.
2 formas de resolver esto
Primero, si puedes influir en el tiempo en las pruebas.
https://sinonjs.org/releases/latest/fake-timers/
De lo contrario, puedes usar tiempos mucho más pequeños en tus pruebas para que pasen más rápido.
Me había decantado por la opción de reloj falso (que me parece más sencilla), pero no funcionaba. Lo voy a volver a intentar, gracias
cce66
15 Febrero, 2024 15:51
24
hola @cicoub13
Solo dos pequeñas observaciones:
¿Por qué no multiplicar tu constante blinking_time directamente en su declaración para evitar el cálculo en el bucle
const blinkingTime = action.blinking_time * 1000 ;
Siempre he utilizado nombres de variables duplicados (ii en lugar de i) ¡es más fácil de rastrear después!
Por lo demás, no soy lo suficientemente experto en este lenguaje.
Hola @cicoub ,
No sé si esto puede ayudarte y si el caso es el mismo:
server/test/services/netatmo/lib/netatmo.pollRefreshingValues.test.js
… espero …
Me costó mucho hacerlo funcionar. Pero con una mezcla de copilot / chatGPT / stackoverflow, funcionó con esta combinación (el primer test en particular)
Notarás esta parte en el segundo test:
clock.tick(120 * 1000);
clock.restore();
// eslint-disable-next-line no-promise-executor-return
await new Promise((resolve) => setTimeout(resolve, 50));
Para pasar 120 segundos, detener el reloj y realizar la Promesa. No funcionaba sin el clock.restore() porque entra en conflicto de gestión de reloj (de lo que entendí… ^^)
Funciona con los temporizadores falsos de SinonJS. Tuve que actualizar a la versión 8.1.1 (anteriormente 7.2.4 ) para beneficiarme de clock.tickAsync().
Por cierto, ya están en la versión 17
Gracias @Terdious y @pierre-gilles , no era fácil hacer estas pruebas con la noción de tiempo
Te aviso cuando todo esté listo
PR lista (funcionalmente, desarrollo, pruebas)
master ← cicoub13:feat-blinking-light-action
ouvert 08:34PM - 25 Jan 24 UTC
### Pull Request check-list
To ensure your Pull Request can be accepted as fa… st as possible, make sure to review and check all of these items:
- [x] If your changes affects code, did your write the tests?
- [x] Are tests passing? (`npm test` on both front/server)
- [x] Is the linter passing? (`npm run eslint` on both front/server)
- [x] Did you run prettier? (`npm run prettier` on both front/server)
- [x] If you are adding a new features/services, did you run integration comparator? (`npm run compare-translations` on front)
- [x] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community ([french forum](https://community.gladysassistant.com/)/[english forum](https://en-community.gladysassistant.com/)) for testing before merging.
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
### Description of change
Please provide a description of the change here. It's always best with screenshots, so don't hesitate to add some!
¡Gracias por la PR @cicoub13 !
He encontrado un pequeño error al hacer una prueba real:
master ← cicoub13:feat-blinking-light-action
ouvert 08:34PM - 25 Jan 24 UTC
### Pull Request check-list
To ensure your Pull Request can be accepted as fa… st as possible, make sure to review and check all of these items:
- [x] If your changes affects code, did your write the tests?
- [x] Are tests passing? (`npm test` on both front/server)
- [x] Is the linter passing? (`npm run eslint` on both front/server)
- [x] Did you run prettier? (`npm run prettier` on both front/server)
- [x] If you are adding a new features/services, did you run integration comparator? (`npm run compare-translations` on front)
- [x] Did you test this pull request in real life? With real devices? If this development is a big feature or a new service, we recommend that you provide a Docker image to the community ([french forum](https://community.gladysassistant.com/)/[english forum](https://en-community.gladysassistant.com/)) for testing before merging.
NOTE: these things are not required to open a PR and can be done afterwards / while the PR is open.
### Description of change
Please provide a description of the change here. It's always best with screenshots, so don't hesitate to add some!
Pero nada grave, ¡el comportamiento funciona bien por lo demás!
¡Gracias por el arreglo @cicoub13 ! Para mí está bien, está fusionado en master y saldrá en la próxima versión de Gladys
Esta funcionalidad está disponible en Gladys Assistant 4.38
Cierro este tema para liberar los votos, no dudes en crear otros temas en caso de errores/comentarios
Gracias a @cicoub13 por el desarrollo