-
Notifications
You must be signed in to change notification settings - Fork 4.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RNMobile] Block title in unsupported block #18268
Changes from all commits
e7d8e59
a23f7a3
766ce90
756b5e8
3a9cf57
47b491b
056b1bd
28b6a08
40ec6da
eab0ba3
6bb7dcb
e5a2433
5a9e429
4c2b904
f7c8582
32d4887
4627420
6815b3c
83bba75
91e74a9
b2bbd73
e863087
92d7e71
c4bc0c8
d150383
69998f0
e26a61b
0569a38
973c2f8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,88 @@ | ||
/** @format */ | ||
.content { | ||
padding-top: 8; | ||
padding-bottom: 0; | ||
padding-left: 24; | ||
padding-right: 24; | ||
align-items: center; | ||
justify-content: space-evenly; | ||
} | ||
|
||
.helpIconContainer { | ||
position: absolute; | ||
top: 0; | ||
right: 0; | ||
height: 48; | ||
width: 48; | ||
padding-top: 12; | ||
padding-right: 12; | ||
justify-content: flex-start; | ||
align-items: flex-end; | ||
} | ||
|
||
.infoContainer { | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: flex-end; | ||
} | ||
|
||
.infoIcon { | ||
size: 36; | ||
height: 36; | ||
padding-top: 8; | ||
padding-bottom: 8; | ||
color: $gray-darken-20; | ||
} | ||
|
||
.infoIconDark { | ||
color: $gray-20; | ||
} | ||
|
||
.infoSheetIcon { | ||
size: 36; | ||
height: 36; | ||
padding-top: 8; | ||
padding-bottom: 8; | ||
color: $gray; | ||
} | ||
|
||
.infoSheetIconDark { | ||
color: $gray-20; | ||
} | ||
|
||
.infoText { | ||
text-align: center; | ||
color: $gray-dark; | ||
} | ||
|
||
.infoTextDark { | ||
color: $white; | ||
} | ||
|
||
.infoTitle { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think we must create a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed with 5a9e429. |
||
padding-top: 8; | ||
padding-bottom: 12; | ||
font-size: 20; | ||
font-weight: bold; | ||
color: $gray-dark; | ||
} | ||
|
||
.infoTitleDark { | ||
color: $white; | ||
} | ||
|
||
.infoDescription { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Addressed with 5a9e429. |
||
padding-bottom: 24; | ||
font-size: 16; | ||
color: $gray-darken-20; | ||
} | ||
|
||
.infoDescriptionDark { | ||
color: $gray-20; | ||
} | ||
|
||
.unsupportedBlock { | ||
background-color: #e9eff3; // grey lighten 30 | ||
background-color: $gray-lighten-30; | ||
padding-top: 24; | ||
padding-bottom: 24; | ||
padding-left: 8; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Missing block renders without crashing 1`] = ` | ||
<View> | ||
<View | ||
accessibilityHint="Tap here to show help" | ||
accessibilityLabel="Help icon" | ||
accessibilityRole="button" | ||
accessible={true} | ||
clickable={true} | ||
onClick={[Function]} | ||
onResponderGrant={[Function]} | ||
onResponderMove={[Function]} | ||
onResponderRelease={[Function]} | ||
onResponderTerminate={[Function]} | ||
onResponderTerminationRequest={[Function]} | ||
onStartShouldSetResponder={[Function]} | ||
> | ||
Svg | ||
</View> | ||
Svg | ||
<Text> | ||
missing/block/title | ||
</Text> | ||
<Text> | ||
Unsupported | ||
</Text> | ||
Modal | ||
</View> | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import renderer from 'react-test-renderer'; | ||
import { Text, Platform } from 'react-native'; | ||
|
||
/** | ||
* WordPress dependencies | ||
*/ | ||
import { BottomSheet, Icon } from '@wordpress/components'; | ||
jest.mock( '@wordpress/blocks' ); | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import UnsupportedBlockEdit from '../edit.native.js'; | ||
|
||
const defaultAttributes = { | ||
originalName: 'missing/block/title', | ||
}; | ||
|
||
const getTestComponentWithContent = ( attributes = defaultAttributes ) => { | ||
return renderer.create( <UnsupportedBlockEdit attributes={ attributes } /> ); | ||
}; | ||
|
||
describe( 'Missing block', () => { | ||
it( 'renders without crashing', () => { | ||
const component = getTestComponentWithContent(); | ||
const rendered = component.toJSON(); | ||
expect( rendered ).toMatchSnapshot(); | ||
} ); | ||
|
||
describe( 'help modal', () => { | ||
it( 'renders help icon', () => { | ||
const component = getTestComponentWithContent(); | ||
const testInstance = component.root; | ||
const icons = testInstance.findAllByType( Icon ); | ||
expect( icons.length ).toBe( 2 ); | ||
expect( icons[ 0 ].props.icon ).toBe( 'editor-help' ); | ||
} ); | ||
|
||
it( 'renders info icon on modal', () => { | ||
const component = getTestComponentWithContent(); | ||
const testInstance = component.root; | ||
const bottomSheet = testInstance.findByType( BottomSheet ); | ||
const children = bottomSheet.props.children.props.children; | ||
expect( children.length ).toBe( 3 ); // 4 children in the bottom sheet: the icon, the "isn't yet supported" title and the "We are working hard..." message | ||
expect( children[ 0 ].props.icon ).toBe( 'editor-help' ); | ||
} ); | ||
|
||
it( 'renders unsupported text on modal', () => { | ||
const component = getTestComponentWithContent(); | ||
const testInstance = component.root; | ||
const bottomSheet = testInstance.findByType( BottomSheet ); | ||
const children = bottomSheet.props.children.props.children; | ||
const expectedOSString = Platform.OS === 'ios' ? 'iOS' : 'Android'; | ||
expect( children[ 1 ].props.children ).toBe( '\'' + defaultAttributes.originalName + '\' isn\'t yet supported on WordPress for ' + expectedOSString ); | ||
} ); | ||
} ); | ||
|
||
it( 'renders admin plugins icon', () => { | ||
const component = getTestComponentWithContent(); | ||
const testInstance = component.root; | ||
const icons = testInstance.findAllByType( Icon ); | ||
expect( icons.length ).toBe( 2 ); | ||
expect( icons[ 1 ].props.icon ).toBe( 'admin-plugins' ); | ||
} ); | ||
|
||
it( 'renders title text without crashing', () => { | ||
const component = getTestComponentWithContent(); | ||
const testInstance = component.root; | ||
const texts = testInstance.findAllByType( Text ); | ||
expect( texts.length ).toBe( 2 ); | ||
expect( texts[ 0 ].props.children ).toBe( 'missing/block/title' ); | ||
expect( texts[ 1 ].props.children ).toBe( 'Unsupported' ); | ||
} ); | ||
} ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not an issue for this PR, but noting for the future: I just realized this might be used in other apps, so we should find a way to inject the app name from the apps instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point!