Skip to content

Commit

Permalink
Merge pull request #344 from JarvusInnovations/develop
Browse files Browse the repository at this point in the history
Release: v1.20.9
  • Loading branch information
themightychris authored Apr 10, 2022
2 parents c2ffa1c + 93e6877 commit 30ba832
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions cypress/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,50 @@ Cypress.Commands.add('withExt', () => {
});
});

Cypress.Commands.add('extGet', { prevSubject: 'optional' }, (subject, query, opts={ all: false } ) => {
const extGet = (subject, query) => cy.wrap(new Cypress.Promise((resolve) => {
if (typeof subject != 'undefined') {
expect(subject).to.be.an('object').and.have.property('query');
const allResults = subject.query(query);
const result = opts.all ? allResults : allResults[0] || null;

Cypress.log({
name: 'extGet',
message: `${subject.id}.${query}`,
consoleProps: () => ({
Scope: subject,
Result: result,
'All Results': allResults
})
});

resolve(result);
} else {
cy.window({ log: false }).then(win => {
const allResults = win.Ext.ComponentQuery.query(query);
const result = opts.all ? allResults : allResults[0] || null;

Cypress.log({
name: 'extGet',
message: query,
consoleProps: () => ({
Result: result,
'All Results': allResults
})
});

resolve(result);
});
}
}), { log: false });

const resolve = () => {
extGet(subject, query).then(result => cy.verifyUpcomingAssertions(result, opts, { onRetry: resolve }))
}

return resolve();
});

// private method
function _buildHabExec(pkg, pkgCmd, pkgArgs) {
const studioContainer = Cypress.env('STUDIO_CONTAINER') || null;
Expand Down

0 comments on commit 30ba832

Please sign in to comment.