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>2023-03-08 18:08:00 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-03-08 18:08:00 +0300
commit684838d4bea13af1dac9c2f32b99985bf0f9f8e2 (patch)
tree611fcc177ba5a4fe702668c25aa68119675dbd8e /spec/frontend
parent012f9a4b9ec4a78d9593d882b38f95e376c2cfe2 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/frontend')
-rw-r--r--spec/frontend/saved_replies/components/__snapshots__/list_item_spec.js.snap17
-rw-r--r--spec/frontend/saved_replies/components/form_spec.js36
2 files changed, 48 insertions, 5 deletions
diff --git a/spec/frontend/saved_replies/components/__snapshots__/list_item_spec.js.snap b/spec/frontend/saved_replies/components/__snapshots__/list_item_spec.js.snap
index 154ce2bd089..204afc744e7 100644
--- a/spec/frontend/saved_replies/components/__snapshots__/list_item_spec.js.snap
+++ b/spec/frontend/saved_replies/components/__snapshots__/list_item_spec.js.snap
@@ -7,7 +7,9 @@ exports[`Saved replies list item component renders list item 1`] = `
<div
class="gl-display-flex gl-align-items-center"
>
- <strong>
+ <strong
+ data-testid="saved-reply-name"
+ >
test
</strong>
@@ -15,6 +17,19 @@ exports[`Saved replies list item component renders list item 1`] = `
class="gl-ml-auto"
>
<gl-button-stub
+ aria-label="Edit"
+ buttontextclasses=""
+ category="primary"
+ class="gl-mr-3"
+ data-testid="saved-reply-edit-btn"
+ icon="pencil"
+ size="medium"
+ title="Edit"
+ to="[object Object]"
+ variant="default"
+ />
+
+ <gl-button-stub
aria-label="Delete"
buttontextclasses=""
category="secondary"
diff --git a/spec/frontend/saved_replies/components/form_spec.js b/spec/frontend/saved_replies/components/form_spec.js
index 693703ca572..adeda498e6f 100644
--- a/spec/frontend/saved_replies/components/form_spec.js
+++ b/spec/frontend/saved_replies/components/form_spec.js
@@ -8,24 +8,33 @@ import createMockApollo from 'helpers/mock_apollo_helper';
import waitForPromises from 'helpers/wait_for_promises';
import Form from '~/saved_replies/components/form.vue';
import createSavedReplyMutation from '~/saved_replies/queries/create_saved_reply.mutation.graphql';
+import updateSavedReplyMutation from '~/saved_replies/queries/update_saved_reply.mutation.graphql';
let wrapper;
let createSavedReplyResponseSpy;
+let updateSavedReplyResponseSpy;
function createMockApolloProvider(response) {
Vue.use(VueApollo);
createSavedReplyResponseSpy = jest.fn().mockResolvedValue(response);
+ updateSavedReplyResponseSpy = jest.fn().mockResolvedValue(response);
- const requestHandlers = [[createSavedReplyMutation, createSavedReplyResponseSpy]];
+ const requestHandlers = [
+ [createSavedReplyMutation, createSavedReplyResponseSpy],
+ [updateSavedReplyMutation, updateSavedReplyResponseSpy],
+ ];
return createMockApollo(requestHandlers);
}
-function createComponent(response = createdSavedReplyResponse) {
+function createComponent(id = null, response = createdSavedReplyResponse) {
const mockApollo = createMockApolloProvider(response);
return mount(Form, {
+ propsData: {
+ id,
+ },
apolloProvider: mockApollo,
});
}
@@ -52,6 +61,7 @@ describe('Saved replies form component', () => {
await waitForPromises();
expect(createSavedReplyResponseSpy).toHaveBeenCalledWith({
+ id: null,
content: 'Test content',
name: 'Test',
});
@@ -72,7 +82,7 @@ describe('Saved replies form component', () => {
${findSavedReplyNameFormGroup} | ${findSavedReplyContentInput} | ${'name'}
${findSavedReplyContentFormGroup} | ${findSavedReplyNameInput} | ${'content'}
`('shows errors for empty $fieldName input', async ({ findFormGroup, findInput }) => {
- wrapper = createComponent(createdSavedReplyErrorResponse);
+ wrapper = createComponent(null, createdSavedReplyErrorResponse);
findInput().setValue('Test');
findSavedReplyFrom().trigger('submit');
@@ -83,7 +93,7 @@ describe('Saved replies form component', () => {
});
it('displays errors when mutation fails', async () => {
- wrapper = createComponent(createdSavedReplyErrorResponse);
+ wrapper = createComponent(null, createdSavedReplyErrorResponse);
findSavedReplyNameInput().setValue('Test');
findSavedReplyContentInput().setValue('Test content');
@@ -113,4 +123,22 @@ describe('Saved replies form component', () => {
expect(findSubmitBtn().props('loading')).toBe(false);
});
});
+
+ describe('updates saved reply', () => {
+ it('calls apollo mutation', async () => {
+ wrapper = createComponent('1');
+
+ findSavedReplyNameInput().setValue('Test');
+ findSavedReplyContentInput().setValue('Test content');
+ findSavedReplyFrom().trigger('submit');
+
+ await waitForPromises();
+
+ expect(updateSavedReplyResponseSpy).toHaveBeenCalledWith({
+ id: '1',
+ content: 'Test content',
+ name: 'Test',
+ });
+ });
+ });
});