mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 12:42:16 +08:00
Removed @cached and changed tests
This commit is contained in:
parent
3dc23b6c42
commit
8a40eef21b
|
@ -64,6 +64,10 @@ export default class SidebarSection extends Component {
|
|||
}
|
||||
},
|
||||
{
|
||||
collapseSection: (sectionName) =>
|
||||
this.sidebarState.collapseSection(sectionName),
|
||||
expandSection: (sectionName) =>
|
||||
this.sidebarState.expandSection(sectionName),
|
||||
sectionName: this.args.sectionName,
|
||||
collapsable: this.args.collapsable,
|
||||
isCollapsed: this.isCollapsed,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { cached, tracked } from "@glimmer/tracking";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { registerDestructor } from "@ember/destroyable";
|
||||
import Service, { service } from "@ember/service";
|
||||
import { TrackedSet } from "@ember-compat/tracked-built-ins";
|
||||
|
@ -53,7 +53,6 @@ export default class SidebarState extends Service {
|
|||
this.restorePreviousState();
|
||||
}
|
||||
|
||||
@cached
|
||||
get currentPanel() {
|
||||
return this.panels.find((panel) => panel.key === this.currentPanelKey);
|
||||
}
|
||||
|
|
|
@ -1040,22 +1040,66 @@ acceptance("Sidebar - Transformers", function (needs) {
|
|||
navigation_menu: "sidebar",
|
||||
});
|
||||
|
||||
test("sidebar-section-set-expanded-state transformer", async function (assert) {
|
||||
const transformed = [];
|
||||
test("sidebar-section-set-expanded-state transformer - collapse all sections", async function (assert) {
|
||||
let shouldCollapse = true;
|
||||
|
||||
withPluginApi("1.34.0", (api) => {
|
||||
withPluginApi("1.35.0", (api) => {
|
||||
api.registerBehaviorTransformer(
|
||||
"sidebar-section-set-expanded-state",
|
||||
({ context, next }) => {
|
||||
transformed.push(context.sectionName);
|
||||
next();
|
||||
({ context }) => {
|
||||
if (shouldCollapse) {
|
||||
context.collapseSection(context.sectionName);
|
||||
} else {
|
||||
context.expandSection(context.sectionName);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await visit("/");
|
||||
|
||||
assert.ok(transformed.length > 0, "sections were transformed");
|
||||
// the tests target .sidebar-section-header-collapsable because sections without a header are not collapsable
|
||||
assert
|
||||
.dom(
|
||||
".sidebar-section.sidebar-section--collapsed .sidebar-section-header-collapsable"
|
||||
)
|
||||
.exists();
|
||||
assert
|
||||
.dom(
|
||||
".sidebar-section.sidebar-section--expanded .sidebar-section-header-collapsable"
|
||||
)
|
||||
.doesNotExist();
|
||||
});
|
||||
|
||||
test("sidebar-section-set-expanded-state transformer - expand all sections", async function (assert) {
|
||||
const shouldCollapse = false;
|
||||
|
||||
withPluginApi("1.35.0", (api) => {
|
||||
api.registerBehaviorTransformer(
|
||||
"sidebar-section-set-expanded-state",
|
||||
({ context }) => {
|
||||
if (shouldCollapse) {
|
||||
context.collapseSection(context.sectionName);
|
||||
} else {
|
||||
context.expandSection(context.sectionName);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
await visit("/");
|
||||
|
||||
// the tests target .sidebar-section-header-collapsable because sections without a header are not collapsable
|
||||
assert
|
||||
.dom(
|
||||
".sidebar-section.sidebar-section--collapsed .sidebar-section-header-collapsable"
|
||||
)
|
||||
.doesNotExist();
|
||||
assert
|
||||
.dom(
|
||||
".sidebar-section.sidebar-section--expanded .sidebar-section-header-collapsable"
|
||||
)
|
||||
.exists();
|
||||
});
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user