Hello,
We are using Discourse version 3.5.0.
We have our own plugin in which we override various Discourse elements and add our own features.
In this plugin, we want to add the event creation icon to the composer’s toolbar. To do this, we need to import:
-
the model
DiscoursePostEventEventlocated atplugins/discourse-calendar/assets/javascripts/discourse/models/discourse-post-event-event.js -
the component
PostEventBuilderlocated atplugins/discourse-calendar/assets/javascripts/discourse/components/modal/post-event-builder.js
Furthermore, we have written integration tests for our features, which we have placed in our plugin under the /test directory.
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("TOTO", function (needs) {
test("coopaname integration - composer", async function (assert) {
await visit("/");
assert.equal(1, 1, "OK");
});
});
We are able to do what we want, but the tests fail regardless of the import method.
Import at the top of the file
When we import our model and component using the import method at the top of the file:
import DiscoursePostEventEvent from "discourse/plugins/discourse-calendar/discourse/models/discourse-post-event-event";
import PostEventBuilder from "discourse/plugins/discourse-calendar/discourse/components/modal/post-event-builder";
Everything works fine at runtime, but when we run our test, it is not executed.


Require at the top of the file
When we import our model and component using the require method at the top of the file:
const DiscoursePostEventEvent = require("discourse/plugins/discourse-calendar/discourse/models/discourse-post-event-event").default;
const PostEventBuilder = require("discourse/plugins/discourse-calendar/discourse/components/modal/post-event-builder").default;
Everything works fine at runtime, but when we run our test, it is not executed.


This produces the same result as with import.
Require in the body of the file
When we import our model and component using the require method in the body of the function:
import { withPluginApi } from "discourse/lib/plugin-api";
function initializeEventBuilder(api) {
const DiscoursePostEventEvent =
require("discourse/plugins/discourse-calendar/discourse/models/discourse-post-event-event").default;
const PostEventBuilder =
require("discourse/plugins/discourse-calendar/discourse/components/modal/post-event-builder").default;
// ... rest of the code
}
export default {
name: "add-custom-create-event-button",
initialize(container) {
withPluginApi(initializeEventBuilder);
},
};
Everything works fine at runtime, but when we run our test, it fails.

The model was not found.
In short, we would like to know how to correctly import models, components, etc. from other plugins so that we can run integration tests.
Thank you!