From d17334f3f3c545187d25bfdb683c567f3cd17894 Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 10 May 2023 15:34:18 +0100 Subject: [PATCH 01/10] feat: Pull in changes to setupPicker helper This commit pulls in the changes from this PR, which are needed to use the picker in our tests: https://github.com/WordPress/gutenberg/pull/50493 --- gutenberg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gutenberg b/gutenberg index f134db098d..a9ee3c780e 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit f134db098da5e4784ac0c4aea833140bf010d1a7 +Subproject commit a9ee3c780ea7806335d9691f483a7672e9fee13f From e2a24b65e807fff79d85a9ed159b032fe11390ee Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 10 May 2023 15:35:21 +0100 Subject: [PATCH 02/10] test: Loop through and verify each rating option --- src/test/videopress/edit.js | 20 ++++++++++ .../videopress/local-helpers/constants.js | 2 + src/test/videopress/local-helpers/utils.js | 37 +++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/src/test/videopress/edit.js b/src/test/videopress/edit.js index 7dec3ce42e..4f9086601a 100644 --- a/src/test/videopress/edit.js +++ b/src/test/videopress/edit.js @@ -22,12 +22,14 @@ import { DEFAULT_PROPS, PLAYBACK_SETTINGS, PLAYBACK_BAR_COLOR_SETTINGS, + RATING_OPTIONS, ADDITIONAL_PRIVACY_AND_RATING_SETTINGS, } from './local-helpers/constants'; import { initializeBlockWithHTML, selectAndOpenBlockSettings, pressSettingInPanel, + pressSettingInPicker, } from './local-helpers/utils'; setupCoreBlocks(); @@ -117,6 +119,24 @@ describe( "Update VideoPress block's settings", () => { } ); } ); + /* + * RATING SETTINGS + * Loop through each of the possible ratings and select each one + */ + RATING_OPTIONS.forEach( ( option, index ) => { + // Skip the default setting, as it is already selected + if ( index === 0 ) return; + + it( `should update Privacy and Rating section's rating setting to ${ option }`, async () => { + await pressSettingInPicker( + screen, + 'Privacy and Rating', + 'Rating', + RATING_OPTIONS, + option + ); + } ); + } ); /* * PRIVACY AND RATING SETTINGS * Loop through the additional Privacy and Rating settings and toggle on/off diff --git a/src/test/videopress/local-helpers/constants.js b/src/test/videopress/local-helpers/constants.js index 8327a911a6..7205bab8c5 100644 --- a/src/test/videopress/local-helpers/constants.js +++ b/src/test/videopress/local-helpers/constants.js @@ -17,6 +17,8 @@ export const PLAYBACK_SETTINGS = [ export const PLAYBACK_BAR_COLOR_SETTINGS = [ 'Dynamic color' ]; +export const RATING_OPTIONS = [ 'G', 'PG-13', 'R' ]; + export const ADDITIONAL_PRIVACY_AND_RATING_SETTINGS = [ 'Allow download', 'Show video sharing menu', diff --git a/src/test/videopress/local-helpers/utils.js b/src/test/videopress/local-helpers/utils.js index c42616f024..79c951eb17 100644 --- a/src/test/videopress/local-helpers/utils.js +++ b/src/test/videopress/local-helpers/utils.js @@ -6,6 +6,7 @@ import { getBlock, fireEvent, openBlockSettings, + setupPicker, } from 'test/helpers'; /** * Internal dependencies @@ -48,3 +49,39 @@ export const pressSettingInPanel = async ( screen, panel, setting ) => { // Toggle the specified setting fireEvent.press( getByText( setting ) ); }; + +/** + * Presses a setting in a specified panel, triggers a picker, and selects an option from the sheet. + * + * @param {Object} screen - The editor's screen. + * @param {string} panel - The panel containing the setting to be pressed. + * @param {string} setting - The setting to be pressed, which triggers the picker. + * @param {string[]} options - An array of all the options available in the picker. + * @param {string} option - The option to be selected from the picker. + */ +export const pressSettingInPicker = async ( + screen, + panel, + setting, + options, + option +) => { + const { getByText } = screen; + + // Navigate to the specified settings panel + fireEvent.press( getByText( panel ) ); + + // Select the specified setting to trigger picker + const pickerButtonPressed = async () => { + fireEvent.press( getByText( setting ) ); + }; + + // Setup the picker and select option + const { selectOption } = setupPicker( + screen, + options, + pickerButtonPressed + ); + + await selectOption( option ); +}; From a0997591694197b4dec02e451fdc374a09ce00d1 Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 10 May 2023 15:35:38 +0100 Subject: [PATCH 03/10] test: Loop through and verify each privacy option --- src/test/videopress/edit.js | 21 +++++++++++++++++++ .../videopress/local-helpers/constants.js | 2 ++ 2 files changed, 23 insertions(+) diff --git a/src/test/videopress/edit.js b/src/test/videopress/edit.js index 4f9086601a..1da6387b17 100644 --- a/src/test/videopress/edit.js +++ b/src/test/videopress/edit.js @@ -23,6 +23,7 @@ import { PLAYBACK_SETTINGS, PLAYBACK_BAR_COLOR_SETTINGS, RATING_OPTIONS, + PRIVACY_OPTIONS, ADDITIONAL_PRIVACY_AND_RATING_SETTINGS, } from './local-helpers/constants'; import { @@ -137,6 +138,26 @@ describe( "Update VideoPress block's settings", () => { ); } ); } ); + + /* + * PRIVACY SETTINGS + * Loop through each of the possible privacy options and select each one + */ + PRIVACY_OPTIONS.forEach( ( option, index ) => { + // Skip the default setting, as it is already selected + if ( index === 0 ) return; + + it( `should update Privacy and Rating section's privacy setting to ${ option }`, async () => { + await pressSettingInPicker( + screen, + 'Privacy and Rating', + 'Privacy', + PRIVACY_OPTIONS, + option + ); + } ); + } ); + /* * PRIVACY AND RATING SETTINGS * Loop through the additional Privacy and Rating settings and toggle on/off diff --git a/src/test/videopress/local-helpers/constants.js b/src/test/videopress/local-helpers/constants.js index 7205bab8c5..f199233664 100644 --- a/src/test/videopress/local-helpers/constants.js +++ b/src/test/videopress/local-helpers/constants.js @@ -19,6 +19,8 @@ export const PLAYBACK_BAR_COLOR_SETTINGS = [ 'Dynamic color' ]; export const RATING_OPTIONS = [ 'G', 'PG-13', 'R' ]; +export const PRIVACY_OPTIONS = [ 'Site default (Public)', 'Public', 'Private' ]; + export const ADDITIONAL_PRIVACY_AND_RATING_SETTINGS = [ 'Allow download', 'Show video sharing menu', From f856707771877956873d3c6d2072806ceff89f62 Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 10 May 2023 15:36:13 +0100 Subject: [PATCH 04/10] test: Add snapshots for privacy and rating tests --- src/test/videopress/__snapshots__/edit.js.snap | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/test/videopress/__snapshots__/edit.js.snap b/src/test/videopress/__snapshots__/edit.js.snap index e509ae5aca..20747bbbd9 100644 --- a/src/test/videopress/__snapshots__/edit.js.snap +++ b/src/test/videopress/__snapshots__/edit.js.snap @@ -18,6 +18,18 @@ exports[`Update VideoPress block's settings should update Privacy and Rating sec exports[`Update VideoPress block's settings should update Privacy and Rating section's Show video sharing menu 1`] = `""`; +exports[`Update VideoPress block's settings should update Privacy and Rating section's privacy setting to Private 1`] = `""`; + +exports[`Update VideoPress block's settings should update Privacy and Rating section's privacy setting to Public 1`] = `""`; + +exports[`Update VideoPress block's settings should update Privacy and Rating section's privacy setting to Site default (Public) 1`] = `""`; + +exports[`Update VideoPress block's settings should update Privacy and Rating section's rating setting to G 1`] = `""`; + +exports[`Update VideoPress block's settings should update Privacy and Rating section's rating setting to PG-13 1`] = `""`; + +exports[`Update VideoPress block's settings should update Privacy and Rating section's rating setting to R 1`] = `""`; + exports[`Update VideoPress block's settings should update description 1`] = `""`; exports[`Update VideoPress block's settings should update title 1`] = `""`; From e46c8346c1670aed9190141987b6b4fd8296957c Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 10 May 2023 15:54:57 +0100 Subject: [PATCH 05/10] fix: Remove unused snapshots --- src/test/videopress/__snapshots__/edit.js.snap | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/test/videopress/__snapshots__/edit.js.snap b/src/test/videopress/__snapshots__/edit.js.snap index 20747bbbd9..139c2c4263 100644 --- a/src/test/videopress/__snapshots__/edit.js.snap +++ b/src/test/videopress/__snapshots__/edit.js.snap @@ -22,10 +22,6 @@ exports[`Update VideoPress block's settings should update Privacy and Rating sec exports[`Update VideoPress block's settings should update Privacy and Rating section's privacy setting to Public 1`] = `""`; -exports[`Update VideoPress block's settings should update Privacy and Rating section's privacy setting to Site default (Public) 1`] = `""`; - -exports[`Update VideoPress block's settings should update Privacy and Rating section's rating setting to G 1`] = `""`; - exports[`Update VideoPress block's settings should update Privacy and Rating section's rating setting to PG-13 1`] = `""`; exports[`Update VideoPress block's settings should update Privacy and Rating section's rating setting to R 1`] = `""`; From 3e9720cad55cd51f85fd023e09fbe2344071e212 Mon Sep 17 00:00:00 2001 From: Siobhan Date: Mon, 15 May 2023 16:44:48 +0100 Subject: [PATCH 06/10] test: Ensure block settings at beginning of tests --- src/test/videopress/edit.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/test/videopress/edit.js b/src/test/videopress/edit.js index 15c46cd9f1..226caf2362 100644 --- a/src/test/videopress/edit.js +++ b/src/test/videopress/edit.js @@ -138,6 +138,7 @@ describe( "Update VideoPress block's settings", () => { if ( index === 0 ) return; it( `should update Privacy and Rating section's rating setting to ${ option }`, async () => { + await selectAndOpenBlockSettings( screen ); await pressSettingInPicker( screen, 'Privacy and Rating', @@ -157,6 +158,7 @@ describe( "Update VideoPress block's settings", () => { if ( index === 0 ) return; it( `should update Privacy and Rating section's privacy setting to ${ option }`, async () => { + await selectAndOpenBlockSettings( screen ); await pressSettingInPicker( screen, 'Privacy and Rating', From 180db421ec3a6e0e985d2dd9121441c1ec96ce4e Mon Sep 17 00:00:00 2001 From: Siobhan Date: Mon, 15 May 2023 16:46:36 +0100 Subject: [PATCH 07/10] test: Import 'setupPicker' helper --- src/test/videopress/local-helpers/utils.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/videopress/local-helpers/utils.js b/src/test/videopress/local-helpers/utils.js index b5878a4df0..585910f68f 100644 --- a/src/test/videopress/local-helpers/utils.js +++ b/src/test/videopress/local-helpers/utils.js @@ -1,7 +1,7 @@ /** * External dependencies */ -import { act, getBlock, fireEvent, openBlockSettings } from 'test/helpers'; +import { act, getBlock, fireEvent, openBlockSettings, setupPicker } from 'test/helpers'; export const selectAndOpenBlockSettings = async ( screen ) => { const videoPressBlock = await getBlock( screen, 'VideoPress' ); From c29b3408cd21828c7b3ff2a26c7f4b8be3e7a0de Mon Sep 17 00:00:00 2001 From: Siobhan Date: Tue, 16 May 2023 11:07:31 +0100 Subject: [PATCH 08/10] refactor: Fix formatting of imports --- jetpack | 2 +- src/test/videopress/local-helpers/utils.js | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/jetpack b/jetpack index 5f2d6e6939..97f3d7568b 160000 --- a/jetpack +++ b/jetpack @@ -1 +1 @@ -Subproject commit 5f2d6e6939ccb6aef986f3a24606c547209078a1 +Subproject commit 97f3d7568b41cab487734d71d2437440db70a554 diff --git a/src/test/videopress/local-helpers/utils.js b/src/test/videopress/local-helpers/utils.js index 585910f68f..da91f4cf43 100644 --- a/src/test/videopress/local-helpers/utils.js +++ b/src/test/videopress/local-helpers/utils.js @@ -1,7 +1,13 @@ /** * External dependencies */ -import { act, getBlock, fireEvent, openBlockSettings, setupPicker } from 'test/helpers'; +import { + act, + getBlock, + fireEvent, + openBlockSettings, + setupPicker, +} from 'test/helpers'; export const selectAndOpenBlockSettings = async ( screen ) => { const videoPressBlock = await getBlock( screen, 'VideoPress' ); From 37692881b062e5329c8c84042e78733460bb203a Mon Sep 17 00:00:00 2001 From: Siobhan Date: Tue, 16 May 2023 11:08:06 +0100 Subject: [PATCH 09/10] refactor: setupPicker prior to opening it Relevant discussion here: https://github.com/wordpress-mobile/gutenberg-mobile/pull/5754#discussion_r1192228878 --- src/test/videopress/local-helpers/utils.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/test/videopress/local-helpers/utils.js b/src/test/videopress/local-helpers/utils.js index da91f4cf43..0d4af8c20b 100644 --- a/src/test/videopress/local-helpers/utils.js +++ b/src/test/videopress/local-helpers/utils.js @@ -59,17 +59,10 @@ export const pressSettingInPicker = async ( // Navigate to the specified settings panel fireEvent.press( getByText( panel ) ); - // Select the specified setting to trigger picker - const pickerButtonPressed = async () => { - fireEvent.press( getByText( setting ) ); - }; + // Setup the picker and open picker + const { selectOption } = setupPicker( screen, options ); + fireEvent.press( getByText( setting ) ); - // Setup the picker and select option - const { selectOption } = setupPicker( - screen, - options, - pickerButtonPressed - ); - - await selectOption( option ); + // Select the specified option from the picker + await act( () => selectOption( option ) ); }; From 7adeb1cb178098dae9013209980f9dba2040dfad Mon Sep 17 00:00:00 2001 From: Siobhan Date: Wed, 17 May 2023 09:07:44 +0100 Subject: [PATCH 10/10] fix: Revert changes to submodules --- gutenberg | 2 +- jetpack | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gutenberg b/gutenberg index 541b0dde90..37dc9f6757 160000 --- a/gutenberg +++ b/gutenberg @@ -1 +1 @@ -Subproject commit 541b0dde9023f85d29890eaf4caa86e867cdae11 +Subproject commit 37dc9f67575153857b59550fc964cc2954f45ce2 diff --git a/jetpack b/jetpack index 97f3d7568b..5f2d6e6939 160000 --- a/jetpack +++ b/jetpack @@ -1 +1 @@ -Subproject commit 97f3d7568b41cab487734d71d2437440db70a554 +Subproject commit 5f2d6e6939ccb6aef986f3a24606c547209078a1