diff --git a/README.md b/README.md index cab777f..36f541b 100644 --- a/README.md +++ b/README.md @@ -5,3 +5,4 @@ To find plugin outlets, run `enableDevTools()` in the javascript console. Demonstrates [Objects type for theme settings](https://meta.discourse.org/t/objects-type-for-theme-setting/305009) and how to use `api.renderInOutlet` to render a Ember (glimmer?) component anywhere you want. +See `TESTING.md` for instructions on running the Discourse-style system specs for this theme. diff --git a/TESTING.md b/TESTING.md new file mode 100644 index 0000000..9f8e5e5 --- /dev/null +++ b/TESTING.md @@ -0,0 +1,33 @@ +Testing (Discourse-style system specs) + +This theme provides RSpec/Capybara system specs that run inside the Discourse +test harness (recommended for end-to-end testing of themes and theme +components). We use the `discourse_theme` CLI to run the specs in a disposable +Docker container. + +Run all system specs for the theme: + +```bash +discourse_theme rspec spec/system +``` + +Run a single spec file: + +```bash +discourse_theme rspec spec/system/text_block_visibility_spec.rb +``` + +Run in headful mode (open Chrome so you can watch/debug): + +```bash +discourse_theme rspec spec/system --headful +``` + +Notes: +- If this repository is a theme *component* (not a full theme) the system spec + uses `upload_theme_component` to install the component into the test + instance. The spec files live under `spec/system` and use Fabricate helpers + from Discourse core to create users/groups for tests. +- Tests run in Docker by default; see the `discourse_theme` documentation for + advanced usage, local Discourse integration, and CI setup: + https://github.com/discourse/discourse_theme diff --git a/javascripts/discourse/api-initializers/custom-components.gjs b/javascripts/discourse/api-initializers/custom-components.gjs index cb3c906..0c2709d 100644 --- a/javascripts/discourse/api-initializers/custom-components.gjs +++ b/javascripts/discourse/api-initializers/custom-components.gjs @@ -1,7 +1,6 @@ -import { htmlSafe } from "@ember/template"; -import concatClass from "discourse/helpers/concat-class"; import { apiInitializer } from "discourse/lib/api"; import ButtonLink from "../components/button-link"; +import TextBlock from "../components/text-block"; export default apiInitializer((api) => { // loop through settings.buttons and render a button for each one @@ -15,11 +14,7 @@ export default apiInitializer((api) => { settings.custom_text_block.forEach((component) => { api.renderInOutlet( component.outlet, - + ); }); }); diff --git a/javascripts/discourse/components/button-link.gjs b/javascripts/discourse/components/button-link.gjs index 147f186..ae5f334 100644 --- a/javascripts/discourse/components/button-link.gjs +++ b/javascripts/discourse/components/button-link.gjs @@ -6,7 +6,7 @@ import concatClass from "discourse/helpers/concat-class"; export default class ButtonLink extends Component { @service currentUser; - get showButtonLink() { + get shouldRender() { let isGroupMember = !!this.currentUser && this.args.button.groups.some((group) => { @@ -27,7 +27,7 @@ export default class ButtonLink extends Component { }