Skip to content

Commit

Permalink
Merge branch 'develop' into fix/wrapped-embeds-in-p-tags
Browse files Browse the repository at this point in the history
  • Loading branch information
thelovekesh committed Jul 7, 2023
2 parents c719d1c + 4d88938 commit 8b8042a
Show file tree
Hide file tree
Showing 15 changed files with 14,811 additions and 10,537 deletions.
57 changes: 40 additions & 17 deletions .github/workflows/build-test-measure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,36 @@ jobs:
repo-token: '${{ secrets.GITHUB_TOKEN }}'
report-json: 'lint-js-report.json'

#-----------------------------------------------------------------------------------------------------------------------

normalize-composer:
name: 'Normalize composer.json'
needs: pre-run
if: needs.pre-run.outputs.changed-php-count > 0 || needs.pre-run.outputs.changed-gha-workflow-count > 0
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'
coverage: none

- name: Get composer-normalize.phar
run: |
wget https://github.com/ergebnis/composer-normalize/releases/latest/download/composer-normalize.phar
chmod +x composer-normalize.phar
- name: Validate composer.json
run: composer --no-interaction validate --no-check-all

- name: Normalize composer.json
run: |
composer config --no-interaction --no-plugins allow-plugins.ergebnis/composer-normalize true
./composer-normalize.phar --dry-run
#-----------------------------------------------------------------------------------------------------------------------

lint-php:
Expand Down Expand Up @@ -189,18 +219,9 @@ jobs:
- name: Install Composer dependencies
run: composer install --prefer-dist --optimize-autoloader --no-progress --no-interaction

- name: Validate composer.json
run: composer --no-interaction validate --no-check-all

- name: Detect coding standard violations (PHPCS)
run: vendor/bin/phpcs -q --report=checkstyle --runtime-set ignore_errors_on_exit 1 --runtime-set ignore_warnings_on_exit 1 | cs2pr --graceful-warnings

- name: Normalize composer.json
run: |
composer config --no-interaction --no-plugins allow-plugins.ergebnis/composer-normalize true
composer require --no-interaction --dev ergebnis/composer-normalize --ignore-platform-reqs
composer --no-interaction normalize --dry-run
#-----------------------------------------------------------------------------------------------------------------------

static-analysis-php:
Expand Down Expand Up @@ -362,12 +383,13 @@ jobs:
mysql:
image: mariadb:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: wordpress_test
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
MARIADB_DATABASE: wordpress_test
MARIADB_MYSQL_LOCALHOST_USER: 1
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
continue-on-error: ${{ matrix.experimental == true }}
strategy:
fail-fast: false
Expand Down Expand Up @@ -606,12 +628,13 @@ jobs:
mysql:
image: mariadb:latest
env:
MYSQL_ALLOW_EMPTY_PASSWORD: true
MYSQL_ROOT_PASSWORD:
MYSQL_DATABASE: wordpress_test
MARIADB_ALLOW_EMPTY_ROOT_PASSWORD: true
MARIADB_DATABASE: wordpress_test
MARIADB_MYSQL_LOCALHOST_USER: 1
MARIADB_MYSQL_LOCALHOST_GRANTS: USAGE
ports:
- 3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
options: --health-cmd="healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=10s --health-timeout=5s --health-retries=3
continue-on-error: ${{ matrix.experimental == true }}
strategy:
fail-fast: false
Expand Down
4 changes: 2 additions & 2 deletions assets/src/components/nav-menu/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export function NavMenu({ links = [], onClick }) {
return (
<Selectable ElementName="nav" className="nav-menu">
<ul className="nav-menu__list">
{links.map((link) => (
<li key={link.url} className="nav-menu__item">
{links.map((link, index) => (
<li key={`${link.url}-${index}`} className="nav-menu__item">
<a
className={classnames('nav-menu__link', {
'nav-menu__link--active': link.isActive,
Expand Down
25 changes: 23 additions & 2 deletions assets/src/components/nav-menu/test/nav-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,24 @@ describe('NavMenu', () => {
const handler = jest.fn();

const { container } = render(
<NavMenu links={links} onClick={handler} />
// Pass empty URLs to avoid `Error: Not implemented: navigation (except hash changes)` in tests.
// This is due to the JSDOM limitation to not support navigation.
// Since we're not testing onClick event and not testing navigation, we can safely pass empty URLs.
<NavMenu
links={[
{
url: '',
label: 'Foo',
isActive: false,
},
{
url: '',
label: 'Bar',
isActive: true,
},
]}
onClick={handler}
/>
);

fireEvent.click(container.querySelector('a'));
Expand All @@ -69,6 +86,10 @@ describe('NavMenu', () => {

const [event, link] = handler.mock.calls[0];
expect(event.type).toBe('click');
expect(link).toBe(links[0]);
expect(link).toStrictEqual({
url: '',
label: 'Foo',
isActive: false,
});
});
});
3 changes: 2 additions & 1 deletion bin/ci/install-wp-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ install_db() {
fi

# create database
mysqladmin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS""$EXTRA"
mariadb-admin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA || \
mysqladmin create "$DB_NAME" --user="$DB_USER" --password="$DB_PASS"$EXTRA
}

install_wp
Expand Down
2 changes: 2 additions & 0 deletions includes/embeds/class-amp-core-block-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -569,6 +569,7 @@ private function process_text_widgets( Document $dom ) {
foreach ( $dom->xpath->query( '//div[ @class = "textwidget" ]' ) as $text_widget ) {
// Restore the width/height attributes which were preserved in preserve_widget_text_element_dimensions.
foreach ( $dom->xpath->query( sprintf( './/*[ @%s or @%s ]', self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME, self::AMP_PRESERVED_HEIGHT_ATTRIBUTE_NAME ), $text_widget ) as $element ) {
/** @var DOMElement $element */
if ( $element->hasAttribute( self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME ) ) {
$element->setAttribute( Attribute::WIDTH, $element->getAttribute( self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME ) );
$element->removeAttribute( self::AMP_PRESERVED_WIDTH_ATTRIBUTE_NAME );
Expand All @@ -586,6 +587,7 @@ private function process_text_widgets( Document $dom ) {
* responsive so this is built-in. Note also the style rule for .wp-video in amp-default.css.
*/
foreach ( $dom->xpath->query( './/div[ @class = "wp-video" and @style ]', $text_widget ) as $element ) {
/** @var DOMElement $element */
$element->removeAttribute( 'style' );
}
}
Expand Down
2 changes: 2 additions & 0 deletions includes/embeds/class-amp-tumblr-embed-handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ public function sanitize_raw_embeds( Document $dom ) {
);
$overflow_element->textContent = __( 'See more', 'amp' );
$amp_element->appendChild( $overflow_element );

/** @var DOMElement $placeholder */
$placeholder->setAttribute( Attribute::PLACEHOLDER, '' );
$amp_element->appendChild( $placeholder );

Expand Down
1 change: 1 addition & 0 deletions includes/sanitizers/class-amp-style-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,7 @@ public function sanitize() {
}
} else {
foreach ( $styled_elements as $element ) {
/** @var DOMElement $element */
$attr = $element->getAttributeNode( Attribute::STYLE );
if ( $attr && preg_match( '/!\s*important/i', $attr->value ) ) {
ValidationExemption::mark_node_as_px_verified( $attr );
Expand Down

0 comments on commit 8b8042a

Please sign in to comment.