Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 15:08:41 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-07-18 15:08:41 +0300
commit5c5d24f032b67d98452f391192386e330a0f880c (patch)
tree9e58d94388f63cb825e426fea2c4929740604768 /spec/frontend/notes
parent5ccb67600c63549774a28811d177dd673e6dd4d0 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend/notes')
-rw-r--r--spec/frontend/notes/components/comment_form_spec.js122
1 files changed, 49 insertions, 73 deletions
diff --git a/spec/frontend/notes/components/comment_form_spec.js b/spec/frontend/notes/components/comment_form_spec.js
index 116016ecae2..463787c148b 100644
--- a/spec/frontend/notes/components/comment_form_spec.js
+++ b/spec/frontend/notes/components/comment_form_spec.js
@@ -550,98 +550,74 @@ describe('issue_comment_form component', () => {
});
describe('confidential notes checkbox', () => {
- describe('when confidentialNotes feature flag is `false`', () => {
- const features = { confidentialNotes: false };
+ it('should render checkbox as unchecked by default', () => {
+ mountComponent({
+ mountFunction: mount,
+ initialData: { note: 'confidential note' },
+ noteableData: { ...notableDataMockCanUpdateIssuable },
+ });
- it('should not render checkbox', () => {
+ const checkbox = findConfidentialNoteCheckbox();
+ expect(checkbox.exists()).toBe(true);
+ expect(checkbox.element.checked).toBe(false);
+ });
+
+ it.each`
+ noteableType | rendered | message
+ ${'Issue'} | ${true} | ${'render'}
+ ${'Epic'} | ${true} | ${'render'}
+ ${'MergeRequest'} | ${false} | ${'not render'}
+ `(
+ 'should $message checkbox when noteableType is $noteableType',
+ ({ noteableType, rendered }) => {
mountComponent({
mountFunction: mount,
- initialData: { note: 'confidential note' },
- noteableData: { ...notableDataMockCanUpdateIssuable },
- features,
+ noteableType,
+ initialData: { note: 'internal note' },
+ noteableData: { ...notableDataMockCanUpdateIssuable, noteableType },
});
- const checkbox = findConfidentialNoteCheckbox();
- expect(checkbox.exists()).toBe(false);
- });
- });
-
- describe('when confidentialNotes feature flag is `true`', () => {
- const features = { confidentialNotes: true };
+ expect(findConfidentialNoteCheckbox().exists()).toBe(rendered);
+ },
+ );
- it('should render checkbox as unchecked by default', () => {
+ describe.each`
+ shouldCheckboxBeChecked
+ ${true}
+ ${false}
+ `('when checkbox value is `$shouldCheckboxBeChecked`', ({ shouldCheckboxBeChecked }) => {
+ it(`sets \`confidential\` to \`${shouldCheckboxBeChecked}\``, async () => {
mountComponent({
mountFunction: mount,
initialData: { note: 'confidential note' },
noteableData: { ...notableDataMockCanUpdateIssuable },
- features,
});
- const checkbox = findConfidentialNoteCheckbox();
- expect(checkbox.exists()).toBe(true);
- expect(checkbox.element.checked).toBe(false);
- });
+ jest.spyOn(wrapper.vm, 'saveNote').mockResolvedValue({});
- it.each`
- noteableType | rendered | message
- ${'Issue'} | ${true} | ${'render'}
- ${'Epic'} | ${true} | ${'render'}
- ${'MergeRequest'} | ${false} | ${'not render'}
- `(
- 'should $message checkbox when noteableType is $noteableType',
- ({ noteableType, rendered }) => {
- mountComponent({
- mountFunction: mount,
- noteableType,
- initialData: { note: 'internal note' },
- noteableData: { ...notableDataMockCanUpdateIssuable, noteableType },
- features,
- });
-
- expect(findConfidentialNoteCheckbox().exists()).toBe(rendered);
- },
- );
-
- describe.each`
- shouldCheckboxBeChecked
- ${true}
- ${false}
- `('when checkbox value is `$shouldCheckboxBeChecked`', ({ shouldCheckboxBeChecked }) => {
- it(`sets \`confidential\` to \`${shouldCheckboxBeChecked}\``, async () => {
- mountComponent({
- mountFunction: mount,
- initialData: { note: 'confidential note' },
- noteableData: { ...notableDataMockCanUpdateIssuable },
- features,
- });
-
- jest.spyOn(wrapper.vm, 'saveNote').mockResolvedValue({});
-
- const checkbox = findConfidentialNoteCheckbox();
+ const checkbox = findConfidentialNoteCheckbox();
- // check checkbox
- checkbox.element.checked = shouldCheckboxBeChecked;
- checkbox.trigger('change');
- await nextTick();
+ // check checkbox
+ checkbox.element.checked = shouldCheckboxBeChecked;
+ checkbox.trigger('change');
+ await nextTick();
- // submit comment
- findCommentButton().trigger('click');
+ // submit comment
+ findCommentButton().trigger('click');
- const [providedData] = wrapper.vm.saveNote.mock.calls[0];
- expect(providedData.data.note.confidential).toBe(shouldCheckboxBeChecked);
- });
+ const [providedData] = wrapper.vm.saveNote.mock.calls[0];
+ expect(providedData.data.note.confidential).toBe(shouldCheckboxBeChecked);
});
+ });
- describe('when user cannot update issuable', () => {
- it('should not render checkbox', () => {
- mountComponent({
- mountFunction: mount,
- noteableData: { ...notableDataMockCannotUpdateIssuable },
- features,
- });
-
- expect(findConfidentialNoteCheckbox().exists()).toBe(false);
+ describe('when user cannot update issuable', () => {
+ it('should not render checkbox', () => {
+ mountComponent({
+ mountFunction: mount,
+ noteableData: { ...notableDataMockCannotUpdateIssuable },
});
+
+ expect(findConfidentialNoteCheckbox().exists()).toBe(false);
});
});
});