In der Zwischenzeit ist ein neues Bild verfügbar cicoub13/gladys:blinking-lights. Was behoben wurde, ist die Tatsache, dass die Aktion blockierend ist.
Zum Beispiel, wenn Sie eine Aktion « Nachricht senden » hinzufügen, wird dies erst erfolgen, nachdem das Licht aufgehört hat zu blinken.
2 Möglichkeiten, das zu lösen
Zuerst, wenn du die Zeit in den Tests beeinflussen kannst!
https://sinonjs.org/releases/latest/fake-timers/
Ansonsten kannst du in deinen Tests viel kleinere Zeiten verwenden, damit es schneller durchläuft.
Ich war auf die Option Fake-Uhr (die mir einfacher erscheint) gegangen, aber es hat nicht funktioniert. Ich werde es nochmal versuchen, danke.
cce66
15. Februar 2024 um 15:51
24
hallo @cicoub13
Nur zwei kleine Anmerkung:
Warum multiplizierst du deine Konstante blinking_time nicht direkt bei ihrer Deklaration, um die Berechnung in der Schleife zu vermeiden?
const blinkingTime = action.blinking_time * 1000 ;
Ich habe immer doppelte Variablennamen verwendet (ii statt i) — das ist später leichter nachzuverfolgen!
Ansonsten bin ich in dieser Sprache nicht gut genug bewandert!
Hallo @cicoub ,
Ich weiß nicht, ob dir das weiterhilft und ob der Fall zutrifft:
server/test/services/netatmo/lib/netatmo.pollRefreshingValues.test.js
… ich hoffe …
Ich habe mich damit herumgeschlagen, es zum Laufen zu bringen. Aber mit einer Mischung aus Copilot / ChatGPT / Stackoverflow hat es mit dieser Kombination funktioniert (insbesondere der erste Test)
Du wirst diesen Teil im zweiten Test bemerken:
clock.tick(120 * 1000);
clock.restore();
// eslint-disable-next-line no-promise-executor-return
await new Promise((resolve) => setTimeout(resolve, 50));
Um 120 Sekunden zu überspringen, dann den clock zu stoppen und das Versprechen zu erfüllen. Es hat nicht funktioniert ohne das clock.restore(), weil es zu einem Konflikt in der Zeiterfassung kommt (soweit ich das verstanden habe… ^^)
Das ist korrigiert, danke
Das funktioniert mit den Fake-Timern von SinonJS. Ich musste auf Version 8.1.1 aktualisieren (zuvor 7.2.4 ), um clock.tickAsync() nutzen zu können.
Übrigens, sie sind bereits bei Version 17
Danke @Terdious und @pierre-gilles , das war nicht einfach, diese Tests mit Zeitkonzepten
Ich sage dir Bescheid, wenn alles fertig ist
PR bereit (funktional, Entwicklung, Tests)
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!
Danke für die PR @cicoub13
Ich habe einen kleinen Bug beim Testen in der Praxis gefunden:
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!
Aber nichts Schlimmes, ansonsten funktioniert das Verhalten gut!
Danke für das Fix @cicoub13 ! Für mich ist es okay, es ist in master gemerged und wird in der nächsten Version von Gladys enthalten sein
Diese Funktion ist in Gladys Assistant 4.38 verfügbar
Ich schließe dieses Thema, um die Stimmen freizugeben. Zögern Sie nicht, bei Problemen/Feedback andere Themen zu erstellen
Vielen Dank an @cicoub13 für die Entwicklung