-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not update deprecated connectors (#4674)
* Do not update deprecated connectors * Fix various connectorDefinition issues: disappearing button, wrong id used for destination update
- Loading branch information
Showing
26 changed files
with
349 additions
and
656 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
92 changes: 92 additions & 0 deletions
92
airbyte-webapp/src/components/hooks/services/useConnector.test.tsx
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,92 @@ | ||
import { makeCacheProvider, makeRenderRestHook } from "@rest-hooks/test"; | ||
import { act } from "@testing-library/react-hooks"; | ||
|
||
import { sourceDefinitionService } from "core/domain/connector/SourceDefinitionService"; | ||
import { destinationDefinitionService } from "core/domain/connector/DestinationDefinitionService"; | ||
|
||
import useConnector from "./useConnector"; | ||
import SourceDefinitionResource from "core/resources/SourceDefinition"; | ||
import DestinationDefinitionResource from "core/resources/DestinationDefinition"; | ||
|
||
jest.mock("core/domain/connector/SourceDefinitionService"); | ||
jest.mock("core/domain/connector/DestinationDefinitionService"); | ||
|
||
const renderRestHook = makeRenderRestHook(makeCacheProvider); | ||
const results = [ | ||
{ | ||
request: SourceDefinitionResource.listShape(), | ||
params: { workspaceId: "5ae6b09b-fdec-41af-aaf7-7d94cfc33ef6" }, | ||
result: { | ||
sourceDefinitions: [ | ||
{ | ||
sourceDefinitionId: "sid1", | ||
latestDockerImageTag: "0.0.2", | ||
dockerImageTag: "0.0.1", | ||
}, | ||
{ | ||
sourceDefinitionId: "sid2", | ||
latestDockerImageTag: "", | ||
dockerImageTag: "0.0.1", | ||
}, | ||
], | ||
}, | ||
}, | ||
{ | ||
request: DestinationDefinitionResource.listShape(), | ||
params: { workspaceId: "5ae6b09b-fdec-41af-aaf7-7d94cfc33ef6" }, | ||
result: { | ||
destinationDefinitions: [ | ||
{ | ||
destinationDefinitionId: "did1", | ||
latestDockerImageTag: "0.0.2", | ||
dockerImageTag: "0.0.1", | ||
}, | ||
{ | ||
destinationDefinitionId: "did2", | ||
latestDockerImageTag: "", | ||
dockerImageTag: "0.0.1", | ||
}, | ||
], | ||
}, | ||
}, | ||
]; | ||
|
||
test("should not call sourceDefinition.updateVersion for deprecated call", async () => { | ||
const { result, waitForNextUpdate } = renderRestHook(() => useConnector(), { | ||
results, | ||
}); | ||
|
||
(sourceDefinitionService.update as jest.Mock).mockResolvedValue([]); | ||
|
||
act(() => { | ||
result.current.updateAllSourceVersions(); | ||
}); | ||
|
||
await waitForNextUpdate(); | ||
|
||
expect(sourceDefinitionService.update).toHaveBeenCalledTimes(1); | ||
expect(sourceDefinitionService.update).toHaveBeenCalledWith({ | ||
dockerImageTag: "0.0.2", | ||
sourceDefinitionId: "sid1", | ||
}); | ||
}); | ||
|
||
test("should not call destinationDefinition.updateVersion for deprecated call", async () => { | ||
const { result, waitForNextUpdate } = renderRestHook(() => useConnector(), { | ||
results, | ||
}); | ||
|
||
(destinationDefinitionService.update as jest.Mock).mockResolvedValue([]); | ||
|
||
act(() => { | ||
result.current.updateAllDestinationVersions(); | ||
}); | ||
|
||
await waitForNextUpdate(); | ||
|
||
expect(destinationDefinitionService.update).toHaveBeenCalledTimes(1); | ||
expect(destinationDefinitionService.update).toHaveBeenCalledWith({ | ||
dockerImageTag: "0.0.2", | ||
destinationDefinitionId: "did1", | ||
}); | ||
}); |
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
14 changes: 14 additions & 0 deletions
14
airbyte-webapp/src/core/domain/connector/DestinationDefinitionService.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,14 @@ | ||
import { AirbyteRequestService } from "core/request/AirbyteRequestService"; | ||
import { DestinationDefinition } from "core/resources/DestinationDefinition"; | ||
|
||
class DestinationDefinitionService extends AirbyteRequestService { | ||
get url() { | ||
return "destination_definitions"; | ||
} | ||
|
||
public update(body: DestinationDefinition): Promise<DestinationDefinition> { | ||
return this.fetch(`${this.url}/update`, body) as any; | ||
} | ||
} | ||
|
||
export const destinationDefinitionService = new DestinationDefinitionService(); |
14 changes: 14 additions & 0 deletions
14
airbyte-webapp/src/core/domain/connector/SourceDefinitionService.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,14 @@ | ||
import { AirbyteRequestService } from "core/request/AirbyteRequestService"; | ||
import { SourceDefinition } from "core/resources/SourceDefinition"; | ||
|
||
class SourceDefinitionService extends AirbyteRequestService { | ||
get url() { | ||
return "source_definitions"; | ||
} | ||
|
||
public update(body: SourceDefinition): Promise<SourceDefinition> { | ||
return this.fetch(`${this.url}/update`, body) as any; | ||
} | ||
} | ||
|
||
export const sourceDefinitionService = new SourceDefinitionService(); |
Oops, something went wrong.