From b741b0e08406bca71d7f21b795aa4e24f946c1ea Mon Sep 17 00:00:00 2001 From: shimotmk Date: Fri, 5 Aug 2022 12:37:15 +0900 Subject: [PATCH 1/2] fix / highlighter rgba --- src/utils/hex-to-rgba.js | 4 ++ .../highlighter-lightning.test.js.snap | 7 ++ .../highlighter-x-t9.test.js.snap | 7 ++ .../specs/highlighter-lightning.test.js | 66 +++++++++++++++++++ test/e2e-tests/specs/highlighter-x-t9.test.js | 66 +++++++++++++++++++ 5 files changed, 150 insertions(+) create mode 100644 test/e2e-tests/specs/__snapshots__/highlighter-lightning.test.js.snap create mode 100644 test/e2e-tests/specs/__snapshots__/highlighter-x-t9.test.js.snap create mode 100644 test/e2e-tests/specs/highlighter-lightning.test.js create mode 100644 test/e2e-tests/specs/highlighter-x-t9.test.js diff --git a/src/utils/hex-to-rgba.js b/src/utils/hex-to-rgba.js index 9028579ba..d28df5503 100644 --- a/src/utils/hex-to-rgba.js +++ b/src/utils/hex-to-rgba.js @@ -1,5 +1,9 @@ //hexカラーコード定義をrgbaに変換 export default function hex2rgba(hex, alpha) { + // rgbaの場合は、そのまま返す(例:rgba( 255,255,255,0.1 )) + if (hex.substring(0, 4) === 'rgba') { + return hex; + } // ロングバージョンの場合(例:#FF0000) let r = hex.match(/^#([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i); let c = null; diff --git a/test/e2e-tests/specs/__snapshots__/highlighter-lightning.test.js.snap b/test/e2e-tests/specs/__snapshots__/highlighter-lightning.test.js.snap new file mode 100644 index 000000000..5a243912c --- /dev/null +++ b/test/e2e-tests/specs/__snapshots__/highlighter-lightning.test.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`Lightning Highlighter Lightning Highlighter 1`] = ` +" +

1

+" +`; diff --git a/test/e2e-tests/specs/__snapshots__/highlighter-x-t9.test.js.snap b/test/e2e-tests/specs/__snapshots__/highlighter-x-t9.test.js.snap new file mode 100644 index 000000000..c7576e9db --- /dev/null +++ b/test/e2e-tests/specs/__snapshots__/highlighter-x-t9.test.js.snap @@ -0,0 +1,7 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`x-t9 Highlighter x-t9 Highlighter 1`] = ` +" +

1

+" +`; diff --git a/test/e2e-tests/specs/highlighter-lightning.test.js b/test/e2e-tests/specs/highlighter-lightning.test.js new file mode 100644 index 000000000..4dc980ebf --- /dev/null +++ b/test/e2e-tests/specs/highlighter-lightning.test.js @@ -0,0 +1,66 @@ +/** + * WordPress dependencies + */ + import { + pressKeyWithModifier, + createNewPost, + clickBlockAppender, + clickBlockToolbarButton, + getEditedPostContent, + activateTheme, + installTheme, +} from '@wordpress/e2e-test-utils'; + +/** + * Internal dependencies + */ + import { changeSiteLang } from '../helper/changeSiteLang'; + +describe( 'Lightning Highlighter', () => { + let oldLanguage; + beforeAll( async () => { + await installTheme( 'lightning' ); + await activateTheme( 'lightning' ); + } ); + beforeEach( async () => { + oldLanguage = await changeSiteLang( 'en' ); + await createNewPost(); + } ); + afterEach( async () => { + await changeSiteLang( oldLanguage ); + }); + afterAll( async () => { + await activateTheme( 'twentytwentytwo' ); + } ); + + it( 'Lightning Highlighter', async () => { + /** + * 新しく投稿を作る + */ + await createNewPost(); + + await clickBlockAppender(); + + // Add text and select to color. + await page.keyboard.type( '1' ); + await pressKeyWithModifier( 'primary', 'a' ); + await clickBlockToolbarButton( 'More' ); + + const button = await page.waitForXPath( + `//button[text()='Highlighter']` + ); + // Clicks may fail if the button is out of view. Assure it is before click. + await button.evaluate( ( element ) => element.scrollIntoView() ); + await button.click(); + + const option = await page.waitForSelector( + '[aria-label="Color: Black"]' + ); + + await option.click(); + + expect( await getEditedPostContent() ).toMatchSnapshot(); + + } ) + +}); diff --git a/test/e2e-tests/specs/highlighter-x-t9.test.js b/test/e2e-tests/specs/highlighter-x-t9.test.js new file mode 100644 index 000000000..f21d6a88a --- /dev/null +++ b/test/e2e-tests/specs/highlighter-x-t9.test.js @@ -0,0 +1,66 @@ +/** + * WordPress dependencies + */ + import { + pressKeyWithModifier, + createNewPost, + clickBlockAppender, + clickBlockToolbarButton, + getEditedPostContent, + activateTheme, + installTheme, +} from '@wordpress/e2e-test-utils'; + +/** + * Internal dependencies + */ + import { changeSiteLang } from '../helper/changeSiteLang'; + +describe( 'x-t9 Highlighter', () => { + let oldLanguage; + beforeAll( async () => { + await installTheme( 'x-t9' ); + await activateTheme( 'x-t9' ); + } ); + beforeEach( async () => { + oldLanguage = await changeSiteLang( 'en' ); + await createNewPost(); + } ); + afterEach( async () => { + await changeSiteLang( oldLanguage ); + }); + afterAll( async () => { + await activateTheme( 'twentytwentytwo' ); + } ); + + it( 'x-t9 Highlighter', async () => { + /** + * 新しく投稿を作る + */ + await createNewPost(); + + await clickBlockAppender(); + + // Add text and select to color. + await page.keyboard.type( '1' ); + await pressKeyWithModifier( 'primary', 'a' ); + await clickBlockToolbarButton( 'More' ); + + const button = await page.waitForXPath( + `//button[text()='Highlighter']` + ); + // Clicks may fail if the button is out of view. Assure it is before click. + await button.evaluate( ( element ) => element.scrollIntoView() ); + await button.click(); + + const option = await page.waitForSelector( + '[aria-label="Color: Text Secondary"]' + ); + + await option.click(); + + expect( await getEditedPostContent() ).toMatchSnapshot(); + + } ) + +}); From 8fff38e211d07c64d4fb90c218ef4a87d19de471 Mon Sep 17 00:00:00 2001 From: shimotmk Date: Fri, 5 Aug 2022 13:05:14 +0900 Subject: [PATCH 2/2] readme --- readme.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.txt b/readme.txt index 5be743c9a..5017b5e19 100644 --- a/readme.txt +++ b/readme.txt @@ -64,6 +64,8 @@ e.g. == Changelog == +[ Bug Fix ][ highlighter ] cope with color palette with alpha. + = 1.40.1 = [ Specification Change ][Step(Pro)/Timeline(Pro)] Change lineStyle ui. [ Bug Fix ][ hidden extension ] fix hidden extension class when Screen size xl.