Test: don't depend on the order of two contact messages sent in the same millisecond
Both rows can get the same created_at, and then their random ids order them, so the test failed about half the time on fast runners (Unit tests (1/2) on this pull request).
1 file changed+5−4
modifiedapps/diffinery/test/unit/contact.test.ts+5−4View file
| @@ -157,10 +157,11 @@ | ||
| 157 | 157 | await submitMessage(env, audit, input("[email protected]", { message: "Second message, about another." }), null, "203.0.113.9"); |
| 158 | 158 | expect(rows(DB)).toHaveLength(2); |
| 159 | 159 | await confirmMessage(env, audit, tokenOf(queued[1])); |
| 160 | - expect(rows(DB).map((r) => [r.message, r.state])).toEqual([ | |
| 161 | - ["First message, about one thing.", "unconfirmed"], | |
| 162 | - ["Second message, about another.", "new"], | |
| 163 | - ]); | |
| 160 | + // Both can have the same created_at millisecond, and then the random id orders them. | |
| 161 | + expect(Object.fromEntries(rows(DB).map((r) => [r.message, r.state]))).toEqual({ | |
| 162 | + "First message, about one thing.": "unconfirmed", | |
| 163 | + "Second message, about another.": "new", | |
| 164 | + }); | |
| 164 | 165 | }); |
| 165 | 166 | |
| 166 | 167 | it("limits one network, one address and the whole form per day, quietly past the last two", async () => { |