Skip to content

refactor: Remove app store index#23449

Merged
keithwillcode merged 4 commits intomainfrom
remove-app-store-index
Aug 29, 2025
Merged

refactor: Remove app store index#23449
keithwillcode merged 4 commits intomainfrom
remove-app-store-index

Conversation

@joeauyeung
Copy link
Contributor

What does this PR do?

  • Fixes #XXXX (GitHub issue number)
  • Fixes CAL-XXXX (Linear issue number - should be visible at the bottom of the GitHub issue description)

Visual Demo (For contributors especially)

A visual demonstration is strongly recommended, for both the original and new change (video / image - any one).

Video Demo (if applicable):

  • Show screen recordings of the issue or feature.
  • Demonstrate how to reproduce the issue, the behavior before and after the change.

Image Demo (if applicable):

  • Add side-by-side screenshots of the original and updated change.
  • Highlight any significant change(s).

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Are there environment variables that should be set?
  • What are the minimal test data to have?
  • What is expected (happy path) to have (input and output)?
  • Any other important info that could help to test that PR

Checklist

  • I haven't read the contributing guide
  • My code doesn't follow the style guidelines of this project
  • I haven't commented my code, particularly in hard-to-understand areas
  • I haven't checked if my changes generate no new warnings

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Aug 29, 2025

Walkthrough

This change removes the app-store registry and its default export by deleting packages/app-store/index.ts, and eliminates the global test mock at tests/libs/mocks/app-store.ts. Tests are updated to stop using appStoreMock. In bookingScenario test utilities, video integrations now use a registry-based approach (mockVideoAdapterRegistry with VideoApiAdapterMap). CRM integrations are mocked directly via vi.doMock for the @calcom/app-store/crm.apps.generated module, supplying a MockCrmService and wiring CrmServiceMap (including metadataLookupKey) to the mock implementation.

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch remove-app-store-index

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@github-actions
Copy link
Contributor

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Remove app store index". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Aug 29, 2025
@joeauyeung joeauyeung changed the title Remove app store index refactor: Remove app store index Aug 29, 2025
@vercel
Copy link

vercel bot commented Aug 29, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

2 Skipped Deployments
Project Deployment Preview Comments Updated (UTC)
cal Ignored Ignored Aug 29, 2025 6:20pm
cal-eu Ignored Ignored Aug 29, 2025 6:20pm

@github-actions
Copy link
Contributor

github-actions bot commented Aug 29, 2025

E2E results are ready!


// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
appStoreMock.default[appStoreLookupKey as keyof typeof appStoreMock.default].mockImplementation(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The video adapter is mocked directly from the video adapter registry


// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore
appStoreMock.default[appStoreLookupKey].mockImplementation(() => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The video adapter is mocked directly from the video adapter registry

ownerEmail: string;
}[] = [];
const eventsCreated: boolean[] = [];
const app = appStoreMetadata[metadataLookupKey as keyof typeof appStoreMetadata];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Instead of mocking the whole CRM app we just mock the CrmService

@joeauyeung joeauyeung marked this pull request as ready for review August 29, 2025 17:05
@graphite-app graphite-app bot requested a review from a team August 29, 2025 17:05
@dosubot dosubot bot added app-store area: app store, apps, calendar integrations, google calendar, outlook, lark, apple calendar 💻 refactor labels Aug 29, 2025
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 1fd1202 and 4a9ab15.

📒 Files selected for processing (3)
  • apps/web/test/utils/bookingScenario/bookingScenario.ts (1 hunks)
  • packages/app-store/index.ts (0 hunks)
  • tests/libs/__mocks__/app-store.ts (0 hunks)
💤 Files with no reviewable changes (2)
  • packages/app-store/index.ts
  • tests/libs/mocks/app-store.ts
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • apps/web/test/utils/bookingScenario/bookingScenario.ts
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • apps/web/test/utils/bookingScenario/bookingScenario.ts
**/*.{ts,tsx,js,jsx}

⚙️ CodeRabbit configuration file

Flag default exports and encourage named exports. Named exports provide better tree-shaking, easier refactoring, and clearer imports. Exempt main components like pages, layouts, and components that serve as the primary export of a module.

Files:

  • apps/web/test/utils/bookingScenario/bookingScenario.ts
🧠 Learnings (1)
📚 Learning: 2025-08-27T13:32:46.887Z
Learnt from: supalarry
PR: calcom/cal.com#23364
File: apps/api/v2/src/ee/event-types/event-types_2024_06_14/transformers/internal-to-api/internal-to-api.spec.ts:295-296
Timestamp: 2025-08-27T13:32:46.887Z
Learning: In calcom/cal.com, when transforming booking fields from internal to API format, tests in organizations-event-types.e2e-spec.ts already expect name field label and placeholder to be empty strings ("") rather than undefined. PR changes that set these to explicit empty strings are typically fixing implementation to match existing test expectations rather than breaking changes.

Applied to files:

  • apps/web/test/utils/bookingScenario/bookingScenario.ts
🔇 Additional comments (1)
apps/web/test/utils/bookingScenario/bookingScenario.ts (1)

2171-2176: Mock ordering is correct – the vi.doMock("@calcom/app-store/crm.apps.generated", …) call precedes any import of that module in this file, so no cache reset or registry rewrite is needed.

Likely an incorrect or invalid review comment.

Comment on lines +2171 to +2211
vi.doMock("@calcom/app-store/crm.apps.generated", async (importOriginal) => {
const original = await importOriginal<typeof import("@calcom/app-store/crm.apps.generated")>();

getContacts(email: string) {
if (crmData?.getContacts) {
contactsQueried = crmData?.getContacts;
const contactsOfEmail = contactsQueried.filter((contact) => contact.email === email);
class MockCrmService {
constructor() {
log.debug("Create CrmService");
}

return Promise.resolve(contactsOfEmail);
}
}
createContact() {
if (crmData?.createContacts) {
contactsCreated = crmData.createContacts;
return Promise.resolve(crmData?.createContacts);
}
return Promise.resolve([]);
}

createEvent() {
eventsCreated.push(true);
return Promise.resolve({});
}
},
getContacts(email: string) {
if (crmData?.getContacts) {
contactsQueried = crmData?.getContacts;
const contactsOfEmail = contactsQueried.filter((contact) => contact.email === email);
return Promise.resolve(contactsOfEmail);
}
return Promise.resolve([]);
}

createEvent() {
eventsCreated.push(true);
return Promise.resolve({});
}
}

return {
...original,
CrmServiceMap: {
...original.CrmServiceMap,
[metadataLookupKey]: Promise.resolve({
default: MockCrmService,
}),
},
});
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Avoid vi.doMock timing pitfalls; switch to a registry-based mock (mirrors video adapters)

vi.doMock must run before the first import; repeated calls override the whole module and drop earlier overrides. Use a shared registry + top-level vi.mock, then register per-key services here.

-  // Mock the CrmServiceMap directly instead of using the old app-store index approach
-  vi.doMock("@calcom/app-store/crm.apps.generated", async (importOriginal) => {
-    const original = await importOriginal<typeof import("@calcom/app-store/crm.apps.generated")>();
-
-    class MockCrmService {
-      constructor() {
-        log.debug("Create CrmService");
-      }
-      ...
-    }
-
-    return {
-      ...original,
-      CrmServiceMap: {
-        ...original.CrmServiceMap,
-        [metadataLookupKey]: Promise.resolve({
-          default: MockCrmService,
-        }),
-      },
-    };
-  });
+  class MockCrmService {
+    constructor() {
+      log.debug("Create CrmService");
+    }
+    ...
+  }
+  // register into the shared registry (defined at module scope)
+  mockCrmServiceRegistry[metadataLookupKey] = Promise.resolve({ default: MockCrmService });

Add at module scope (near the video registry):

const mockCrmServiceRegistry: Record<string, any> = {};
vi.mock("@calcom/app-store/crm.apps.generated", () => ({
  CrmServiceMap: new Proxy(
    {},
    {
      get(_t, prop) {
        if (typeof prop === "string" && mockCrmServiceRegistry[prop]) {
          return mockCrmServiceRegistry[prop];
        }
        return Promise.resolve({ default: vi.fn() });
      },
    }
  ),
}));

Comment on lines +2180 to +2185
contactsCreated = crmData.createContacts;
return Promise.resolve(crmData?.createContacts);
}
return Promise.resolve([]);
}

Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix reassignment bug: returned arrays never update

contactsCreated and contactsQueried are reassigned, so the arrays returned from mockCrmApp() won’t reflect updates. Mutate in place to preserve references.

-      createContact() {
-        if (crmData?.createContacts) {
-          contactsCreated = crmData.createContacts;
-          return Promise.resolve(crmData?.createContacts);
-        }
-        return Promise.resolve([]);
-      }
+      async createContact() {
+        if (crmData?.createContacts) {
+          contactsCreated.length = 0;
+          contactsCreated.push(...crmData.createContacts);
+          return contactsCreated;
+        }
+        return [];
+      }

-      getContacts(email: string) {
-        if (crmData?.getContacts) {
-          contactsQueried = crmData?.getContacts;
-          const contactsOfEmail = contactsQueried.filter((contact) => contact.email === email);
-          return Promise.resolve(contactsOfEmail);
-        }
-        return Promise.resolve([]);
-      }
+      async getContacts(email: string) {
+        if (crmData?.getContacts) {
+          contactsQueried.length = 0;
+          contactsQueried.push(...crmData.getContacts);
+          const contactsOfEmail = contactsQueried.filter((contact) => contact.email === email);
+          return contactsOfEmail;
+        }
+        return [];
+      }

Also applies to: 2187-2194

🤖 Prompt for AI Agents
In apps/web/test/utils/bookingScenario/bookingScenario.ts around lines 2180-2185
and 2187-2194, the issue is that contactsCreated and contactsQueried are being
reassigned to new arrays so callers holding the original references won't see
subsequent updates; instead mutate the existing arrays in place and return the
original array reference (e.g., clear the target array and push new items or use
splice to replace contents) so that mockCrmApp() always returns the same array
object while its contents are updated; keep returning a resolved Promise of that
array reference.

@keithwillcode keithwillcode enabled auto-merge (squash) August 29, 2025 18:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app-store area: app store, apps, calendar integrations, google calendar, outlook, lark, apple calendar core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ready-for-e2e 💻 refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants