-
Notifications
You must be signed in to change notification settings - Fork 8.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Don't AutoScroll to embed when multiple-duration event's booking…
… page is embedded (#16411) * Fix and add test and eslint rule * Fix eslint errors --------- Co-authored-by: Peer Richelsen <[email protected]>
- Loading branch information
1 parent
38fa0fa
commit d836497
Showing
17 changed files
with
129 additions
and
21 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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,29 +6,23 @@ import { | |
assertNoRequestIsBlocked, | ||
bookFirstEvent, | ||
deleteAllBookingsByEmail, | ||
getEmbedIframe, | ||
ensureEmbedIframe, | ||
} from "../lib/testUtils"; | ||
|
||
test.describe("Inline Iframe", () => { | ||
test("Inline Iframe - Configured with Dark Theme. Do booking and verify that COEP/CORP headers are correctly set", async ({ | ||
test("Configured with Dark Theme. Do booking and verify that COEP/CORP headers are correctly set", async ({ | ||
page, | ||
embeds: { addEmbedListeners, getActionFiredDetails }, | ||
embeds, | ||
}) => { | ||
await deleteAllBookingsByEmail("[email protected]"); | ||
await addEmbedListeners(""); | ||
await page.goto("/?only=ns:default"); | ||
await embeds.gotoPlayground({ calNamespace: "", url: "/?only=ns:default" }); | ||
const calNamespace = ""; | ||
const embedIframe = await getEmbedIframe({ calNamespace, page, pathname: "/pro" }); | ||
expect(embedIframe).toBeEmbedCalLink(calNamespace, getActionFiredDetails, { | ||
pathname: "/pro", | ||
const embedIframe = await ensureEmbedIframe({ calNamespace, page, pathname: "/pro" }); | ||
expect(embedIframe).toBeEmbedCalLink(calNamespace, embeds.getActionFiredDetails, { | ||
searchParams: { | ||
theme: "dark", | ||
}, | ||
}); | ||
// expect(await page.screenshot()).toMatchSnapshot("event-types-list.png"); | ||
if (!embedIframe) { | ||
throw new Error("Embed iframe not found"); | ||
} | ||
|
||
assertNoRequestIsBlocked(page); | ||
|
||
|
@@ -57,6 +51,17 @@ test.describe("Inline Iframe", () => { | |
}); | ||
}); | ||
|
||
test("Ensure iframe doesn't hijack scroll in embed mode", async ({ page, embeds, users }) => { | ||
const user = await users.create(); | ||
const calNamespace = "autoScrollTest"; | ||
await embeds.gotoPlayground({ calNamespace, url: `?only=ns:autoScrollTest` }); | ||
const calLink = `${user.username}/multiple-duration`; | ||
await page.goto(`/?only=ns:autoScrollTest&cal-link=${calLink}`); | ||
const embedIframe = await ensureEmbedIframe({ calNamespace, page, pathname: `/${calLink}` }); | ||
const finalScrollPosition = await page.evaluate(() => window.scrollY); | ||
expect(finalScrollPosition).toBe(0); | ||
}); | ||
|
||
todo( | ||
"Ensure that on all pages - [user], [user]/[type], team/[slug], team/[slug]/book, UI styling works if these pages are directly linked in embed" | ||
); | ||
|
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
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
42 changes: 42 additions & 0 deletions
42
packages/eslint-plugin/src/rules/no-scroll-into-view-embed.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,42 @@ | ||
import type { TSESTree } from "@typescript-eslint/utils"; | ||
import { ESLintUtils } from "@typescript-eslint/utils"; | ||
|
||
const createRule = ESLintUtils.RuleCreator((name) => `https://developer.cal.com/eslint/rule/${name}`); | ||
|
||
export default createRule({ | ||
name: "no-scroll-into-view-embed", | ||
meta: { | ||
docs: { | ||
description: "Disallow usage of scrollIntoView in embed mode", | ||
recommended: "error", | ||
}, | ||
messages: { | ||
noScrollIntoViewForEmbed: | ||
"Make sure to call scrollIntoView conditionally if it is called without user action. Use useIsEmbed() to detect if embed mode and then don't call it for embed case.", | ||
}, | ||
type: "problem", | ||
schema: [], | ||
}, | ||
defaultOptions: [], | ||
create(context) { | ||
return { | ||
CallExpression(node: TSESTree.CallExpression) { | ||
const { callee } = node; | ||
|
||
if (callee.type === "MemberExpression") { | ||
if (callee.property.type === "Identifier" && callee.property.name === "scrollIntoView") { | ||
context.report({ | ||
node, | ||
messageId: "noScrollIntoViewForEmbed", | ||
}); | ||
} | ||
} else if (callee.type === "Identifier" && callee.name === "scrollIntoView") { | ||
context.report({ | ||
node, | ||
messageId: "noScrollIntoViewForEmbed", | ||
}); | ||
} | ||
}, | ||
}; | ||
}, | ||
}); |
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
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
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
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