Skip to content

Commit

Permalink
Merge pull request #6653 from wordpress-mobile/test/add-dark-mode-tests
Browse files Browse the repository at this point in the history
test: Add dark mode tests
  • Loading branch information
dcalhoun authored Feb 26, 2024
2 parents ddcac16 + 02c5b96 commit 0fbf08f
Show file tree
Hide file tree
Showing 13 changed files with 112 additions and 2 deletions.
21 changes: 20 additions & 1 deletion __device-tests__/gutenberg-editor-gallery-visual.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
* Internal dependencies
*/
const { blockNames } = editorPage;
import { takeScreenshot } from './utils';
const { toggleDarkMode } = e2eUtils;
import { takeScreenshot, takeScreenshotByElement } from './utils';

describe( 'Gutenberg Editor Visual test for Gallery Block', () => {
it( 'should be able to render the placeholder correctly', async () => {
Expand Down Expand Up @@ -31,4 +32,22 @@ describe( 'Gutenberg Editor Visual test for Gallery Block', () => {
const screenshot = await takeScreenshot();
expect( screenshot ).toMatchImageSnapshot();
} );

it( 'should display correct colors for dark mode', async () => {
await toggleDarkMode( editorPage.driver, true );
await editorPage.initializeEditor( {
initialData: [ e2eTestData.galleryBlockTwoImages ].join( '\n\n' ),
} );

const block = await editorPage.selectBlock(
await editorPage.getBlockAtPosition( blockNames.gallery )
);
await editorPage.driver.pause( 5000 ); // Wait for images to load

const screenshot = await takeScreenshotByElement( block, {
padding: 7,
} );
await toggleDarkMode( editorPage.driver, false );
expect( screenshot ).toMatchImageSnapshot();
} );
} );
39 changes: 39 additions & 0 deletions __device-tests__/gutenberg-editor-media-text-visual.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/**
* Internal dependencies
*/
const { blockNames } = editorPage;
const { toggleDarkMode } = e2eUtils;
import { takeScreenshotByElement } from './utils';

const mediaTextBlock = `<!-- wp:media-text -->
<div class="wp-block-media-text is-stacked-on-mobile"><figure class="wp-block-media-text__media"></figure><div class="wp-block-media-text__content"><!-- wp:paragraph -->
<p></p>
<!-- /wp:paragraph --></div></div>
<!-- /wp:media-text -->`;

describe( 'Gutenberg Editor Visual test for Media & Text Block', () => {
it( 'should display correct colors for dark mode', async () => {
await toggleDarkMode( editorPage.driver, true );
await editorPage.initializeEditor( {
initialData: mediaTextBlock,
} );

const tapOutsideMediaButton = {
offset: {
x: ( width ) => Math.floor( width * -0.5 + 20 ),
y: ( height ) => Math.floor( height * -0.5 + 20 ),
},
};

const block = await editorPage.selectBlock(
await editorPage.getBlockAtPosition( blockNames.mediaText ),
tapOutsideMediaButton
);

const screenshot = await takeScreenshotByElement( block, {
padding: 7,
} );
await toggleDarkMode( editorPage.driver, false );
expect( screenshot ).toMatchImageSnapshot();
} );
} );
28 changes: 28 additions & 0 deletions __device-tests__/gutenberg-editor-quote-visual.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
* Internal dependencies
*/
const { blockNames } = editorPage;
const { toggleDarkMode } = e2eUtils;
import { takeScreenshotByElement } from './utils';

const quoteBlock = `<!-- wp:quote -->
<blockquote class="wp-block-quote"><!-- wp:paragraph -->
<p>Hello, world!</p>
<!-- /wp:paragraph --><cite>A person</cite></blockquote>
<!-- /wp:quote -->`;

describe( 'Gutenberg Editor Visual test for Quote Block', () => {
it( 'should display correct colors for dark mode', async () => {
await toggleDarkMode( editorPage.driver, true );
await editorPage.initializeEditor( {
initialData: quoteBlock,
} );

const block = await editorPage.getBlockAtPosition( blockNames.quote );
const screenshot = await takeScreenshotByElement( block, {
padding: 7,
} );
await toggleDarkMode( editorPage.driver, false );
expect( screenshot ).toMatchImageSnapshot();
} );
} );
24 changes: 24 additions & 0 deletions __device-tests__/gutenberg-editor-shortcode-visual.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/**
* Internal dependencies
*/
const { blockNames } = editorPage;
const { toggleDarkMode } = e2eUtils;
import { takeScreenshotByElement } from './utils';

const shortcodeBlock = `<!-- wp:shortcode /-->`;

describe( 'Gutenberg Editor Visual test for Shortcode Block', () => {
it( 'should display correct colors for dark mode', async () => {
await toggleDarkMode( editorPage.driver, true );
await editorPage.initializeEditor( {
initialData: shortcodeBlock,
} );

const block = await editorPage.getBlockAtPosition(
blockNames.shortcode
);
const screenshot = await takeScreenshotByElement( block );
await toggleDarkMode( editorPage.driver, false );
expect( screenshot ).toMatchImageSnapshot();
} );
} );
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion gutenberg
Submodule gutenberg updated 53 files
+1 −1 .github/CODEOWNERS
+1 −1 .github/workflows/php-changes-detection.yml
+254 −0 changelog.txt
+1 −1 docs/contributors/code/react-native/README.md
+1 −1 docs/reference-guides/theme-json-reference/theme-json-living.md
+4 −1 gutenberg.php
+1 −0 lib/class-wp-theme-json-gutenberg.php
+1 −1 lib/theme.json
+2 −2 package-lock.json
+1 −1 package.json
+1 −0 packages/block-editor/src/components/block-edit/context.js
+5 −1 packages/block-editor/src/components/block-edit/index.js
+2 −1 packages/block-editor/src/components/block-list/content.scss
+6 −5 packages/block-editor/src/components/global-styles/border-panel.js
+53 −10 packages/block-editor/src/components/global-styles/shadow-panel-components.js
+18 −2 packages/block-editor/src/components/global-styles/style.scss
+56 −26 packages/block-editor/src/components/iframe/index.js
+10 −4 packages/block-editor/src/components/inserter/menu.js
+2 −1 packages/block-editor/src/components/inserter/search-results.js
+10 −0 packages/block-editor/src/components/inserter/style.scss
+2 −1 packages/block-editor/src/components/inserter/tabs.js
+1 −1 packages/block-editor/src/components/resizable-box-popover/index.js
+50 −44 packages/block-editor/src/components/rich-text/index.js
+4 −0 packages/block-editor/src/components/rich-text/use-enter.js
+2 −4 packages/block-editor/src/store/actions.js
+0 −4 packages/block-editor/src/store/test/actions.js
+20 −0 packages/block-editor/src/utils/calculate-scale.js
+2 −0 packages/block-library/src/block/index.php
+5 −0 packages/block-library/src/calendar/index.php
+2 −0 packages/block-library/src/comments/index.php
+16 −2 packages/block-library/src/cover/edit/block-controls.js
+7 −3 packages/data/src/redux-store/index.js
+1 −1 packages/e2e-test-utils-playwright/src/request-utils/index.ts
+7 −9 packages/edit-site/src/components/block-editor/editor-canvas.js
+0 −3 packages/edit-site/src/components/block-editor/style.scss
+1 −1 packages/edit-site/src/components/global-styles/screen-typography.js
+0 −0 packages/edit-site/src/components/global-styles/typography-elements.js
+5 −0 packages/edit-site/src/components/layout/index.js
+0 −22 packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/edit-button.js
+0 −2 packages/edit-site/src/components/sidebar-navigation-screen-navigation-menu/single-navigation-menu.js
+1 −1 packages/edit-site/src/style.scss
+1 −1 packages/element/README.md
+1 −1 packages/element/src/platform.js
+74 −0 packages/interactivity/docs/api-reference.md
+1 −0 packages/react-native-bridge/common/gutenberg-web-single-block/editor-style-overrides.css
+10 −0 packages/react-native-editor/__device-tests__/helpers/test-data.js
+32 −0 packages/react-native-editor/__device-tests__/pages/editor-page.js
+2 −0 packages/widgets/src/blocks/legacy-widget/index.php
+6 −0 phpunit/class-wp-theme-json-test.php
+1 −1 schemas/json/theme.json
+5 −3 test/e2e/specs/editor/various/dropdown-menu.spec.js
+5 −62 test/e2e/specs/site-editor/navigation-editor.spec.js
+1 −1 test/native/jest.config.js

0 comments on commit 0fbf08f

Please sign in to comment.