Skip to content
This repository was archived by the owner on Sep 8, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/features/revieweditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ export default class ReviewEditor extends Editor {
}

static run() {
return this.createEditor( 'div.pull-request-review-menu > form' );
return this.createEditor( 'div.SelectMenu-list > form.color-bg-primary' );
}
}
16 changes: 13 additions & 3 deletions tests/_pom/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,18 @@ class Editor {
* @return {Promise<GitHubPage>} The current page.
*/
async submit() {
const selector = `[data-github-writer-id="${ this.id }"] .btn-primary`;
await this.page.browserPage.click( selector );
const selector = `[data-github-writer-id="${ this.id }"] .btn-primary[type="submit"]`;
const matchedElementHandles = await this.page.browserPage.$$( selector );

// On the `newIssue` page there are 2 submit buttons available. Filtering the one visible is needed, as they're
// positioned differently, depending on the browser window size (devtools on/off).
if ( matchedElementHandles.length > 1 ) {
await matchedElementHandles.filter( handle => {
return handle.boundingBox() ? handle.click() : ''; } );
} else {
await matchedElementHandles[ 0 ].click();
}

return this.page;
}

Expand Down Expand Up @@ -255,7 +265,7 @@ class NewLineCommentEditor extends Editor {
.nextElementSibling
.querySelector( '.js-comments-holder' );

const count = container.querySelectorAll( '.review-comment-contents.js-suggested-changes-contents' ).length;
const count = container.querySelectorAll( '.js-pending-review-comment .js-suggested-changes-contents' ).length;

return count === expectedCount;
}, {}, this.line, commentsCount + 1 );
Expand Down
20 changes: 14 additions & 6 deletions tests/_pom/pages/commentstimelinepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,20 @@ class CommentsTimelinePage extends GitHubPage {
*/
async editComment( index ) {
const root = ( await this.browserPage.$$( 'form.js-comment-update' ) )[ index ];
const editButton = await root.evaluateHandle( root =>
root.closest( '.timeline-comment' ).querySelector( '.js-comment-edit-button' ) );
const actionButton = await editButton.evaluateHandle( editButton =>
editButton.closest( 'details-menu' ).previousElementSibling );

const actionButton = await root.evaluateHandle( root =>
root.closest( '.timeline-comment' ).querySelector( '.show-more-popover' )
.parentElement.querySelector( 'summary[role=button]' ) );

actionButton.hover();
await this.browserPage.waitFor( 2000 );
Comment thread
mateuszzagorski marked this conversation as resolved.
Outdated

await actionButton.click();
await this.hasElement( '.js-comment-edit-button' );

const editButton = await actionButton.evaluateHandle( actionButton =>
actionButton.parentElement.querySelector( '.dropdown-menu' ).querySelector( '.js-comment-edit-button' ) );

await this.waitVisible( editButton );
await editButton.click();
await this.waitVisible( root );
Expand All @@ -49,11 +57,11 @@ class CommentsTimelinePage extends GitHubPage {
async getCommentHtml( index ) {
// Wait for the comment to be available.
await this.browserPage.waitForFunction( function getCommentHtmlWait( index ) {
return !!document.querySelectorAll( '.timeline-comment.comment td.comment-body' )[ index ];
return !!document.querySelectorAll( '.timeline-comment.comment .js-comment-body' )[ index ];
}, {}, index );

return await this.browserPage.evaluate( function getCommentHtmlEval( index ) {
const element = document.querySelectorAll( '.timeline-comment.comment td.comment-body' )[ index ];
const element = document.querySelectorAll( '.timeline-comment.comment .js-comment-body' )[ index ];
return element.innerHTML.replace( /^\s+|\s+$/g, '' );
}, index );
}
Expand Down
2 changes: 1 addition & 1 deletion tests/_pom/pages/issuepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class IssuePage extends CommentsTimelinePage {
* @return {Promise<GitHubPage>} The page loaded after the issue is deleted (`/issues`);
*/
async deleteIssue() {
await this.browserPage.click( '.discussion-sidebar-item svg.octicon-trashcan' );
await this.browserPage.click( '.discussion-sidebar-item svg.octicon-trash' );
await this.waitForNavigation( this.browserPage.click( 'button[name="verify_delete"]' ) );

return await GitHubPage.getCurrentPage();
Expand Down
6 changes: 3 additions & 3 deletions tests/_pom/pages/pullrequestpage.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class PullRequestPage extends CommentsTimelinePage {

await this.browserPage.click( '.js-reviews-toggle' );

return await this.getEditorByRoot( 'div.pull-request-review-menu > form', MainEditor );
return await this.getEditorByRoot( 'div.SelectMenu-list form.color-bg-primary', MainEditor );
}

/**
Expand Down Expand Up @@ -115,7 +115,7 @@ class PullRequestPage extends CommentsTimelinePage {
container = container && container.querySelector( '.js-comments-holder' );

return !!container && !!container.querySelectorAll(
'.review-comment-contents.js-suggested-changes-contents' )[ index ];
'.js-pending-review-comment .js-suggested-changes-contents' )[ index ];
}, {}, position, index );

return await this.browserPage.evaluate( function getLineCommentHtmlEval( position, index ) {
Expand All @@ -127,7 +127,7 @@ class PullRequestPage extends CommentsTimelinePage {
.querySelector( '.js-comments-holder' );

const element = container.querySelectorAll(
'.review-comment-contents.js-suggested-changes-contents .js-comment-body' )[ index ];
'.js-pending-review-comment .js-suggested-changes-contents .js-comment-body' )[ index ];
return element.innerHTML.replace( /^\s+|\s+$/g, '' );
}, position, index );
}
Expand Down
8 changes: 3 additions & 5 deletions tests/_pom/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ const util = {
* - [Enter]
* - [Ctrl+ArrowRight]
* - [Ctrl+Shift+Alt+Z]
* - [CtrlCmd+Space]
*
* The "CtrlCmd" modified sends the `command` (meta) key on mac and the `control` key in other OSs.
* By default "Ctrl" is used, and it is modified to equal `Control` or `Meta`, depending on the OS used.
*
* @param targetElement {ElementHandle} The element to receive the typing.
* @param texts {...String} The texts to be typed.
Expand All @@ -75,8 +74,7 @@ const util = {
modifiers = modifiers.map( key => key
.replace( /Shift/i, 'Shift' )
.replace( /Alt/i, 'Alt' )
.replace( /CtrlCmd/i, ctrlCmdKey )
.replace( /Ctrl/i, 'Control' )
.replace( /Ctrl/i, ctrlCmdKey )
);

for ( let i = 0; i < modifiers.length; i++ ) {
Expand All @@ -95,7 +93,7 @@ const util = {
}

async function getCtrlCmdKey() {
return await browserPage.evaluate( () => /Mac/i.test( navigator.platform ) ? 'Meta' : 'Control' );
return await browserPage.evaluate( () => /MacIntel/i.test( navigator.platform ) ? 'Meta' : 'Control' );
}
}
};
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/issue.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ describe( 'Issue', function() {
if ( page instanceof IssuePage ) {
await page.deleteIssue();
}
// Forcing wait so the page can fully load before PR tests start to run.
await page.browserPage.waitFor( 2000 );
} );

it( 'should create a new issue', async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/pullrequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe( 'Pull Request', function() {
} );

it( 'should create a new pull request', async () => {
page = await FileEditPage.getPage( 'master/README.md' );
page = await FileEditPage.getPage( 'main/README.md' );

const timestamp = ( new Date() ).toISOString();

Expand Down