Skip to content
This repository has been archived by the owner on Mar 13, 2024. It is now read-only.

Commit

Permalink
MM-12996/MM-13229 - Updating modals on mobile and fixing plugin butto…
Browse files Browse the repository at this point in the history
…n on mobile (#2086)

* MM-12996 - Updating modals on mobile

* Updating snapshots

* Updating test

* Updating test

* Updating tests

* Update unit tests for MobileChannelHeaderPlug
  • Loading branch information
asaadmahmood authored and hmhealey committed Nov 29, 2018
1 parent dbe7bbe commit f057e0a
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,22 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
isDropdown={false}
theme={Object {}}
>
<button
className="navbar-toggle navbar-right__icon"
onClick={[Function]}
<li
className="flex-parent--center"
>
<span
className="icon navbar-plugin-button"
<button
className="navbar-toggle navbar-right__icon"
onClick={[Function]}
>
<i
className="fa fa-anchor"
/>
</span>
</button>
<span
className="icon navbar-plugin-button"
>
<i
className="fa fa-anchor"
/>
</span>
</button>
</li>
</MobileChannelHeaderPlug>
`;

Expand All @@ -75,18 +79,22 @@ exports[`plugins/MobileChannelHeaderPlug should match snapshot with one extended
isDropdown={true}
theme={Object {}}
>
<button
className="navbar-toggle navbar-right__icon"
onClick={[Function]}
<li
className="flex-parent--center"
>
<span
className="icon navbar-plugin-button"
<button
className="navbar-toggle navbar-right__icon"
onClick={[Function]}
>
<i
className="fa fa-anchor"
/>
</span>
</button>
<span
className="icon navbar-plugin-button"
>
<i
className="fa fa-anchor"
/>
</span>
</button>
</li>
</MobileChannelHeaderPlug>
`;

Expand Down
18 changes: 10 additions & 8 deletions plugins/mobile_channel_header_plug/mobile_channel_header_plug.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ export default class MobileChannelHeaderPlug extends React.PureComponent {

createButton(plug) {
return (
<button
className='navbar-toggle navbar-right__icon'
onClick={() => this.fireAction(plug)}
>
<span className='icon navbar-plugin-button'>
{plug.icon}
</span>
</button>
<li className='flex-parent--center'>
<button
className='navbar-toggle navbar-right__icon'
onClick={() => this.fireAction(plug)}
>
<span className='icon navbar-plugin-button'>
{plug.icon}
</span>
</button>
</li>
);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ describe('plugins/MobileChannelHeaderPlug', () => {
/>
);
expect(wrapper).toMatchSnapshot();

// Render nothing
expect(wrapper.find('li').exists()).toBe(false);
});

test('should match snapshot with one extended component', () => {
Expand All @@ -40,10 +43,11 @@ describe('plugins/MobileChannelHeaderPlug', () => {
);
expect(wrapper).toMatchSnapshot();

wrapper.instance().fireAction = jest.fn();
expect(wrapper.find('button').exists()).toEqual(true);
expect(wrapper.find('li').exists()).toEqual(false);
// Render a single list item containing a button
expect(wrapper.find('li')).toHaveLength(1);
expect(wrapper.find('button')).toHaveLength(1);

wrapper.instance().fireAction = jest.fn();
wrapper.find('button').first().simulate('click');
expect(wrapper.instance().fireAction).toHaveBeenCalledTimes(1);
expect(wrapper.instance().fireAction).toBeCalledWith(testPlug);
Expand All @@ -60,6 +64,9 @@ describe('plugins/MobileChannelHeaderPlug', () => {
/>
);
expect(wrapper).toMatchSnapshot();

// Render nothing
expect(wrapper.find('li').exists()).toBe(false);
});

test('should match snapshot with no extended component, in dropdown', () => {
Expand All @@ -73,6 +80,9 @@ describe('plugins/MobileChannelHeaderPlug', () => {
/>
);
expect(wrapper).toMatchSnapshot();

// Render nothing
expect(wrapper.find('li').exists()).toBe(false);
});

test('should match snapshot with one extended component, in dropdown', () => {
Expand All @@ -87,9 +97,9 @@ describe('plugins/MobileChannelHeaderPlug', () => {
);
expect(wrapper).toMatchSnapshot();

wrapper.instance().fireAction = jest.fn();
expect(wrapper.find('button').exists()).toEqual(true);
expect(wrapper.find('li').exists()).toEqual(false);
// Render a single list item containing a button
expect(wrapper.find('li')).toHaveLength(1);
expect(wrapper.find('button')).toHaveLength(1);
});

test('should match snapshot with two extended components, in dropdown', () => {
Expand All @@ -104,9 +114,12 @@ describe('plugins/MobileChannelHeaderPlug', () => {
);
expect(wrapper).toMatchSnapshot();

// Render a two list items containing anchors
expect(wrapper.find('li')).toHaveLength(2);
expect(wrapper.find('button')).toHaveLength(0);
expect(wrapper.find('a')).toHaveLength(2);

wrapper.instance().fireAction = jest.fn();
expect(wrapper.find('button').exists()).toEqual(false);
expect(wrapper.find('li').exists()).toEqual(true);

wrapper.find('a').first().simulate('click');
expect(wrapper.instance().fireAction).toHaveBeenCalledTimes(1);
Expand Down
5 changes: 5 additions & 0 deletions sass/layout/_navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
display: flex;
}

.flex-parent--center {
display: flex;
justify-content: center;
}

.browser--ie & {
.navbar-default {
.navbar-brand {
Expand Down
19 changes: 17 additions & 2 deletions sass/responsive/_mobile.scss
Original file line number Diff line number Diff line change
Expand Up @@ -1558,9 +1558,24 @@
}

.more-modal {
.modal-content {
display: flex;
flex-direction: column;
}

.modal-header {
flex: 0 0 56px;
}

.modal-body {
max-height: calc(100vh - 62px);
padding-bottom: 5px;
flex: 1 1 auto;
max-height: 100%;
display: flex;
}

.filtered-user-list {
flex: 1 1 auto;
height: auto;
}
}
}
Expand Down

0 comments on commit f057e0a

Please sign in to comment.