Commit 03510314 authored by Justin Ho's avatar Justin Ho

Add frontend and backend specs

- Cover most backend and frontend changes
- Minor refactors / fixes from writing specs
parent c54d7b6b
...@@ -89,7 +89,7 @@ export default { ...@@ -89,7 +89,7 @@ export default {
this.isUpdatingLabels = true; this.isUpdatingLabels = true;
updateIssue(this.issue, { labels }) updateIssue(this.issue, { labels })
.then((response) => { .then((response) => {
this.issue = response; this.issue.labels = response.labels;
}) })
.catch(() => { .catch(() => {
createFlash({ createFlash({
...@@ -123,7 +123,7 @@ export default { ...@@ -123,7 +123,7 @@ export default {
this.isUpdatingStatus = true; this.isUpdatingStatus = true;
updateIssue(this.issue, { status }) updateIssue(this.issue, { status })
.then((response) => { .then((response) => {
this.issue = response; this.issue.status = response.status;
}) })
.catch(() => { .catch(() => {
createFlash({ createFlash({
......
...@@ -91,6 +91,10 @@ export default { ...@@ -91,6 +91,10 @@ export default {
toggleSidebar() { toggleSidebar() {
this.sidebarToggleEl.dispatchEvent(new Event('click')); this.sidebarToggleEl.dispatchEvent(new Event('click'));
}, },
afterSidebarTransitioned(callback) {
// Wait for sidebar expand animation to complete
this.sidebarEl.addEventListener('transitionend', callback, { once: true });
},
expandSidebarAndOpenDropdown(dropdownRef = null) { expandSidebarAndOpenDropdown(dropdownRef = null) {
// Expand the sidebar if not already expanded. // Expand the sidebar if not already expanded.
if (!this.sidebarExpanded) { if (!this.sidebarExpanded) {
...@@ -98,15 +102,9 @@ export default { ...@@ -98,15 +102,9 @@ export default {
} }
if (dropdownRef) { if (dropdownRef) {
// Wait for sidebar expand animation to complete this.afterSidebarTransitioned(() => {
// before revealing the dropdown. dropdownRef.expand();
this.sidebarEl.addEventListener( });
'transitionend',
() => {
dropdownRef.expand();
},
{ once: true },
);
} }
}, },
onIssueLabelsClose() { onIssueLabelsClose() {
...@@ -114,13 +112,9 @@ export default { ...@@ -114,13 +112,9 @@ export default {
}, },
onIssueLabelsToggle() { onIssueLabelsToggle() {
this.expandSidebarAndOpenDropdown(); this.expandSidebarAndOpenDropdown();
this.sidebarEl.addEventListener( this.afterSidebarTransitioned(() => {
'transitionend', this.isEditingLabels = true;
() => { });
this.isEditingLabels = true;
},
{ once: true },
);
}, },
onIssueLabelsUpdated(labels) { onIssueLabelsUpdated(labels) {
this.$emit('issue-labels-updated', labels); this.$emit('issue-labels-updated', labels);
......
...@@ -120,6 +120,22 @@ describe('JiraIssuesShow', () => { ...@@ -120,6 +120,22 @@ describe('JiraIssuesShow', () => {
await waitForPromises(); await waitForPromises();
}); });
it('updates issue labels on issue-labels-updated', async () => {
const updateIssueSpy = jest.spyOn(JiraIssuesShowApi, 'updateIssue').mockResolvedValue();
const labels = [{ id: 'ecosystem' }];
findJiraIssueSidebar().vm.$emit('issue-labels-updated', labels);
await wrapper.vm.$nextTick();
expect(updateIssueSpy).toHaveBeenCalledWith(expect.any(Object), { labels });
expect(findJiraIssueSidebar().props('isUpdatingLabels')).toBe(true);
await waitForPromises();
expect(findJiraIssueSidebar().props('isUpdatingLabels')).toBe(false);
});
it('fetches issue statuses on issue-status-fetch', async () => { it('fetches issue statuses on issue-status-fetch', async () => {
const fetchIssueStatusesSpy = jest const fetchIssueStatusesSpy = jest
.spyOn(JiraIssuesShowApi, 'fetchIssueStatuses') .spyOn(JiraIssuesShowApi, 'fetchIssueStatuses')
......
...@@ -101,7 +101,11 @@ RSpec.describe EE::IntegrationsHelper do ...@@ -101,7 +101,11 @@ RSpec.describe EE::IntegrationsHelper do
end end
it 'includes Jira issues show data' do it 'includes Jira issues show data' do
is_expected.to include(:issues_show_path) is_expected.to include(
issue_labels_path: "/#{project.full_path}/-/integrations/jira/issues/FE-1/labels",
issues_show_path: "/#{project.full_path}/-/integrations/jira/issues/FE-1.json",
issues_list_path: "/#{project.full_path}/-/integrations/jira/issues"
)
end end
end end
......
...@@ -86,6 +86,7 @@ RSpec.describe Integrations::JiraSerializers::IssueDetailEntity do ...@@ -86,6 +86,7 @@ RSpec.describe Integrations::JiraSerializers::IssueDetailEntity do
state: 'closed', state: 'closed',
labels: [ labels: [
{ {
id: 'backend',
title: 'backend', title: 'backend',
name: 'backend', name: 'backend',
color: '#0052CC', color: '#0052CC',
......
...@@ -53,6 +53,7 @@ RSpec.describe Integrations::JiraSerializers::IssueEntity do ...@@ -53,6 +53,7 @@ RSpec.describe Integrations::JiraSerializers::IssueEntity do
status: 'To Do', status: 'To Do',
labels: [ labels: [
{ {
id: 'backend',
title: 'backend', title: 'backend',
name: 'backend', name: 'backend',
color: '#0052CC', color: '#0052CC',
......
...@@ -18478,6 +18478,9 @@ msgstr "" ...@@ -18478,6 +18478,9 @@ msgstr ""
msgid "JiraService|Failed to load Jira issue. View the issue in Jira, or reload the page." msgid "JiraService|Failed to load Jira issue. View the issue in Jira, or reload the page."
msgstr "" msgstr ""
msgid "JiraService|Failed to update Jira issue labels. View the issue in Jira, or reload the page."
msgstr ""
msgid "JiraService|Failed to update Jira issue status. View the issue in Jira, or reload the page." msgid "JiraService|Failed to update Jira issue status. View the issue in Jira, or reload the page."
msgstr "" msgstr ""
......
...@@ -54,7 +54,6 @@ describe('DropdownContentsLabelsView', () => { ...@@ -54,7 +54,6 @@ describe('DropdownContentsLabelsView', () => {
afterEach(() => { afterEach(() => {
wrapper.destroy(); wrapper.destroy();
wrapper = null;
}); });
const findDropdownContent = () => wrapper.find('[data-testid="dropdown-content"]'); const findDropdownContent = () => wrapper.find('[data-testid="dropdown-content"]');
...@@ -381,6 +380,15 @@ describe('DropdownContentsLabelsView', () => { ...@@ -381,6 +380,15 @@ describe('DropdownContentsLabelsView', () => {
expect(findDropdownFooter().exists()).toBe(false); expect(findDropdownFooter().exists()).toBe(false);
}); });
it('does not render footer list items when `allowLabelCreate` is false and `labelsManagePath` is null', () => {
createComponent({
...mockConfig,
allowLabelCreate: false,
labelsManagePath: null,
});
expect(findDropdownFooter().exists()).toBe(false);
});
it('renders footer list items when `state.variant` is "embedded"', () => { it('renders footer list items when `state.variant` is "embedded"', () => {
expect(findDropdownFooter().exists()).toBe(true); expect(findDropdownFooter().exists()).toBe(true);
}); });
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment