Skip to content

test: verify embed helpers#11318

Merged
kodiakhq[bot] merged 7 commits intocalcom:mainfrom
wesleymatosdev:test/verify-embed-helpers
Sep 14, 2023
Merged

test: verify embed helpers#11318
kodiakhq[bot] merged 7 commits intocalcom:mainfrom
wesleymatosdev:test/verify-embed-helpers

Conversation

@wesleymatosdev
Copy link
Copy Markdown
Contributor

@wesleymatosdev wesleymatosdev commented Sep 12, 2023

  • test: add test cases to window.getEmbedNamespace
  • test: add test cases when window.name doesn't have cal-embed=
  • test: add test case to getembedTheme returning the theme from embedStore
  • test: add test to getEmbedTheme returning the theme from query params

What does this PR do?

Adding tests to getEmbedTheme, getEmbedNamespace and isEmbed

Fixes #9086
/claim #9086

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • Chore (refactoring code, technical debt, workflow improvements)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How should this be tested?

It should be run via yarn e2e:embed. Probably the automated pipelines will run these new tests.
None of the tests added on this PR should break.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 12, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 14, 2023 7:05am

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 12, 2023

@ologbonowiwi is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions bot added automated-tests area: unit tests, e2e tests, playwright embed area: embed, widget, react embed High priority Created by Linear-GitHub Sync 💎 Bounty A bounty on Algora.io labels Sep 12, 2023
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 12, 2023

Thank you for following the naming conventions! 🙏

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Sep 12, 2023

📦 Next.js Bundle Analysis for @calcom/web

This analysis was generated by the Next.js Bundle Analysis action. 🤖

This PR introduced no changes to the JavaScript bundle! 🙌


import { test } from "@calcom/web/playwright/lib/fixtures";

import "../../src/types.d";
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now window.isEmbed type definition would be available.

@hariombalhara hariombalhara force-pushed the test/verify-embed-helpers branch from 6bf85b5 to f8b0b45 Compare September 14, 2023 05:35

test("should change to embed when window.name is changed to cal-embed=", async ({ page }) => {
await page.goto("http://localhost:3000/free/30min");
test.describe("isEmbed, getEmbedNamespace, getEmbedTheme testing", () => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Clubbed the tests under one describe.

page,
}) => {
const queryParamTheme = "dark";
await page.evaluate(() => {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can set window.name before going to the URL and then load the URL. It avoids an unnecessary page load saving time per test.

test("should change to embed when window.name is changed to cal-embed=", async ({ page }) => {
await page.goto("http://localhost:3000/free/30min");
test.describe("isEmbed, getEmbedNamespace, getEmbedTheme testing", () => {
test("when `window.name` is set to 'cal-embed=' and `theme` is supplied as a query param", async ({
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also clubbed the different test sections for isEmbed and getEmbedNamespace together so that we can test both on a single page visit. This is to again save time as we really want to not increase time taken by our E2E tests significantly

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved global type augmentation here so that they can be shared with others.

hariombalhara
hariombalhara previously approved these changes Sep 14, 2023
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @ologbonowiwi 🙏 LGTM!!

hariombalhara
hariombalhara previously approved these changes Sep 14, 2023
@kodiakhq kodiakhq bot merged commit dfde171 into calcom:main Sep 14, 2023
Copy link
Copy Markdown
Contributor

@shivamklr shivamklr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested, lgtm.

ashwintelmore pushed a commit to ashwintelmore/cal.com that referenced this pull request Sep 19, 2023
* test: add test cases to `window.getEmbedNamespace`

* test: add test cases when window.name doesn't have cal-embed=

* test: add test case to `getembedTheme` returning the theme from embedStore

* test: add test to `getEmbedTheme` returning the theme from query params

* Small refactor to reduce the time taken by tests and fix missing typings for embed functions on window

* Fix weird test failure

* Fix type import error caught by api.test.test

---------

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
aar2dee2 pushed a commit to rkreddy99/cal.com that referenced this pull request Sep 27, 2023
* test: add test cases to `window.getEmbedNamespace`

* test: add test cases when window.name doesn't have cal-embed=

* test: add test case to `getembedTheme` returning the theme from embedStore

* test: add test to `getEmbedTheme` returning the theme from query params

* Small refactor to reduce the time taken by tests and fix missing typings for embed functions on window

* Fix weird test failure

* Fix type import error caught by api.test.test

---------

Co-authored-by: Hariom Balhara <hariombalhara@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automated-tests area: unit tests, e2e tests, playwright automerge 🙋 Bounty claim 💎 Bounty A bounty on Algora.io embed area: embed, widget, react embed High priority Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[CAL-1753] Embed: Update e2e tests to verify that methods like getEmbedNamespace, getEmbedTheme, isEmbed work correctly.

4 participants