mirror of
https://github.com/discourse/discourse.git
synced 2025-06-06 03:06:53 +08:00
DEV: [gjs-codemod] Convert automation/styleguide/other to gjs
Co-authored-by: Jarek Radosz <jarek@cvx.dev>
This commit is contained in:
@ -1,13 +1,15 @@
|
||||
import { click, render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { i18n } from "discourse-i18n";
|
||||
import PollButtonsDropdown from "discourse/plugins/poll/discourse/components/poll-buttons-dropdown";
|
||||
|
||||
module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("Renders a clickable dropdown menu with a close option", async function (assert) {
|
||||
const self = this;
|
||||
|
||||
this.siteSettings.data_explorer_enabled = true;
|
||||
this.siteSettings.poll_export_data_explorer_query_id = 18;
|
||||
this.currentUser.setProperties({ admin: true });
|
||||
@ -23,16 +25,20 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
dropDownClick: () => {},
|
||||
});
|
||||
|
||||
await render(hbs`<PollButtonsDropdown
|
||||
@closed={{this.closed}}
|
||||
@voters={{this.voters}}
|
||||
@isStaff={{this.isStaff}}
|
||||
@isMe={{this.isMe}}
|
||||
@topicArchived={{this.topicArchived}}
|
||||
@groupableUserFields={{this.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{this.isAutomaticallyClosed}}
|
||||
@dropDownClick={{this.dropDownClick}}
|
||||
/>`);
|
||||
await render(
|
||||
<template>
|
||||
<PollButtonsDropdown
|
||||
@closed={{self.closed}}
|
||||
@voters={{self.voters}}
|
||||
@isStaff={{self.isStaff}}
|
||||
@isMe={{self.isMe}}
|
||||
@topicArchived={{self.topicArchived}}
|
||||
@groupableUserFields={{self.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{self.isAutomaticallyClosed}}
|
||||
@dropDownClick={{self.dropDownClick}}
|
||||
/>
|
||||
</template>
|
||||
);
|
||||
|
||||
await click(".widget-dropdown-header");
|
||||
|
||||
@ -46,6 +52,8 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
});
|
||||
|
||||
test("Renders a show-tally button when poll is a bar chart", async function (assert) {
|
||||
const self = this;
|
||||
|
||||
this.setProperties({
|
||||
closed: false,
|
||||
voters: 2,
|
||||
@ -58,17 +66,21 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
availableDisplayMode: "showTally",
|
||||
});
|
||||
|
||||
await render(hbs`<PollButtonsDropdown
|
||||
@closed={{this.closed}}
|
||||
@voters={{this.voters}}
|
||||
@isStaff={{this.isStaff}}
|
||||
@isMe={{this.isMe}}
|
||||
@topicArchived={{this.topicArchived}}
|
||||
@groupableUserFields={{this.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{this.isAutomaticallyClosed}}
|
||||
@dropDownClick={{this.dropDownClick}}
|
||||
@availableDisplayMode={{this.availableDisplayMode}}
|
||||
/>`);
|
||||
await render(
|
||||
<template>
|
||||
<PollButtonsDropdown
|
||||
@closed={{self.closed}}
|
||||
@voters={{self.voters}}
|
||||
@isStaff={{self.isStaff}}
|
||||
@isMe={{self.isMe}}
|
||||
@topicArchived={{self.topicArchived}}
|
||||
@groupableUserFields={{self.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{self.isAutomaticallyClosed}}
|
||||
@dropDownClick={{self.dropDownClick}}
|
||||
@availableDisplayMode={{self.availableDisplayMode}}
|
||||
/>
|
||||
</template>
|
||||
);
|
||||
|
||||
await click(".widget-dropdown-header");
|
||||
|
||||
@ -82,6 +94,8 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
});
|
||||
|
||||
test("Renders a single button when there is only one authorised action", async function (assert) {
|
||||
const self = this;
|
||||
|
||||
this.setProperties({
|
||||
closed: false,
|
||||
voters: 2,
|
||||
@ -93,16 +107,20 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
dropDownClick: () => {},
|
||||
});
|
||||
|
||||
await render(hbs`<PollButtonsDropdown
|
||||
@closed={{this.closed}}
|
||||
@voters={{this.voters}}
|
||||
@isStaff={{this.isStaff}}
|
||||
@isMe={{this.isMe}}
|
||||
@topicArchived={{this.topicArchived}}
|
||||
@groupableUserFields={{this.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{this.isAutomaticallyClosed}}
|
||||
@dropDownClick={{this.dropDownClick}}
|
||||
/>`);
|
||||
await render(
|
||||
<template>
|
||||
<PollButtonsDropdown
|
||||
@closed={{self.closed}}
|
||||
@voters={{self.voters}}
|
||||
@isStaff={{self.isStaff}}
|
||||
@isMe={{self.isMe}}
|
||||
@topicArchived={{self.topicArchived}}
|
||||
@groupableUserFields={{self.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{self.isAutomaticallyClosed}}
|
||||
@dropDownClick={{self.dropDownClick}}
|
||||
/>
|
||||
</template>
|
||||
);
|
||||
|
||||
assert.dom(".widget-dropdown-header").doesNotExist();
|
||||
assert.dom("button.widget-button").exists({ count: 1 });
|
||||
@ -115,6 +133,8 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
});
|
||||
|
||||
test("Doesn't render a button when user has no authorised actions", async function (assert) {
|
||||
const self = this;
|
||||
|
||||
this.setProperties({
|
||||
closed: false,
|
||||
voters: 0,
|
||||
@ -126,16 +146,20 @@ module("Poll | Component | poll-buttons-dropdown", function (hooks) {
|
||||
dropDownClick: () => {},
|
||||
});
|
||||
|
||||
await render(hbs`<PollButtonsDropdown
|
||||
@closed={{this.closed}}
|
||||
@voters={{this.voters}}
|
||||
@isStaff={{this.isStaff}}
|
||||
@isMe={{this.isMe}}
|
||||
@topicArchived={{this.topicArchived}}
|
||||
@groupableUserFields={{this.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{this.isAutomaticallyClosed}}
|
||||
@dropDownClick={{this.dropDownClick}}
|
||||
/>`);
|
||||
await render(
|
||||
<template>
|
||||
<PollButtonsDropdown
|
||||
@closed={{self.closed}}
|
||||
@voters={{self.voters}}
|
||||
@isStaff={{self.isStaff}}
|
||||
@isMe={{self.isMe}}
|
||||
@topicArchived={{self.topicArchived}}
|
||||
@groupableUserFields={{self.groupableUserFields}}
|
||||
@isAutomaticallyClosed={{self.isAutomaticallyClosed}}
|
||||
@dropDownClick={{self.dropDownClick}}
|
||||
/>
|
||||
</template>
|
||||
);
|
||||
|
||||
assert.dom(".widget-dropdown-header").doesNotExist();
|
||||
assert.dom("button.widget-button").doesNotExist();
|
||||
|
Reference in New Issue
Block a user