mirror of
https://github.com/wassname/talk.git
synced 2026-08-06 13:41:02 +08:00
[CORL-116] Configure sitewide commenting (#2193)
* feat: configure sitewide commenting * fix: repaired snapshots * fix: updated snapshots * test: update snapshots
This commit is contained in:
@@ -107,6 +107,107 @@ exports[`renders configure general 1`] = `
|
||||
className="HorizontalGutter-root HorizontalGutter-double"
|
||||
data-testid="configure-generalContainer"
|
||||
>
|
||||
<fieldset
|
||||
className="HorizontalGutter-root HorizontalGutter-oneAndAHalf"
|
||||
>
|
||||
<legend
|
||||
className="Typography-root Typography-heading1 Typography-colorTextPrimary Header-root"
|
||||
>
|
||||
Sitewide Commenting
|
||||
</legend>
|
||||
<p
|
||||
className="Typography-root Typography-detail Typography-colorTextPrimary"
|
||||
>
|
||||
Open or close comment streams for new comments sitewide. When new comments
|
||||
are turned off sitewide, new comments cannot be submitted, but existing
|
||||
comments can continue to receive “Respect” reactions, be reported, and be
|
||||
shared.
|
||||
</p>
|
||||
<fieldset
|
||||
className="HorizontalGutter-root FormField-root HorizontalGutter-half"
|
||||
>
|
||||
<legend
|
||||
className="Typography-root Typography-inputLabel Typography-colorTextPrimary InputLabel-root"
|
||||
>
|
||||
Enable New Comments Sitewide
|
||||
</legend>
|
||||
<div>
|
||||
<div
|
||||
className="Flex-root RadioButton-root Flex-flex Flex-alignCenter"
|
||||
>
|
||||
<input
|
||||
checked={true}
|
||||
className="RadioButton-input"
|
||||
disabled={false}
|
||||
id="disableCommenting.enabled-true"
|
||||
name="disableCommenting.enabled"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
onFocus={[Function]}
|
||||
type="radio"
|
||||
value={false}
|
||||
/>
|
||||
<label
|
||||
className="RadioButton-label"
|
||||
htmlFor="disableCommenting.enabled-true"
|
||||
>
|
||||
<span>
|
||||
On - Comment streams opened for new comments
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
className="Flex-root RadioButton-root Flex-flex Flex-alignCenter"
|
||||
>
|
||||
<input
|
||||
checked={false}
|
||||
className="RadioButton-input"
|
||||
disabled={false}
|
||||
id="disableCommenting.enabled-false"
|
||||
name="disableCommenting.enabled"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
onFocus={[Function]}
|
||||
type="radio"
|
||||
value={true}
|
||||
/>
|
||||
<label
|
||||
className="RadioButton-label"
|
||||
htmlFor="disableCommenting.enabled-false"
|
||||
>
|
||||
<span>
|
||||
Off - Comment streams closed for new comments
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</fieldset>
|
||||
<div
|
||||
className="HorizontalGutter-root FormField-root HorizontalGutter-half"
|
||||
>
|
||||
<label
|
||||
className="Typography-root Typography-inputLabel Typography-colorTextPrimary InputLabel-root"
|
||||
htmlFor="configure-general-sitewideCommenting-message"
|
||||
>
|
||||
Sitewide Closed Comments Message
|
||||
</label>
|
||||
<p
|
||||
className="Typography-root Typography-detail Typography-colorTextSecondary"
|
||||
>
|
||||
Write a message that will be displayed when comment streams are closed sitewide
|
||||
</p>
|
||||
</div>
|
||||
<div
|
||||
className="MarkdownEditor-wrapper"
|
||||
>
|
||||
<textarea
|
||||
id="configure-general-sitewideCommenting-message"
|
||||
name="disableCommenting.message"
|
||||
onChange={[Function]}
|
||||
value=""
|
||||
/>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset
|
||||
className="FieldSet-root HorizontalGutter-root HorizontalGutter-oneAndAHalf"
|
||||
>
|
||||
@@ -143,7 +244,9 @@ exports[`renders configure general 1`] = `
|
||||
className="RadioButton-label"
|
||||
htmlFor="communityGuidelines.enabled-true"
|
||||
>
|
||||
On
|
||||
<span>
|
||||
On
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
@@ -153,7 +256,7 @@ exports[`renders configure general 1`] = `
|
||||
checked={true}
|
||||
className="RadioButton-input"
|
||||
disabled={false}
|
||||
id="communityGuidelines.enabled-fase"
|
||||
id="communityGuidelines.enabled-false"
|
||||
name="communityGuidelines.enabled"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
@@ -163,9 +266,11 @@ exports[`renders configure general 1`] = `
|
||||
/>
|
||||
<label
|
||||
className="RadioButton-label"
|
||||
htmlFor="communityGuidelines.enabled-fase"
|
||||
htmlFor="communityGuidelines.enabled-false"
|
||||
>
|
||||
Off
|
||||
<span>
|
||||
Off
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -248,7 +353,9 @@ Markdown can be found
|
||||
className="RadioButton-label"
|
||||
htmlFor="charCount.enabled-true"
|
||||
>
|
||||
On
|
||||
<span>
|
||||
On
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
@@ -258,7 +365,7 @@ Markdown can be found
|
||||
checked={true}
|
||||
className="RadioButton-input"
|
||||
disabled={false}
|
||||
id="charCount.enabled-fase"
|
||||
id="charCount.enabled-false"
|
||||
name="charCount.enabled"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
@@ -268,9 +375,11 @@ Markdown can be found
|
||||
/>
|
||||
<label
|
||||
className="RadioButton-label"
|
||||
htmlFor="charCount.enabled-fase"
|
||||
htmlFor="charCount.enabled-false"
|
||||
>
|
||||
Off
|
||||
<span>
|
||||
Off
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -471,7 +580,9 @@ moderation panel.
|
||||
className="RadioButton-label"
|
||||
htmlFor="autoCloseStream-true"
|
||||
>
|
||||
On
|
||||
<span>
|
||||
On
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
@@ -481,7 +592,7 @@ moderation panel.
|
||||
checked={true}
|
||||
className="RadioButton-input"
|
||||
disabled={false}
|
||||
id="autoCloseStream-fase"
|
||||
id="autoCloseStream-false"
|
||||
name="autoCloseStream"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
@@ -491,9 +602,11 @@ moderation panel.
|
||||
/>
|
||||
<label
|
||||
className="RadioButton-label"
|
||||
htmlFor="autoCloseStream-fase"
|
||||
htmlFor="autoCloseStream-false"
|
||||
>
|
||||
Off
|
||||
<span>
|
||||
Off
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -158,7 +158,9 @@ the
|
||||
className="RadioButton-label"
|
||||
htmlFor="integrations.perspective.enabled-true"
|
||||
>
|
||||
On
|
||||
<span>
|
||||
On
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
@@ -168,7 +170,7 @@ the
|
||||
checked={true}
|
||||
className="RadioButton-input"
|
||||
disabled={false}
|
||||
id="integrations.perspective.enabled-fase"
|
||||
id="integrations.perspective.enabled-false"
|
||||
name="integrations.perspective.enabled"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
@@ -178,9 +180,11 @@ the
|
||||
/>
|
||||
<label
|
||||
className="RadioButton-label"
|
||||
htmlFor="integrations.perspective.enabled-fase"
|
||||
htmlFor="integrations.perspective.enabled-false"
|
||||
>
|
||||
Off
|
||||
<span>
|
||||
Off
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
@@ -424,7 +428,9 @@ the comment will be published.
|
||||
className="RadioButton-label"
|
||||
htmlFor="integrations.akismet.enabled-true"
|
||||
>
|
||||
On
|
||||
<span>
|
||||
On
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
<div
|
||||
@@ -434,7 +440,7 @@ the comment will be published.
|
||||
checked={true}
|
||||
className="RadioButton-input"
|
||||
disabled={false}
|
||||
id="integrations.akismet.enabled-fase"
|
||||
id="integrations.akismet.enabled-false"
|
||||
name="integrations.akismet.enabled"
|
||||
onBlur={[Function]}
|
||||
onChange={[Function]}
|
||||
@@ -444,9 +450,11 @@ the comment will be published.
|
||||
/>
|
||||
<label
|
||||
className="RadioButton-label"
|
||||
htmlFor="integrations.akismet.enabled-fase"
|
||||
htmlFor="integrations.akismet.enabled-false"
|
||||
>
|
||||
Off
|
||||
<span>
|
||||
Off
|
||||
</span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -68,6 +68,67 @@ it("renders configure general", async () => {
|
||||
expect(within(configureContainer).toJSON()).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("change site wide commenting", async () => {
|
||||
let settingsRecord = cloneDeep(settings);
|
||||
const updateSettingsStub = createSinonStub(s =>
|
||||
s.onFirstCall().callsFake((_: any, data: any) => {
|
||||
expect(data.input.settings.disableCommenting).toEqual({
|
||||
enabled: true,
|
||||
message: "Closing message",
|
||||
});
|
||||
settingsRecord = merge(settingsRecord, data.input.settings);
|
||||
return {
|
||||
settings: settingsRecord,
|
||||
clientMutationId: data.input.clientMutationId,
|
||||
};
|
||||
})
|
||||
);
|
||||
const {
|
||||
configureContainer,
|
||||
generalContainer,
|
||||
saveChangesButton,
|
||||
} = await createTestRenderer({
|
||||
Mutation: {
|
||||
updateSettings: updateSettingsStub,
|
||||
},
|
||||
});
|
||||
|
||||
const sitewideCommentingContainer = within(generalContainer).getAllByText(
|
||||
"Sitewide Commenting",
|
||||
{ selector: "fieldset" }
|
||||
)[0];
|
||||
|
||||
const offField = within(sitewideCommentingContainer).getByLabelText(
|
||||
"Off - Comment streams closed for new comments"
|
||||
);
|
||||
const contentField = within(sitewideCommentingContainer).getByLabelText(
|
||||
"Sitewide Closed Comments Message"
|
||||
);
|
||||
|
||||
// Let's enable it.
|
||||
offField.props.onChange(offField.props.value.toString());
|
||||
|
||||
// Let's change the content.
|
||||
contentField.props.onChange("Closing message");
|
||||
|
||||
// Send form
|
||||
within(configureContainer)
|
||||
.getByType("form")
|
||||
.props.onSubmit();
|
||||
|
||||
// Submit button and text field should be disabled.
|
||||
expect(saveChangesButton.props.disabled).toBe(true);
|
||||
expect(offField.props.disabled).toBe(true);
|
||||
|
||||
// Wait for submission to be finished
|
||||
await wait(() => {
|
||||
expect(offField.props.disabled).toBe(false);
|
||||
});
|
||||
|
||||
// Should have successfully sent with server.
|
||||
expect(updateSettingsStub.called).toBe(true);
|
||||
});
|
||||
|
||||
it("change community guidlines", async () => {
|
||||
let settingsRecord = cloneDeep(settings);
|
||||
const updateSettingsStub = createSinonStub(s =>
|
||||
|
||||
@@ -11,6 +11,9 @@ export const settings = {
|
||||
max: 1000,
|
||||
min: 3,
|
||||
},
|
||||
disableCommenting: {
|
||||
enabled: false,
|
||||
},
|
||||
closedTimeout: 604800,
|
||||
autoCloseStream: false,
|
||||
closedMessage: null,
|
||||
|
||||
Reference in New Issue
Block a user