Skip to content

Commit

Permalink
Cleanup requestWorkspaceId
Browse files Browse the repository at this point in the history
  • Loading branch information
edmundito committed Jan 30, 2023
1 parent 96a712d commit fd30bdd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 14 deletions.
21 changes: 9 additions & 12 deletions airbyte-webapp-e2e-tests/cypress/commands/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ConectionGetBody,
ConnectionGetBody,
Connection,
ConnectionCreateRequestBody,
ConnectionsList,
Expand All @@ -13,16 +13,6 @@ import { getWorkspaceId, setWorkspaceId } from "./workspace";

const getApiUrl = (path: string): string => `http://localhost:8001/api/v1${path}`;

export const requestWorkspaceId = () =>
cy.request("POST", getApiUrl("/workspaces/list")).then((response) => {
expect(response.status).to.eq(200);
const {
workspaces: [{ workspaceId }],
} = response.body;

setWorkspaceId(workspaceId as string);
});

const apiRequest = <T = void>(
method: Cypress.HttpMethod,
path: string,
Expand All @@ -34,6 +24,13 @@ const apiRequest = <T = void>(
return response.body;
});

export const requestWorkspaceId = () =>
apiRequest<{ workspaces: Array<{ workspaceId: string }> }>("POST", "/workspaces/list").then(
({ workspaces: [{ workspaceId }] }) => {
setWorkspaceId(workspaceId);
}
);

export const requestConnectionsList = () =>
apiRequest<ConnectionsList>("POST", "/connections/list", { workspaceId: getWorkspaceId() });

Expand All @@ -43,7 +40,7 @@ export const requestCreateConnection = (body: ConnectionCreateRequestBody) =>
export const requestUpdateConnection = (body: Record<string, unknown>) =>
apiRequest<Connection>("POST", "/web_backend/connections/update", body);

export const requestGetConnection = (body: ConectionGetBody) =>
export const requestGetConnection = (body: ConnectionGetBody) =>
apiRequest<Connection>("POST", "/web_backend/connections/get", body);

export const requestDeleteConnection = (connectionId: string) =>
Expand Down
2 changes: 1 addition & 1 deletion airbyte-webapp-e2e-tests/cypress/commands/api/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface ConnectionCreateRequestBody {
syncCatalog: SyncCatalog;
}

export interface ConectionGetBody {
export interface ConnectionGetBody {
connectionId: string;
withRefreshedCatalog?: boolean;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ describe("Connection - Auto-detect schema changes", () => {
runDbQuery(dropUsersTableQuery);
runDbQuery(createUsersTableQuery);

requestWorkspaceId()?.then(() => {
requestWorkspaceId().then(() => {
const sourceRequestBody = getPostgresCreateSourceBody(appendRandomString("Auto-detect schema Source"));
const destinationRequestBody = getPostgresCreateDestinationBody(
appendRandomString("Auto-detect schema Destination")
Expand Down

0 comments on commit fd30bdd

Please sign in to comment.