diff --git a/webpack/assets/javascripts/react_app/components/common/Slot/Slot.test.js b/webpack/assets/javascripts/react_app/components/common/Slot/Slot.test.js
index 8703cd376ad..7ff6cf950a7 100644
--- a/webpack/assets/javascripts/react_app/components/common/Slot/Slot.test.js
+++ b/webpack/assets/javascripts/react_app/components/common/Slot/Slot.test.js
@@ -1,55 +1,27 @@
import React from 'react';
-import IntegrationTestHelper from '../../../common/IntegrationTestHelper';
-
+import '@testing-library/jest-dom';
+import { screen } from '@testing-library/react';
import Fill from '../Fill';
import Slot from './';
-import FillReducer from '../Fill/FillReducer';
+import { rtlHelpers } from '../../../common/rtlTestHelpers';
-const combinedReducers = { extendable: FillReducer };
+const { renderWithStore } = rtlHelpers;
const SlotComponent = ({ text }) =>
{text}
; // eslint-disable-line
jest.unmock('../../../../services/SlotsRegistry');
describe('Slot-Fill', () => {
- const integrationTestHelper = new IntegrationTestHelper(combinedReducers);
-
- it('render multiple fills', () => {
- const FirstComponent = () => Should be the first in the snap;
- const SecondComponent = () => Should be the first in the snap;
- const wrapper = integrationTestHelper.mount(
-
-
-
-
-
-
-
-
-
- defaul value
-
-
- );
-
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
- integrationTestHelper.takeStoreSnapshot();
- integrationTestHelper.takeActionsSnapshot();
- });
-
- it('Slot with a prop should be pass to a fill', () => {
- const wrapper = integrationTestHelper.mount(
+ it('Slot with a prop should be passed to a fill', async () => {
+ renderWithStore(
-
);
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
+ expect(await screen.findByText('this prop should be taken')).toBeInTheDocument();
});
it('Fill with no component nor overriden props should throw an error', () => {
@@ -58,7 +30,7 @@ describe('Slot-Fill', () => {
// eslint-disable-next-line no-console
console.error = jest.fn();
expect(() => {
- integrationTestHelper.mount(
+ renderWithStore(
@@ -66,16 +38,18 @@ describe('Slot-Fill', () => {
);
}).toThrowError(new Error('Slot with override props must have a child'));
+
// eslint-disable-next-line no-console
console.error = err;
});
- it('no multiple fills', () => {
- const AbsentComponent = () => This should not be in the snap
;
+ it('no multiple fills', async () => {
+ const AbsentComponent = () => This should not be in the snap
;
const PresentComponent = () => (
- This span should be in the snap
+ This span should be in the snap
);
- const wrapper = integrationTestHelper.mount(
+
+ renderWithStore(
@@ -83,18 +57,19 @@ describe('Slot-Fill', () => {
-
- defaul value
+ default value
);
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
+ expect(await screen.findByText('This span should be in the snap')).toBeInTheDocument();
+
+ expect(screen.queryByText('This should not be in the snap')).not.toBeInTheDocument();
});
- it('props fill', () => {
- const wrapper = integrationTestHelper.mount(
+
+ it('props fill', async () => {
+ renderWithStore(
{
id="some-key-1"
weight={100}
/>
-
);
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
+ expect(await screen.findByText('This is given by a prop')).toBeInTheDocument();
});
+
it('default slot', () => {
- const wrapper = integrationTestHelper.mount(
+ renderWithStore(
);
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
+ expect(screen.getByText('Default Value')).toBeInTheDocument();
});
- it('multiple slot with override props', () => {
- const wrapper = integrationTestHelper.mount(
+
+ it('multiple slot with override props', async () => {
+ renderWithStore(
{
);
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
+ const e1 = await screen.findByText('This should be the first');
+ const e2 = await screen.findByText('This should be the second');
+ expect(e1.compareDocumentPosition(e2)).toBe(4);
});
- it('slot with multi override props should take max weight', () => {
- const wrapper = integrationTestHelper.mount(
+ it('slot with multi override props should take max weight', async () => {
+ renderWithStore(
{
);
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
+
+ expect(await screen.findByText('This text should be in the snap')).toBeInTheDocument();
+
+ expect(screen.queryByText('This should not be in the snap')).not.toBeInTheDocument();
});
- it('multi slot with override props fill and component fill', () => {
- const TestComponent = () => Also this should be in the snap
;
- const wrapper = integrationTestHelper.mount(
+ it('multi slot with override props fill and component fill', async () => {
+ const TestComponent = () => Also this should be in the snap
;
+ renderWithStore(
{
);
- wrapper.update();
- expect(wrapper.find('Slot')).toMatchSnapshot();
+
+ expect(await screen.findByText('This should be in the snap')).toBeInTheDocument();
+ expect(await screen.findByText('Also this should be in the snap')).toBeInTheDocument();
});
});
diff --git a/webpack/assets/javascripts/react_app/components/common/Slot/__snapshots__/Slot.test.js.snap b/webpack/assets/javascripts/react_app/components/common/Slot/__snapshots__/Slot.test.js.snap
deleted file mode 100644
index d3fee52ce78..00000000000
--- a/webpack/assets/javascripts/react_app/components/common/Slot/__snapshots__/Slot.test.js.snap
+++ /dev/null
@@ -1,280 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`Slot-Fill Slot with a prop should be pass to a fill 1`] = `
-,
- ]
- }
- id="slot-9"
- multi={false}
- replacedBy=""
- text="this prop should be taken"
->
-
-
- this prop should be taken
-
-
-
-`;
-
-exports[`Slot-Fill default slot 1`] = `
-
-
-
- Default Value
-
-
-
-`;
-
-exports[`Slot-Fill multi slot with override props fill and component fill 1`] = `
-,
- ]
- }
- id="slot-10"
- multi={true}
- replacedBy=""
->
-
-
- This should be in the snap
-
-
-
-
- Also this should be in the snap
-
-
-
-`;
-
-exports[`Slot-Fill multiple slot with override props 1`] = `
-
-
-
- This should be the first
-
-
-
-
- This should be the second
-
-
-
-`;
-
-exports[`Slot-Fill no multiple fills 1`] = `
-,
- ]
- }
- id="slot-2"
- multi={false}
- replacedBy=""
->
-
-
- This span should be in the snap
-
-
-
-`;
-
-exports[`Slot-Fill props fill 1`] = `
-
-
-
- This is given by a prop
-
-
-
-`;
-
-exports[`Slot-Fill render multiple fills 1`] = `
-,
- ,
- ]
- }
- id="slot-1"
- multi={true}
- replacedBy=""
->
-
-
- Should be the first in the snap
-
-
-
-
- Should be the first in the snap
-
-
-
-`;
-
-exports[`Slot-Fill render multiple fills: Integration test actions 1`] = `
-Array [
- Array [
- Object {
- "payload": Object {
- "fillId": "some-key-1",
- "metadata": undefined,
- "slotId": "slot-1",
- "weight": 100,
- },
- "type": "SLOT_AND_FILL_REGISTER_FILL",
- },
- ],
- Array [
- Object {
- "payload": Object {
- "fillId": "some-key-2",
- "metadata": undefined,
- "slotId": "slot-1",
- "weight": 200,
- },
- "type": "SLOT_AND_FILL_REGISTER_FILL",
- },
- ],
-]
-`;
-
-exports[`Slot-Fill render multiple fills: Integration test store 1`] = `
-Object {
- "extendable": Object {
- "slot-1": Object {
- "some-key-1": Object {
- "metadata": undefined,
- "weight": 100,
- },
- "some-key-2": Object {
- "metadata": undefined,
- "weight": 200,
- },
- },
- },
-}
-`;
-
-exports[`Slot-Fill slot with multi override props should take max weight 1`] = `
-
-
-
- This text should be in the snap
-
-
-
-`;