Skip to content

Commit

Permalink
e2e test + tweak on the sync-error test plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Apr 23, 2024
1 parent 112f8ea commit 3d3f5ba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
8 changes: 8 additions & 0 deletions tests/cypress/integration/dashboard-sync.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,15 @@ describe('Dashboard Sync', () => {
cy.contains('button', 'Log').click();
cy.contains('button', 'Errors').click();
cy.contains('.ep-sync-errors', 'No errors found in the log.').should('exist');

/**
* Reload the page, so we can check if the Error Log tab is opened by default when an error occurs.
*/
cy.visitAdminPage('admin.php?page=elasticpress-sync');
cy.contains('button', 'Start sync').click();
cy.get('.ep-sync-errors__table', {
timeout: Cypress.config('elasticPressIndexTimeout'),
}).should('be.visible');
cy.get('.ep-sync-errors tr', { timeout: Cypress.config('elasticPressIndexTimeout') })
.contains('Limit of total fields [???] in index [???] has been exceeded')
.should('exist');
Expand Down
22 changes: 20 additions & 2 deletions tests/cypress/wordpress-files/test-plugins/sync-error.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@
* @package ElasticPress_Tests_E2e
*/

add_filter( 'ep_total_field_limit', fn() => 100 );
namespace ElasticPress\Tests\E2E\SyncError;

const META_COUNT = 100;

add_filter( 'ep_total_field_limit', fn() => META_COUNT );

add_filter(
'ep_prepare_meta_data',
function ( $post_meta, $post ) {
if ( 0 === $post->ID % 2 ) {
for ( $i = 0; $i < 100; $i++ ) {
for ( $i = 0; $i < META_COUNT; $i++ ) {
$post_meta[ "test_meta_{$i}_title_{$post->ID}" ] = 'Lorem';
$post_meta[ "test_meta_{$i}_body_{$post->ID}" ] = 'Ipsum';
}
Expand All @@ -25,3 +29,17 @@ function ( $post_meta, $post ) {
10,
2
);

add_filter(
'ep_prepare_meta_allowed_protected_keys',
function ( $allowed_meta, $post ) {
for ( $i = 0; $i < META_COUNT; $i++ ) {
$allowed_meta[] = "test_meta_{$i}_title_{$post->ID}";
$allowed_meta[] = "test_meta_{$i}_body_{$post->ID}";
}

return $allowed_meta;
},
10,
2
);

0 comments on commit 3d3f5ba

Please sign in to comment.