Skip to content

Commit

Permalink
Overwrite wpCliEval as the path is always elasticpress-labs
Browse files Browse the repository at this point in the history
  • Loading branch information
felipeelia committed Jan 14, 2025
1 parent f8964e7 commit e7bace5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/cypress/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
logs
videos
16 changes: 16 additions & 0 deletions tests/cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,19 @@ Cypress.Commands.add('clearThenType', { prevSubject: true }, (subject, text, for
cy.wrap(subject).clear();
cy.wrap(subject).type(text, { force });
});

Cypress.Commands.add('wpCliEval', (command) => {
const fileName = (Math.random() + 1).toString(36).substring(7);

// this will be written "local" plugin directory
const escapedCommand = command.replace(/^<\?php /, '');
cy.writeFile(fileName, `<?php ${escapedCommand}`);

// which is read from it's proper location in the plugins directory
cy.exec(
`./bin/wp-env-cli tests-wordpress "wp --allow-root eval-file wp-content/plugins/elasticpress-labs/${fileName}"`,
).then((result) => {
cy.exec(`rm ${fileName}`);
cy.wrap(result);
});
});

0 comments on commit e7bace5

Please sign in to comment.