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 {
this.isUpdatingLabels = true;
updateIssue(this.issue, { labels })
.then((response) => {
this.issue = response;
this.issue.labels = response.labels;
})
.catch(() => {
createFlash({
......@@ -123,7 +123,7 @@ export default {
this.isUpdatingStatus = true;
updateIssue(this.issue, { status })
.then((response) => {
this.issue = response;
this.issue.status = response.status;
})
.catch(() => {
createFlash({
......
......@@ -91,6 +91,10 @@ export default {
toggleSidebar() {
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) {
// Expand the sidebar if not already expanded.
if (!this.sidebarExpanded) {
......@@ -98,15 +102,9 @@ export default {
}
if (dropdownRef) {
// Wait for sidebar expand animation to complete
// before revealing the dropdown.
this.sidebarEl.addEventListener(
'transitionend',
() => {
dropdownRef.expand();
},
{ once: true },
);
this.afterSidebarTransitioned(() => {
dropdownRef.expand();
});
}
},
onIssueLabelsClose() {
......@@ -114,13 +112,9 @@ export default {
},
onIssueLabelsToggle() {
this.expandSidebarAndOpenDropdown();
this.sidebarEl.addEventListener(
'transitionend',
() => {
this.isEditingLabels = true;
},
{ once: true },
);
this.afterSidebarTransitioned(() => {
this.isEditingLabels = true;
});
},
onIssueLabelsUpdated(labels) {
this.$emit('issue-labels-updated', labels);
......
......@@ -120,6 +120,22 @@ describe('JiraIssuesShow', () => {
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 () => {
const fetchIssueStatusesSpy = jest
.spyOn(JiraIssuesShowApi, 'fetchIssueStatuses')
......
......@@ -101,7 +101,11 @@ RSpec.describe EE::IntegrationsHelper do
end
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
......
......@@ -86,6 +86,7 @@ RSpec.describe Integrations::JiraSerializers::IssueDetailEntity do
state: 'closed',
labels: [
{
id: 'backend',
title: 'backend',
name: 'backend',
color: '#0052CC',
......
......@@ -53,6 +53,7 @@ RSpec.describe Integrations::JiraSerializers::IssueEntity do
status: 'To Do',
labels: [
{
id: 'backend',
title: 'backend',
name: 'backend',
color: '#0052CC',
......
......@@ -18478,6 +18478,9 @@ msgstr ""
msgid "JiraService|Failed to load Jira issue. View the issue in Jira, or reload the page."
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."
msgstr ""
......
......@@ -54,7 +54,6 @@ describe('DropdownContentsLabelsView', () => {
afterEach(() => {
wrapper.destroy();
wrapper = null;
});
const findDropdownContent = () => wrapper.find('[data-testid="dropdown-content"]');
......@@ -381,6 +380,15 @@ describe('DropdownContentsLabelsView', () => {
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"', () => {
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