Commit a48c07da authored by Eric Eastwood's avatar Eric Eastwood

Use js- classes instead of Vue refs in tests for some perf

See
https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/14272#note_41419104
parent f2c23ab8
...@@ -26,9 +26,8 @@ export default { ...@@ -26,9 +26,8 @@ export default {
<ci-icon v-else :status="statusObj" /> <ci-icon v-else :status="statusObj" />
<button <button
v-if="showDisabledButton" v-if="showDisabledButton"
ref="mergeButton"
type="button" type="button"
class="btn btn-success btn-sm" class="js-disabled-merge-button btn btn-success btn-sm"
disabled="true"> disabled="true">
Merge Merge
</button> </button>
......
...@@ -11,16 +11,15 @@ export default { ...@@ -11,16 +11,15 @@ export default {
template: ` template: `
<div class="mr-widget-body media"> <div class="mr-widget-body media">
<status-icon <status-icon
ref="statusIcon"
status="failed" status="failed"
showDisabledButton /> showDisabledButton />
<div class="media-body space-children"> <div class="media-body space-children">
<template v-if="mr.ffOnlyEnabled"> <span
<span class="bold"> v-if="mr.ffOnlyEnabled"
class="bold">
Fast-forward merge is not possible. Fast-forward merge is not possible.
To merge this request, first rebase locally To merge this request, first rebase locally
</span> </span>
</template>
<template v-else> <template v-else>
<span class="bold"> <span class="bold">
There are merge conflicts<span v-if="!mr.canMerge">.</span> There are merge conflicts<span v-if="!mr.canMerge">.</span>
...@@ -30,15 +29,13 @@ export default { ...@@ -30,15 +29,13 @@ export default {
</span> </span>
<a <a
v-if="mr.canMerge && mr.conflictResolutionPath" v-if="mr.canMerge && mr.conflictResolutionPath"
ref="resolveConflictsButton"
:href="mr.conflictResolutionPath" :href="mr.conflictResolutionPath"
class="btn btn-default btn-xs"> class="js-resolve-conflicts-button btn btn-default btn-xs">
Resolve conflicts Resolve conflicts
</a> </a>
<a <a
v-if="mr.canMerge" v-if="mr.canMerge"
ref="mergeLocallyButton" class="js-merge-locally-button btn btn-default btn-xs"
class="btn btn-default btn-xs"
data-toggle="modal" data-toggle="modal"
href="#modal_merge_info"> href="#modal_merge_info">
Merge locally Merge locally
......
...@@ -286,15 +286,14 @@ export default { ...@@ -286,15 +286,14 @@ export default {
<span <span
v-if="mr.ffOnlyEnabled" v-if="mr.ffOnlyEnabled"
ref="fastForwardMessage"> class="js-fast-forward-message">
Fast-forward merge without a merge commit Fast-forward merge without a merge commit
</span> </span>
<button <button
v-else v-else
ref="modifyCommitMessageButton"
@click="toggleCommitMessageEditor" @click="toggleCommitMessageEditor"
:disabled="isMergeButtonDisabled" :disabled="isMergeButtonDisabled"
class="btn btn-default btn-xs" class="js-modify-commit-message-button btn btn-default btn-xs"
type="button"> type="button">
Modify commit message Modify commit message
</button> </button>
......
...@@ -28,25 +28,29 @@ describe('MRWidgetConflicts', () => { ...@@ -28,25 +28,29 @@ describe('MRWidgetConflicts', () => {
}); });
}); });
afterEach(() => {
vm.$destroy();
});
it('should tell you about conflicts without bothering other people', () => { it('should tell you about conflicts without bothering other people', () => {
expect(vm.$el.textContent).toContain('There are merge conflicts'); expect(vm.$el.textContent).toContain('There are merge conflicts');
expect(vm.$el.textContent).not.toContain('ask someone with write access'); expect(vm.$el.textContent).not.toContain('ask someone with write access');
}); });
it('should allow you to resolve the conflicts', () => { it('should allow you to resolve the conflicts', () => {
const resolveButton = vm.$refs.resolveConflictsButton; const resolveButton = vm.$el.querySelector('.js-resolve-conflicts-button');
expect(resolveButton.textContent).toContain('Resolve conflicts'); expect(resolveButton.textContent).toContain('Resolve conflicts');
expect(resolveButton.getAttribute('href')).toEqual(path); expect(resolveButton.getAttribute('href')).toEqual(path);
}); });
it('should have merge buttons', () => { it('should have merge buttons', () => {
const mergeButton = vm.$refs.statusIcon.$refs.mergeButton; const mergeButton = vm.$el.querySelector('.js-disabled-merge-button');
const mergeLocallyButton = vm.$refs.mergeLocallyButton; const mergeLocallyButton = vm.$el.querySelector('.js-merge-locally-button');
expect(mergeButton.textContent).toContain('Merge'); expect(mergeButton.textContent).toContain('Merge');
expect(mergeButton.disabled).toBeTruthy(); expect(mergeButton.disabled).toBeTruthy();
expect(mergeButton.classList.contains('btn-success')).toBeTruthy(); expect(mergeButton.classList.contains('btn-success')).toEqual(true);
expect(mergeLocallyButton.textContent).toContain('Merge locally'); expect(mergeLocallyButton.textContent).toContain('Merge locally');
}); });
}); });
...@@ -62,14 +66,18 @@ describe('MRWidgetConflicts', () => { ...@@ -62,14 +66,18 @@ describe('MRWidgetConflicts', () => {
}); });
}); });
afterEach(() => {
vm.$destroy();
});
it('should show proper message', () => { it('should show proper message', () => {
expect(vm.$el.textContent).toContain('ask someone with write access'); expect(vm.$el.textContent).toContain('ask someone with write access');
}); });
it('should not have action buttons', () => { it('should not have action buttons', () => {
expect(vm.$refs.statusIcon.$refs.mergeButton).toBeDefined(); expect(vm.$el.querySelector('.js-disabled-merge-button')).toBeDefined();
expect(vm.$refs.resolveConflictsButton).toBeUndefined(); expect(vm.$el.querySelector('.js-resolve-conflicts-button')).toBeNull();
expect(vm.$refs.mergeLocallyButton).toBeUndefined(); expect(vm.$el.querySelector('.js-merge-locally-button')).toBeNull();
}); });
}); });
...@@ -84,6 +92,10 @@ describe('MRWidgetConflicts', () => { ...@@ -84,6 +92,10 @@ describe('MRWidgetConflicts', () => {
}); });
}); });
afterEach(() => {
vm.$destroy();
});
it('should tell you to rebase locally', () => { it('should tell you to rebase locally', () => {
expect(vm.$el.textContent).toContain('Fast-forward merge is not possible.'); expect(vm.$el.textContent).toContain('Fast-forward merge is not possible.');
expect(vm.$el.textContent).toContain('To merge this request, first rebase locally'); expect(vm.$el.textContent).toContain('To merge this request, first rebase locally');
......
...@@ -474,8 +474,8 @@ describe('MRWidgetReadyToMerge', () => { ...@@ -474,8 +474,8 @@ describe('MRWidgetReadyToMerge', () => {
mr: { ffOnlyEnabled: false }, mr: { ffOnlyEnabled: false },
}); });
expect(customVm.$refs.fastForwardMessage).toBeUndefined(); expect(customVm.$el.querySelector('.js-fast-forward-message')).toBeNull();
expect(customVm.$refs.modifyCommitMessageButton).toBeDefined(); expect(customVm.$el.querySelector('.js-modify-commit-message-button')).toBeDefined();
}); });
it('when fast-forward merge is enabled, only show fast-forward message', () => { it('when fast-forward merge is enabled, only show fast-forward message', () => {
...@@ -483,8 +483,8 @@ describe('MRWidgetReadyToMerge', () => { ...@@ -483,8 +483,8 @@ describe('MRWidgetReadyToMerge', () => {
mr: { ffOnlyEnabled: true }, mr: { ffOnlyEnabled: true },
}); });
expect(customVm.$refs.fastForwardMessage).toBeDefined(); expect(customVm.$el.querySelector('.js-fast-forward-message')).toBeDefined();
expect(customVm.$refs.modifyCommitMessageButton).toBeUndefined(); expect(customVm.$el.querySelector('.js-modify-commit-message-button')).toBeNull();
}); });
}); });
}); });
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