Skip to content
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] Gallery block: Add integration tests related to its manual tests #38571

Merged
merged 35 commits into from
Mar 1, 2022
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
d69eca9
Add test case: display media picker when selected
fluiddot Feb 2, 2022
6517cf9
Add initializeWithGalleryBlock helper
fluiddot Feb 2, 2022
2892cb6
Add test case for partially covering TC001 manual test
fluiddot Feb 2, 2022
feb9315
Add caption test cases
fluiddot Feb 2, 2022
90a53e6
Make initializeWithGalleryBlock synchronous
fluiddot Feb 2, 2022
71fd147
Add test case: successfully uploads items
fluiddot Feb 2, 2022
98ef408
Add test case: takes a photo
fluiddot Feb 2, 2022
7073918
Add test case: handles failed uploads
fluiddot Feb 2, 2022
04c26b7
Check failed images provide retry option
fluiddot Feb 2, 2022
75c0853
Add test case: uploads from free photo library
fluiddot Feb 2, 2022
bd5bee5
Add test case: cancel uploads
fluiddot Feb 2, 2022
04a823c
Add test case: rearrange gallery items
fluiddot Feb 2, 2022
44119f2
Add test case: upload from other apps
fluiddot Feb 4, 2022
37beb38
Add test case: override Link to setting
fluiddot Feb 4, 2022
8e599a7
Add test case: change columns setting
fluiddot Feb 4, 2022
7635cd6
Add test case: disables crop images setting
fluiddot Feb 4, 2022
96bd3d3
Fix act warning in rearranges gallery items case
fluiddot Feb 4, 2022
4370aed
Add executeStoreResolvers helper
fluiddot Feb 4, 2022
a9fe9e1
Fix toBeVisible custom matcher
fluiddot Feb 4, 2022
49f70d2
Extract helpers from gallery test cases
fluiddot Feb 4, 2022
fe45cde
Remove gallery test fixtures
fluiddot Feb 7, 2022
d9c2b10
Update triggerGalleryLayout helper
fluiddot Feb 7, 2022
ed72c38
Update test case descriptions
fluiddot Feb 7, 2022
6c4077c
Merge branch 'trunk' into rnmobile/add/gallery-block-integration-tests
fluiddot Feb 7, 2022
a8f8f66
Update executeStoreResolvers description
fluiddot Feb 7, 2022
9aa4ff6
Add openBlockSettings helper
fluiddot Feb 7, 2022
b6ced5b
Fix act warnings in executeStoreResolvers
fluiddot Feb 7, 2022
4879835
Split columns setting test cases
fluiddot Feb 7, 2022
6b34d57
Add documentation to helpers
fluiddot Feb 7, 2022
10b2858
Remove wpios string from media options
fluiddot Feb 7, 2022
f805081
Generate gallery block html upon editor initialization
fluiddot Feb 7, 2022
7f10cf9
Remove not needed calls to fireEvent
fluiddot Feb 7, 2022
c1e37ad
Add test id for media placeholder appender icon
fluiddot Feb 18, 2022
1b8343a
Merge branch 'trunk' into rnmobile/add/gallery-block-integration-tests
fluiddot Mar 1, 2022
c9f5756
Rename executeStoreResolvers helper
fluiddot Mar 1, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion packages/block-editor/src/components/index.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@ export {
MEDIA_TYPE_AUDIO,
MEDIA_TYPE_ANY,
} from './media-upload';
export { default as MediaUploadProgress } from './media-upload-progress';
export {
default as MediaUploadProgress,
MEDIA_UPLOAD_STATE_UPLOADING,
MEDIA_UPLOAD_STATE_SUCCEEDED,
MEDIA_UPLOAD_STATE_FAILED,
MEDIA_UPLOAD_STATE_RESET,
ttahmouch marked this conversation as resolved.
Show resolved Hide resolved
} from './media-upload-progress';
export { default as BlockMediaUpdateProgress } from './block-media-update-progress';
export { default as URLInput } from './url-input';
export { default as BlockInvalidWarning } from './block-list/block-invalid-warning';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ export class MediaUpload extends Component {
ref={ ( instance ) => ( this.picker = instance ) }
options={ this.getMediaOptionsItems() }
onChange={ this.onPickerSelect }
testID="media-options-picker"
/>
);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,171 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Gallery block Columns setting decrements columns 1`] = `
"<!-- wp:gallery {\\"columns\\":2,\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-2 is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2001} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2001\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2002} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-3.jpeg\\" alt=\\"\\" class=\\"wp-image-2002\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block Columns setting does not increment due to maximum value 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2001} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2001\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2002} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-3.jpeg\\" alt=\\"\\" class=\\"wp-image-2002\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block cancels uploads 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":null} -->
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found it interesting that when an upload is canceled, it sets the id attribute to null. Looks like this doesn't produce any unexpected side effects but I think it's worth highlighting it.

<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":null} -->
<figure class=\\"wp-block-image\\"><img alt=\\"\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block disables crop images setting 1`] = `
"<!-- wp:gallery {\\"imageCrop\\":false,\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block finishes pending uploads upon opening the editor 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2001} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2001\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block handles failed uploads 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":1} -->
<figure class=\\"wp-block-image\\"><img src=\\"file:///local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2} -->
<figure class=\\"wp-block-image\\"><img src=\\"file:///local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block inserts block 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block overrides "Link to" setting of gallery items 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"media\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":1,\\"linkDestination\\":\\"media\\"} -->
<figure class=\\"wp-block-image\\"><img src=\\"file:///local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-1\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2,\\"linkDestination\\":\\"media\\"} -->
<figure class=\\"wp-block-image\\"><img src=\\"file:///local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block rearranges gallery items 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2002} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-3.jpeg\\" alt=\\"\\" class=\\"wp-image-2002\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2001} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2001\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block sets caption to gallery 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image --><figcaption class=\\"blocks-gallery-caption\\"><strong>Bold</strong> <em>italic</em> <s>strikethrough</s> gallery caption</figcaption></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block sets caption to gallery items 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/><figcaption><strong>Bold</strong> <em>italic</em> <s>strikethrough</s> image caption</figcaption></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block successfully uploads items 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2001} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2001\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block takes a photo 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block uploads from free photo library 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2001} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2001\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;

exports[`Gallery block uploads from other apps 1`] = `
"<!-- wp:gallery {\\"linkTo\\":\\"none\\"} -->
<figure class=\\"wp-block-gallery has-nested-images columns-default is-cropped\\"><!-- wp:image {\\"id\\":2000} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-1.jpeg\\" alt=\\"\\" class=\\"wp-image-2000\\"/></figure>
<!-- /wp:image -->

<!-- wp:image {\\"id\\":2001} -->
<figure class=\\"wp-block-image\\"><img src=\\"https://test-site.files.wordpress.com/local-image-2.jpeg\\" alt=\\"\\" class=\\"wp-image-2001\\"/></figure>
<!-- /wp:image --></figure>
<!-- /wp:gallery -->"
`;
Loading