Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test for importing webapp externally #57

Closed
wants to merge 3 commits into from
Closed

Conversation

mickmister
Copy link
Contributor

@mickmister mickmister commented Nov 1, 2023

Summary

In order to share frontend code between calendar projects, we need to have a way to reference the source code of the shared package. This PR introduces a postinstall script that checks out the shared repo as an npm dependency, so that the common calendar logic can be imported by the gcal repo. By defining the postinstall script, we do the following whenever npm install is run:

  • Clone the mattermost-plugin-google-calendar (should be mattermost-plugin-google-shared) repo as an npm dependency
  • Install that project's npm dependencies

The index.tsx file on this bare-webapp branch does not define a Plugin object to provide to registerPlugin. It instead imports the one provided by the cloned module, and uses that to call registerPlugin. Note that the commit 157e796 being imported avoids calling registerPlugin in its index.tsx file

Ticket Link

"postinstall": "node postinstall.js"
},
"customModule": {
"name": "mattermost-plugin-google-calendar",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We would actually have this be something like mattermost-plugin-calendar-shared

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also the name customModule is arbitrary

useEffect(() => {
setup();
}, []);
import Plugin from 'mattermost-plugin-google-calendar/webapp/src/index.tsx';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Import the Plugin class from the external repo, rather than defining our own

@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7de5e03) 11.22% compared to head (14e7924) 11.22%.

Additional details and impacted files
@@           Coverage Diff           @@
##           master      #57   +/-   ##
=======================================
  Coverage   11.22%   11.22%           
=======================================
  Files          16       16           
  Lines         606      606           
=======================================
  Hits           68       68           
  Misses        536      536           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mickmister mickmister closed this May 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants