Skip to content
Draft
Show file tree
Hide file tree
Changes from all 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
17 changes: 16 additions & 1 deletion .github/workflows/cypress.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,25 @@ jobs:
version: 'WordPress/WordPress#master',
number: 'trunk',
}
- {
name: 'WP 7.0',
version: 'WordPress/WordPress#7.0-branch',
number: '7.0',
}
- {
name: 'WP 6.9',
version: 'WordPress/WordPress#6.9-branch',
number: '6.9',
}
- {
name: 'WP 6.8',
version: 'WordPress/WordPress#6.8-branch',
number: '6.8',
}
- {
name: 'WP 6.7',
version: 'WordPress/WordPress#6.7-branch',
number: '6.7'
number: '6.7',
}
- {
name: 'WP 6.6',
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
tests/cypress/screenshots
tests/cypress/videos
tests/cypress/reports
tests/cypress/downloads

# wp-env files
.wp-env.override.json
Expand Down
2 changes: 1 addition & 1 deletion run-all-cores.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

MAJOR_VERSIONS="5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7"
MAJOR_VERSIONS="5.7 5.8 5.9 6.0 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0"
TRUNK="master:trunk"

VERSIONS=""
Expand Down
2 changes: 1 addition & 1 deletion src/commands/close-welcome-guide.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const closeWelcomeGuide = (): void => {
'.edit-post-welcome-guide .components-modal__header button';

// Wait for edit page to load
cy.getBlockEditor().find(titleInput).should('exist');
cy.getBlockEditor().find(titleInput, { timeout: 10000 }).should('exist');

cy.get('body').then($body => {
if ($body.find(closeButtonSelector).length > 0) {
Expand Down
79 changes: 45 additions & 34 deletions src/commands/insert-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,47 +74,58 @@ export const insertBlock = (type: string, name?: string): void => {
// End of Block search logic.

blockNames.forEach(blockName => {
const blockSelector = `.editor-block-list-item-${
'core' === namespace ? '' : namespace + '-'
}${blockName}`;
const blockSelectors = [
`.editor-block-list-item-${
'core' === namespace ? '' : namespace + '-'
}${blockName}`,
`.editor-block-list-item-${
'core' === namespace ? '' : namespace + '-'
}${blockName}\\/${blockName}`, // Briefly in 6.9 for default variants.
];

const blockSelector = blockSelectors.join(',');

console.log(blockName, blockSelector);

cy.get('body').then($body => {
if ($body.find(blockSelector).length) {
// Start of Block insertion by click logic.
cy.get(blockSelector).then($block => {
if ($block.length) {
cy.wrap($block).click();
inserterBtn.click();
cy.get(blockSelector)
.first()
.then($block => {
if ($block.length) {
cy.wrap($block).click();
inserterBtn.click();

const [ns, rest] = type.split('/'); // namespace = ns, second namespace or block name = rest
const [ns, rest] = type.split('/'); // namespace = ns, second namespace or block name = rest

cy.get('body').then($body => {
if ($body.find('iframe[name="editor-canvas"]').length) {
// Works with WP 6.4
getIframe('iframe[name="editor-canvas"]').then($iframe => {
const blockInIframe = $iframe.find(
`.wp-block[data-type="${ns}/${rest}"]`
cy.get('body').then($body => {
if ($body.find('iframe[name="editor-canvas"]').length) {
// Works with WP 6.4
getIframe('iframe[name="editor-canvas"]').then($iframe => {
const blockInIframe = $iframe.find(
`.wp-block[data-type="${ns}/${rest}"]`
);
if (blockInIframe.length > 0) {
cy.wrap(blockInIframe.last().prop('id'));
}
});
} else if (
$body.find(`.wp-block[data-type="${ns}/${rest}"]`).length
) {
// Works with WP 5.7
cy.get(`.wp-block[data-type="${ns}/${rest}"]`).then(
$blockInEditor => {
expect($blockInEditor.length).to.equal(1);
cy.wrap($blockInEditor.prop('id'));
}
);
if (blockInIframe.length > 0) {
cy.wrap(blockInIframe.last().prop('id'));
}
});
} else if (
$body.find(`.wp-block[data-type="${ns}/${rest}"]`).length
) {
// Works with WP 5.7
cy.get(`.wp-block[data-type="${ns}/${rest}"]`).then(
$blockInEditor => {
expect($blockInEditor.length).to.equal(1);
cy.wrap($blockInEditor.prop('id'));
}
);
} else {
throw new Error(`${ns}/${rest} not found.`);
}
});
}
});
} else {
throw new Error(`${ns}/${rest} not found.`);
}
});
}
});
// End of Block insertion by click logic.
}
});
Expand Down
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ declare global {
}
}

// Ignore promises rejected due to missed transitions.
// These are common on CI environments due to the speed of the tests and the environment.
Cypress.on('uncaught:exception', err => {
if (
err?.name === 'AbortError' &&
err?.message?.includes('Transition was skipped')
) {
return false;
}
});

// Register commands
Cypress.Commands.add('checkPostExists', checkPostExists);
Cypress.Commands.add('classicCreatePost', classicCreatePost);
Expand Down
5 changes: 3 additions & 2 deletions tests/cypress/e2e/insert-block.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ describe('Command: insertBlock', () => {

it('Should be able to insert custom block', () => {
if (
'trunk' !== Cypress.env('WORDPRESS_CORE').toString() &&
compare(Cypress.env('WORDPRESS_CORE').toString(), '6.1', '<')
!Cypress.env('WORDPRESS_CORE') ||
('trunk' !== Cypress.env('WORDPRESS_CORE').toString() &&
compare(Cypress.env('WORDPRESS_CORE').toString(), '6.1', '<'))
) {
// WinAmp block does not support this version of WordPress.
assert(true, 'Skipping test, WinAmp block does not exist');
Expand Down
Loading