Zoom/Hubspot Tests with MSW mocking of requests initiated from Next.js server (#3210)

* Add code from previous PR

* Remove env variables from wrong place

* Fix tests

* Remove dead code

* Package.json updates

* Fix eslint error

* Fix issue due to conflict resolution

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: zomars <[email protected]>
This commit is contained in:
authored and GitHub committed 2022-08-26 12:44:02 -06:00
1 parent e0744a4857
commit 4ef666a610
20 files changed
+916 -106

No files matched your search

@@ -21,8 +21,24 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
);
if (result.status !== 200) {
let errorMessage = "Something is wrong with Zoom API";
try {
const responseBody = await result.json();
errorMessage = responseBody.error;
} catch (e) {}
res.status(400).json({ message: errorMessage });
return;
}
const responseBody = await result.json();
if (responseBody.error) {
res.status(400).json({ message: responseBody.error });
return;
}
responseBody.expiry_date = Math.round(Date.now() + responseBody.expires_in * 1000);
delete responseBody.expires_in;
@@ -244,7 +244,7 @@ const ZoomVideoApiAdapter = (credential: Credential): VideoApiAdapter => {
url: result.join_url,
});
}
return Promise.reject(new Error("Failed to create meeting"));
return Promise.reject(new Error("Failed to create meeting. Response is " + JSON.stringify(result)));
},
deleteMeeting: async (uid: string): Promise<void> => {
await fetchZoomApi(`meetings/${uid}`, {
+10 -1
View File
@@ -4,6 +4,10 @@ import dayjs, { Dayjs } from "@calcom/dayjs";
import { getErrorFromUnknown } from "@calcom/lib/errors";
import { serverConfig } from "@calcom/lib/serverConfig";
declare let global: {
E2E_EMAILS?: Record<string, unknown>[];
};
export default class BaseEmail {
name = "";
@@ -23,7 +27,12 @@ export default class BaseEmail {
return {};
}
public sendEmail() {
if (process.env.NEXT_PUBLIC_IS_E2E) return new Promise((r) => r("Skipped sendEmail for E2E"));
if (process.env.NEXT_PUBLIC_IS_E2E) {
global.E2E_EMAILS = global.E2E_EMAILS || [];
global.E2E_EMAILS.push(this.getNodeMailerPayload());
console.log("Skipped Sending Email");
return new Promise((r) => r("Skipped sendEmail for E2E"));
}
new Promise((resolve, reject) =>
nodemailer
.createTransport(this.getMailerOptions().transport)
+1 -1
View File
@@ -63,7 +63,7 @@ export default function ConfirmationDialogContent(props: PropsWithChildren<Confi
<div className="mt-5 flex flex-row-reverse gap-x-2 sm:mt-8">
<DialogClose disabled={isLoading} onClick={onConfirm} asChild>
{confirmBtn || (
<Button color="primary" loading={isLoading}>
<Button data-testid="confirm-button" color="primary" loading={isLoading}>
{isLoading ? loadingText : confirmBtnText}
</Button>
)}