-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remove sub-1-hour frequency options, and add current connection frequ…
…ency to dropdown
- Loading branch information
Showing
4 changed files
with
72 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
airbyte-webapp/src/views/Connection/ConnectionForm/formConfig.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { renderHook } from "@testing-library/react-hooks"; | ||
|
||
import FrequencyConfig from "config/FrequencyConfig.json"; | ||
import { ConnectionScheduleTimeUnit } from "core/request/AirbyteClient"; | ||
import { TestWrapper as wrapper } from "utils/testutils"; | ||
|
||
import { useFrequencyDropdownData } from "./formConfig"; | ||
|
||
describe("useFrequencyDropdownData", () => { | ||
it("should return only default frequencies when no additional frequency is provided", () => { | ||
const { result } = renderHook(() => useFrequencyDropdownData(undefined), { wrapper }); | ||
const stringifiedResult = JSON.stringify(result.current.map((item) => item.value)); | ||
const stringifiedConfig = JSON.stringify(FrequencyConfig.map((item) => item.config)); | ||
|
||
expect(stringifiedResult).toEqual(stringifiedConfig); | ||
}); | ||
|
||
it("should return only default frequencies when additional frequency is already present", () => { | ||
const additionalFrequency = { | ||
units: 1, | ||
timeUnit: ConnectionScheduleTimeUnit["hours"], | ||
}; | ||
const { result } = renderHook(() => useFrequencyDropdownData(additionalFrequency), { wrapper }); | ||
const stringifiedResult = JSON.stringify(result.current.map((item) => item.value)); | ||
const stringifiedConfig = JSON.stringify(FrequencyConfig.map((item) => item.config)); | ||
|
||
expect(stringifiedResult).toEqual(stringifiedConfig); | ||
}); | ||
|
||
it("should include additional frequency when provided and unique", () => { | ||
const additionalFrequency = { | ||
units: 7, | ||
timeUnit: ConnectionScheduleTimeUnit["minutes"], | ||
}; | ||
const { result } = renderHook(() => useFrequencyDropdownData(additionalFrequency), { wrapper }); | ||
|
||
expect(result.current.length).toEqual(FrequencyConfig.length + 1); | ||
expect( | ||
result.current.some( | ||
(item) => item.label === "Every 7 minutes" && item.value.units === 7 && item.value.timeUnit === "minutes" | ||
) | ||
).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters