BigW Consortium Gitlab

Commit b4e2f9f1 by Regis

test async nature of issue show

parent 3417e97c
...@@ -20,7 +20,7 @@ export default { ...@@ -20,7 +20,7 @@ export default {
errorCallback: (err) => { errorCallback: (err) => {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
// eslint-disable-next-line no-console // eslint-disable-next-line no-console
console.error('ISSUE SHOW TITLE REALTIME ERROR', err); console.error('ISSUE SHOW REALTIME ERROR', err);
} else { } else {
throw new Error(err); throw new Error(err);
} }
......
...@@ -70,7 +70,6 @@ feature 'Task Lists', feature: true do ...@@ -70,7 +70,6 @@ feature 'Task Lists', feature: true do
it 'renders' do it 'renders' do
visit_issue(project, issue) visit_issue(project, issue)
wait_for_vue_resource wait_for_vue_resource
expect(page).to have_selector('ul.task-list', count: 1) expect(page).to have_selector('ul.task-list', count: 1)
...@@ -80,11 +79,10 @@ feature 'Task Lists', feature: true do ...@@ -80,11 +79,10 @@ feature 'Task Lists', feature: true do
it 'contains the required selectors' do it 'contains the required selectors' do
visit_issue(project, issue) visit_issue(project, issue)
wait_for_vue_resource
container = '.detail-page-description .description.js-task-list-container' container = '.detail-page-description .description.js-task-list-container'
wait_for_vue_resource
expect(page).to have_selector(container) expect(page).to have_selector(container)
expect(page).to have_selector("#{container} .wiki .task-list .task-list-item .task-list-item-checkbox") expect(page).to have_selector("#{container} .wiki .task-list .task-list-item .task-list-item-checkbox")
expect(page).to have_selector("#{container} .js-task-list-field") expect(page).to have_selector("#{container} .js-task-list-field")
...@@ -94,16 +92,13 @@ feature 'Task Lists', feature: true do ...@@ -94,16 +92,13 @@ feature 'Task Lists', feature: true do
it 'is only editable by author' do it 'is only editable by author' do
visit_issue(project, issue) visit_issue(project, issue)
wait_for_vue_resource wait_for_vue_resource
expect(page).to have_selector('.js-task-list-container') expect(page).to have_selector('.js-task-list-container')
logout(:user) logout(:user)
login_as(user2) login_as(user2)
visit current_path visit current_path
wait_for_vue_resource wait_for_vue_resource
expect(page).not_to have_selector('.js-task-list-container') expect(page).not_to have_selector('.js-task-list-container')
end end
...@@ -119,7 +114,6 @@ feature 'Task Lists', feature: true do ...@@ -119,7 +114,6 @@ feature 'Task Lists', feature: true do
it 'renders' do it 'renders' do
visit_issue(project, issue) visit_issue(project, issue)
wait_for_vue_resource wait_for_vue_resource
expect(page).to have_selector('ul.task-list', count: 1) expect(page).to have_selector('ul.task-list', count: 1)
...@@ -138,7 +132,6 @@ feature 'Task Lists', feature: true do ...@@ -138,7 +132,6 @@ feature 'Task Lists', feature: true do
it 'renders' do it 'renders' do
visit_issue(project, issue) visit_issue(project, issue)
wait_for_vue_resource wait_for_vue_resource
expect(page).to have_selector('ul.task-list', count: 1) expect(page).to have_selector('ul.task-list', count: 1)
......
import Vue from 'vue'; import Vue from 'vue';
import $ from 'jquery';
import '~/render_math';
import '~/render_gfm';
import issueTitle from '~/issue_show/issue_title_description.vue'; import issueTitle from '~/issue_show/issue_title_description.vue';
import issueShowData from './mock_data';
window.$ = $;
const issueShowInterceptor = (request, next) => {
console.log(issueShowData);
next(request.respondWith(JSON.stringify(issueShowData), {
status: 200,
}));
};
describe('Issue Title', () => { describe('Issue Title', () => {
let IssueTitleComponent; const comps = {
IssueTitleComponent: {},
};
beforeEach(() => { beforeEach(() => {
IssueTitleComponent = Vue.extend(issueTitle); comps.IssueTitleComponent = Vue.extend(issueTitle);
Vue.http.interceptors.push(issueShowInterceptor);
});
afterEach(() => {
Vue.http.interceptors = _.without(
Vue.http.interceptors, issueShowInterceptor,
);
}); });
it('should render a title', () => { it('should render a title', (done) => {
const component = new IssueTitleComponent({ const issueShowComponent = new comps.IssueTitleComponent({
propsData: { propsData: {
initialTitle: 'wow', candescription: '.css-stuff',
endpoint: '/gitlab-org/gitlab-shell/issues/9/rendered_title', endpoint: '/gitlab-org/gitlab-shell/issues/9/rendered_title',
}, },
}).$mount(); }).$mount();
expect(component.$el.classList).toContain('title'); // need setTimeout because actual setTimeout in code :P
expect(component.$el.innerHTML).toContain('wow'); setTimeout(() => {
expect(issueShowComponent.$el.querySelector('.title').innerHTML)
.toContain('this is a title');
done();
}, 300);
// 300 is just three times the Vue comps setTimeout to ensure pass
}); });
}); });
export default {
title: '<p>this is a title</p>',
description: '<p>this is a description!</p>',
description_text: 'this is a description',
};
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