Skip to content

Commit

Permalink
Merge branch 'develop' into fix/layout-preview-modal
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerardo Pacheco committed Apr 7, 2020
2 parents 111e79d + 7898f98 commit eff00be
Show file tree
Hide file tree
Showing 51 changed files with 3,861 additions and 3,660 deletions.
5 changes: 3 additions & 2 deletions RELEASE-NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
1.25.0
------
* New block: Cover
* Improve icon on the "Take a Video" media option
* [Android] Dark Mode
* [Android] Improve icon on the "Take a Video" media option
* Removed the dimming effect on unselected blocks
* Enabled edit button over image block for Android
* [iOS] Add alignment options for heading block
* Implemented dropdown toolbar for alignment toolbar in Heading, Paragraph, Image, MediaText blocks
* Block Editor: When editing link settings, tapping the keyboard return button now closes the settings panel as well as closing the keyboard.
* [Android] Show an "Edit" button overlay on selected image blocks

1.24.0
------
Expand Down
56 changes: 56 additions & 0 deletions __device-tests__/gutenberg-editor-latest-posts.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* @format
* */

/**
* Internal dependencies
*/
import EditorPage from './pages/editor-page';
import {
setupDriver,
isLocalEnvironment,
stopDriver,
} from './helpers/utils';

jasmine.DEFAULT_TIMEOUT_INTERVAL = 1000000;

describe( 'Gutenberg Editor Latest Post Block tests', () => {
let driver;
let editorPage;
let allPassed = true;

// Use reporter for setting status for saucelabs Job
if ( ! isLocalEnvironment() ) {
const reporter = {
specDone: async ( result ) => {
allPassed = allPassed && result.status !== 'failed';
},
};

jasmine.getEnv().addReporter( reporter );
}

beforeAll( async () => {
driver = await setupDriver();
editorPage = new EditorPage( driver );
} );

it( 'should be able to see visual editor', async () => {
await expect( editorPage.getBlockList() ).resolves.toBe( true );
} );

it( 'should be able to add a Latests-Posts block', async () => {
await editorPage.addNewLatestPostsBlock();
const latestPostsBlock = await editorPage.getLatestPostsBlockAtPosition( 1 );

expect( latestPostsBlock ).toBeTruthy();
await editorPage.removeLatestPostsBlockAtPosition( 1 );
} );

afterAll( async () => {
if ( ! isLocalEnvironment() ) {
driver.sauceJobStatus( allPassed );
}
await stopDriver( driver );
} );
} );
36 changes: 35 additions & 1 deletion __device-tests__/pages/editor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export default class EditorPage {
headingBlockName = 'Heading';
imageBlockName = 'Image';
galleryBlockName = 'Gallery';
latestPostsBlockName = 'Latest Posts';
unorderedListButtonName = 'Convert to unordered list';
orderedListButtonName = 'Convert to ordered list';

Expand Down Expand Up @@ -161,10 +162,27 @@ export default class EditorPage {
await addButton.click();

// Click on block of choice
const blockButton = await this.driver.elementByAccessibilityId( blockName );
const blockButton = await this.findBlockButton( blockName );
await blockButton.click();
}

// Attempts to find the given block button in the block inserter control.
async findBlockButton( blockName: string ) {
// If running on iOS returns the result of the look up as no scrolling is necessary for offscreen items.
if ( ! isAndroid() ) {
return await this.driver.elementByAccessibilityId( blockName );
}

// Checks if the Block Button is available, and if not will scroll to the second half of the available buttons.
if ( ! await this.driver.hasElementByAccessibilityId( blockName ) ) {
for ( let step = 0; step < 5; step++ ) {
await this.driver.pressKeycode( 20 ); // Press the Down arrow to force a scroll.
}
}

return await this.driver.elementByAccessibilityId( blockName );
}

async clickToolBarButton( buttonName: string ) {
const toolBarButton = await this.driver.elementByAccessibilityId( buttonName );
await toolBarButton.click();
Expand Down Expand Up @@ -432,4 +450,20 @@ export default class EditorPage {
const text = await textViewElement.text();
return text.toString();
}

// ============================
// Latest-Posts Block functions
// ============================

async addNewLatestPostsBlock() {
await this.addNewBlock( this.latestPostsBlockName );
}

async getLatestPostsBlockAtPosition( position: number ) {
return this.getBlockAtPosition( position, this.latestPostsBlockName );
}

async removeLatestPostsBlockAtPosition( position: number ) {
return await this.removeBlockAtPosition( position, this.latestPostsBlockName );
}
}
11 changes: 10 additions & 1 deletion android/app/src/main/java/com/gutenberg/MainApplication.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.gutenberg;

import android.app.Application;
import android.content.res.Configuration;
import android.os.Bundle;
import android.util.Log;

Expand Down Expand Up @@ -126,7 +127,8 @@ public void editorDidEmitLog(String message, LogLevel logLevel) {

@Override
public void performRequest(String path, Consumer<String> onSuccess, Consumer<Bundle> onError) {}
});

}, isDarkMode());

return new ReactNativeHost(this) {
@Override
Expand All @@ -153,6 +155,13 @@ protected String getJSMainModuleName() {
};
}

private boolean isDarkMode() {
Configuration configuration = getResources().getConfiguration();
int currentNightMode = configuration.uiMode & Configuration.UI_MODE_NIGHT_MASK;

return currentNightMode == Configuration.UI_MODE_NIGHT_YES;
}

@Override
public ReactNativeHost getReactNativeHost() {
if (mReactNativeHost == null) {
Expand Down
19 changes: 17 additions & 2 deletions bin/po2android.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,21 @@ function escapeResourceXML( unsafeXMLValue ) {
} );
}

/**
* Android specifics replacements.
*
* @param {string} XMLValue input to apply replacements.
* @return {string} valid string passing Android linter rules.
*/
function androidReplacements( XMLValue ) {
return XMLValue.replace( /(-|\.\.\.)/gm, function( character ) {
switch ( character ) {
case '-': return '–'; // Android lint rule: TypographyDashes.
case '...': return '…'; // Android lint rule: TypographyEllipsis
}
} );
}

/**
* Generate a unique string identifier to use as the `name` property in our xml.
* Try using the string first by stripping any non-alphanumeric characters and cropping it
Expand Down Expand Up @@ -74,8 +89,8 @@ function po2Android( poInput ) {
return result;
}
const uniqueName = getUniqueName( translation.msgid );
const escapedValue = escapeResourceXML( translation.msgid );
const escapedValuePlural = escapeResourceXML( translation.msgid_plural || '' );
const escapedValue = androidReplacements( escapeResourceXML( translation.msgid ) );
const escapedValuePlural = androidReplacements( escapeResourceXML( translation.msgid_plural || '' ) );
const comment = translation.comments.extracted || '';
let localizedEntry = '';
if ( comment ) {
Expand Down
Loading

0 comments on commit eff00be

Please sign in to comment.