Skip to content

Scheduling infrastructure for absolutely everyone.

chore: Don't render certain components when running meticulous tests (#10772)

Keith Williams43b3d6844755
diff --git a/apps/web/components/eventtype/EventAdvancedTab.tsx b/apps/web/components/eventtype/EventAdvancedTab.tsx
index 2d5f17c66db..540021f92a4 100644
--- a/apps/web/components/eventtype/EventAdvancedTab.tsx
+++ b/apps/web/components/eventtype/EventAdvancedTab.tsx
@@ -35,6 +35,7 @@ import {
Tooltip,
} from "@calcom/ui";
import { Copy, Edit } from "@calcom/ui/components/icon";
+import { IS_VISUAL_REGRESSION_TESTING } from "@calcom/web/constants";
import RequiresConfirmationController from "./RequiresConfirmationController";
@@ -286,36 +287,38 @@ export const EventAdvancedTab = ({ eventType, team }: Pick<EventTypeSetupProps,
}}>
{/* Textfield has some margin by default we remove that so we can keep consitant aligment */}
<div className="lg:-ml-2">
- <TextField
- disabled
- name="hashedLink"
- label={t("private_link_label")}
- data-testid="generated-hash-url"
- labelSrOnly
- type="text"
- hint={t("private_link_hint")}
- defaultValue={placeholderHashedLink}
- addOnSuffix={
- <Tooltip content={eventType.hashedLink ? t("copy_to_clipboard") : t("enabled_after_update")}>
- <Button
- color="minimal"
- size="sm"
- type="button"
- className="hover:stroke-3 hover:text-emphasis min-w-fit !py-0 px-0 hover:bg-transparent"
- aria-label="copy link"
- onClick={() => {
- navigator.clipboard.writeText(placeholderHashedLink);
- if (eventType.hashedLink) {
- showToast(t("private_link_copied"), "success");
- } else {
- showToast(t("enabled_after_update_description"), "warning");
- }
- }}>
- <Copy className="h-4 w-4" />
- </Button>
- </Tooltip>
- }
- />
+ {!IS_VISUAL_REGRESSION_TESTING && (
+ <TextField
+ disabled
+ name="hashedLink"
+ label={t("private_link_label")}
+ data-testid="generated-hash-url"
+ labelSrOnly
+ type="text"
+ hint={t("private_link_hint")}
+ defaultValue={placeholderHashedLink}
+ addOnSuffix={
+ <Tooltip content={eventType.hashedLink ? t("copy_to_clipboard") : t("enabled_after_update")}>
+ <Button
+ color="minimal"
+ size="sm"
+ type="button"
+ className="hover:stroke-3 hover:text-emphasis min-w-fit !py-0 px-0 hover:bg-transparent"
+ aria-label="copy link"
+ onClick={() => {
+ navigator.clipboard.writeText(placeholderHashedLink);
+ if (eventType.hashedLink) {
+ showToast(t("private_link_copied"), "success");
+ } else {
+ showToast(t("enabled_after_update_description"), "warning");
+ }
+ }}>
+ <Copy className="h-4 w-4" />
+ </Button>
+ </Tooltip>
+ }
+ />
+ )}
</div>
</SettingsToggle>
<hr className="border-subtle" />
diff --git a/apps/web/constants.ts b/apps/web/constants.ts
new file mode 100644
index 00000000000..c19877c5ef3
--- /dev/null
+++ b/apps/web/constants.ts
@@ -0,0 +1 @@
+export const IS_VISUAL_REGRESSION_TESTING = Boolean(globalThis.window?.Meticulous?.isRunningAsTest);
diff --git a/apps/web/pages/_document.tsx b/apps/web/pages/_document.tsx
index 3d6fdae7365..006b73c8fad 100644
--- a/apps/web/pages/_document.tsx
+++ b/apps/web/pages/_document.tsx
@@ -51,7 +51,7 @@ class MyDocument extends Document<Props> {
<meta name="msapplication-TileColor" content="#ff0000" />
<meta name="theme-color" media="(prefers-color-scheme: light)" content="#f9fafb" />
<meta name="theme-color" media="(prefers-color-scheme: dark)" content="#1C1C1C" />
- {(!IS_PRODUCTION || process.env.VERCEL_ENV === "preview") && (
+ {!IS_PRODUCTION && process.env.VERCEL_ENV === "preview" && (
// eslint-disable-next-line @next/next/no-sync-scripts
<script
data-project-id="KjpMrKTnXquJVKfeqmjdTffVPf1a6Unw2LZ58iE4"
diff --git a/packages/features/settings/TimezoneChangeDialog.tsx b/packages/features/settings/TimezoneChangeDialog.tsx
index 20a38fa7676..34865396e5e 100644
--- a/packages/features/settings/TimezoneChangeDialog.tsx
+++ b/packages/features/settings/TimezoneChangeDialog.tsx
@@ -5,6 +5,7 @@ import dayjs from "@calcom/dayjs";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc/react";
import { Dialog, DialogClose, DialogContent, DialogFooter, showToast } from "@calcom/ui";
+import { IS_VISUAL_REGRESSION_TESTING } from "@calcom/web/constants";
export default function TimezoneChangeDialog() {
const { t } = useLocale();
@@ -43,7 +44,7 @@ export default function TimezoneChangeDialog() {
const tzDifferent =
!isLoading && dayjs.tz(undefined, currentTz).utcOffset() !== dayjs.tz(undefined, userTz).utcOffset();
const showDialog = tzDifferent && !document.cookie.includes("calcom-timezone-dialog=1");
- setOpen(showDialog);
+ setOpen(!IS_VISUAL_REGRESSION_TESTING && showDialog);
}, [currentTz, isLoading, userTz]);
// save cookie to not show again
diff --git a/packages/features/shell/Shell.tsx b/packages/features/shell/Shell.tsx
index fb57af4cdb0..0b4e5b881ab 100644
--- a/packages/features/shell/Shell.tsx
+++ b/packages/features/shell/Shell.tsx
@@ -77,6 +77,7 @@ import {
Zap,
} from "@calcom/ui/components/icon";
import { Discord } from "@calcom/ui/components/icon/Discord";
+import { IS_VISUAL_REGRESSION_TESTING } from "@calcom/web/constants";
import { useOrgBranding } from "../ee/organizations/context/provider";
import FreshChatProvider from "../ee/support/lib/freshchat/FreshChatProvider";
@@ -920,7 +921,7 @@ function SideBar({ bannersHeight, user }: SideBarProps) {
</ButtonOrLink>
</Tooltip>
))}
- <Credits />
+ {!IS_VISUAL_REGRESSION_TESTING && <Credits />}
</div>
</aside>
</div>
diff --git a/packages/types/window.d.ts b/packages/types/window.d.ts
new file mode 100644
index 00000000000..4818b3b6c89
--- /dev/null
+++ b/packages/types/window.d.ts
@@ -0,0 +1,5 @@
+interface Window {
+ Meticulous?: {
+ isRunningAsTest: boolean;
+ };
+}