1
0
Fork 0
mirror of synced 2024-07-07 23:35:49 +12:00

Merge pull request #13726 from Budibase/fix-search-tests

Remove most of the date mocking in search.spec.ts
This commit is contained in:
Sam Rose 2024-05-20 12:48:46 +01:00 committed by GitHub
commit efa0c8289f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -19,12 +19,8 @@ import {
} from "@budibase/types"
import _ from "lodash"
import tk from "timekeeper"
import { mocks } from "@budibase/backend-core/tests"
import { encodeJSBinding } from "@budibase/string-templates"
const serverTime = mocks.date.MOCK_DATE
tk.freeze(serverTime)
describe.each([
["lucene", undefined],
["sqs", undefined],
@ -252,8 +248,14 @@ describe.each([
describe("bindings", () => {
let globalUsers: any = []
const future = new Date(serverTime.getTime())
future.setDate(future.getDate() + 30)
const serverTime = new Date()
// In MariaDB and MySQL we only store dates to second precision, so we need
// to remove milliseconds from the server time to ensure searches work as
// expected.
serverTime.setMilliseconds(0)
const future = new Date(serverTime.getTime() + 1000 * 60 * 60 * 24 * 30)
const rows = (currentUser: User) => {
return [
@ -359,20 +361,22 @@ describe.each([
})
it("should parse the date binding and return all rows after the resolved value", async () => {
await expectQuery({
range: {
appointment: {
low: "{{ [now] }}",
high: "9999-00-00T00:00:00.000Z",
await tk.withFreeze(serverTime, async () => {
await expectQuery({
range: {
appointment: {
low: "{{ [now] }}",
high: "9999-00-00T00:00:00.000Z",
},
},
},
}).toContainExactly([
{
name: config.getUser().firstName,
appointment: future.toISOString(),
},
{ name: "serverDate", appointment: serverTime.toISOString() },
])
}).toContainExactly([
{
name: config.getUser().firstName,
appointment: future.toISOString(),
},
{ name: "serverDate", appointment: serverTime.toISOString() },
])
})
})
it("should parse the date binding and return all rows before the resolved value", async () => {