Commit 38415d70 authored by Illya Klymov's avatar Illya Klymov

Replace attachToDocument with attachTo: document.body

@vue/test-utils deprecated `attachToDocument` in 1.0.x
parent af894655
......@@ -63,7 +63,7 @@ describe('Approvals ApproversSelect', () => {
...options,
propsData,
localVue,
attachToDocument: true,
attachTo: document.body,
});
await waitForPromises();
......
......@@ -34,7 +34,7 @@ describe('Branches Select', () => {
},
localVue,
store: new Vuex.Store(store),
attachToDocument: true,
attachTo: document.body,
});
await waitForPromises();
......
......@@ -27,7 +27,7 @@ describe('EE Approvals MRRules', () => {
wrapper = mount(localVue.extend(MRRules), {
localVue,
store: new Vuex.Store(store),
attachToDocument: true,
attachTo: document.body,
});
};
......
......@@ -53,7 +53,7 @@ describe('User invites', () => {
beforeEach(() => {
wrapper = mount(Component, {
propsData: { emails: [], docsPath: 'https://some.doc.path' },
attachToDocument: true,
attachTo: document.body,
});
clickButton();
......
......@@ -77,7 +77,7 @@ describe('RelatedIssuableInput', () => {
references: ['foo', 'bar'],
},
// We need to attach to document, so that `document.activeElement` is properly set in jsdom
attachToDocument: true,
attachTo: document.body,
});
wrapper.find('li').trigger('click');
......
......@@ -24,7 +24,7 @@ describe('MrWidgetPipelineContainer', () => {
provide: {
...provide,
},
attachToDocument: true,
attachTo: document.body,
});
};
......
......@@ -2,7 +2,7 @@ export * from '@gitlab/ui';
/**
* The @gitlab/ui tooltip directive requires awkward and distracting set up in tests
* for components that use it (e.g., `attachToDocument: true` and `sync: true` passed
* for components that use it (e.g., `attachTo: document.body` and `sync: true` passed
* to the `mount` helper from `vue-test-utils`).
*
* This mock decouples those tests from the implementation, removing the need to set
......
......@@ -71,7 +71,7 @@ describe('BoardForm', () => {
mutate,
},
},
attachToDocument: true,
attachTo: document.body,
});
};
......
......@@ -94,7 +94,7 @@ describe('BoardsSelector', () => {
weights: [],
},
mocks: { $apollo },
attachToDocument: true,
attachTo: document.body,
});
wrapper.vm.$apollo.addSmartQuery = jest.fn((_, options) => {
......
......@@ -17,7 +17,7 @@ describe('Ci variable modal', () => {
const createComponent = (method, options = {}) => {
store = createStore();
wrapper = method(CiVariableModal, {
attachToDocument: true,
attachTo: document.body,
stubs: {
GlModal: ModalStub,
},
......
......@@ -17,7 +17,7 @@ describe('Ci variable table', () => {
store.state.isGroup = true;
jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = mount(CiVariableTable, {
attachToDocument: true,
attachTo: document.body,
localVue,
store,
});
......
......@@ -19,7 +19,7 @@ describe('Deploy freeze modal', () => {
timezoneData: timezoneDataFixture,
});
wrapper = shallowMount(DeployFreezeModal, {
attachToDocument: true,
attachTo: document.body,
stubs: {
GlModal,
},
......
......@@ -18,7 +18,7 @@ describe('Deploy freeze table', () => {
});
jest.spyOn(store, 'dispatch').mockImplementation();
wrapper = mount(DeployFreezeTable, {
attachToDocument: true,
attachTo: document.body,
localVue,
store,
});
......
......@@ -36,7 +36,7 @@ describe('Design reply form component', () => {
it('textarea has focus after component mount', () => {
// We need to attach to document, so that `document.activeElement` is properly set in jsdom
createComponent({}, { attachToDocument: true });
createComponent({}, { attachTo: document.body });
expect(findTextarea().element).toEqual(document.activeElement);
});
......
......@@ -160,7 +160,7 @@ describe('Design management index page', () => {
localVue,
router,
stubs: { DesignDestroyer, ApolloMutation, VueDraggable, ...stubs },
attachToDocument: true,
attachTo: document.body,
provide: {
projectPath: 'project-path',
issueIid: '1',
......
......@@ -26,7 +26,7 @@ describe('Stacked column chart component', () => {
stubs: {
GlPopover: true,
},
attachToDocument: true,
attachTo: document.body,
});
beforeEach(() => {
......
......@@ -53,7 +53,7 @@ describe('Time series component', () => {
stubs: {
GlPopover: true,
},
attachToDocument: true,
attachTo: document.body,
});
};
......
......@@ -11,7 +11,7 @@ const createMountedWrapper = (props = {}) => {
wrapper = mount(DuplicateDashboardForm, {
propsData: { ...props },
// We need to attach to document, so that `document.activeElement` is properly set in jsdom
attachToDocument: true,
attachTo: document.body,
});
};
......
......@@ -16,8 +16,8 @@ describe('~/pipeline_editor/pipeline_editor_app.vue', () => {
...props,
},
// attachToDocument is required for input/submit events
attachToDocument: mountFn === mount,
// attachTo is required for input/submit events
attachTo: mountFn === mount ? document.body : null,
});
};
......
......@@ -100,8 +100,8 @@ describe('~/pipeline_editor/pipeline_editor_app.vue', () => {
mutate: mockMutate,
},
},
// attachToDocument is required for input/submit events
attachToDocument: mountFn === mount,
// attachTo is required for input/submit events
attachTo: mountFn === mount ? document.body : null,
...options,
});
};
......
......@@ -20,7 +20,7 @@ describe('The DAG graph', () => {
}
wrapper = shallowMount(DagGraph, {
attachToDocument: true,
attachTo: document.body,
propsData,
data() {
return {
......
......@@ -26,7 +26,7 @@ describe('Pipelines filtered search', () => {
projectId: '21',
params,
},
attachToDocument: true,
attachTo: document.body,
});
};
......
......@@ -26,7 +26,7 @@ describe('Pipelines stage component', () => {
const createComponent = (props = {}) => {
wrapper = mount(StageComponent, {
attachToDocument: true,
attachTo: document.body,
propsData: {
...defaultProps,
...props,
......
......@@ -29,7 +29,7 @@ describe('sidebar assignees', () => {
},
},
// Attaching to document is required because this component emits something from the parent element :/
attachToDocument: true,
attachTo: document.body,
});
};
......
......@@ -58,8 +58,20 @@ Object.entries(jqueryMatchers).forEach(([matcherName, matcherFactory]) => {
expect.extend(customMatchers);
// Tech debt issue TBD
testUtilsConfig.logModifiedComponents = false;
testUtilsConfig.deprecationWarningHandler = (method, message) => {
const ALLOWED_DEPRECATED_METHODS = [
// https://gitlab.com/gitlab-org/gitlab/-/issues/295679
'finding components with `find` or `get`',
// https://gitlab.com/gitlab-org/gitlab/-/issues/295680
'finding components with `findAll`',
'options.attachToDocument is deprecated in favor of options.attachTo and will be removed in a future release',
];
if (!ALLOWED_DEPRECATED_METHODS.includes(method)) {
global.console.error(message);
}
};
Object.assign(global, {
requestIdleCallback(cb) {
......
......@@ -31,7 +31,7 @@ describe('ProjectSelector component', () => {
showSearchErrorMessage: false,
totalResults: searchResults.length,
},
attachToDocument: true,
attachTo: document.body,
});
({ vm } = wrapper);
......
......@@ -18,7 +18,7 @@ describe('TooltipOnTruncate component', () => {
const createComponent = ({ propsData, ...options } = {}) => {
wrapper = shallowMount(TooltipOnTruncate, {
attachToDocument: true,
attachTo: document.body,
propsData: {
...propsData,
},
......@@ -44,7 +44,7 @@ describe('TooltipOnTruncate component', () => {
},
{
propsData: { ...propsData },
attachToDocument: true,
attachTo: document.body,
...options,
},
);
......
......@@ -19,7 +19,7 @@ describe('Tooltip directive', () => {
data: () => ({ tooltip: text }),
template,
},
{ attachToDocument: true },
{ attachTo: document.body },
);
}
......
......@@ -36,7 +36,7 @@ describe('validation directive', () => {
`,
};
wrapper = shallowMount(component, { attachToDocument: true });
wrapper = shallowMount(component, { attachTo: document.body });
};
afterEach(() => {
......
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