Skip to content

Commit

Permalink
Add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
burhandodhy committed Jun 29, 2022
1 parent 038e179 commit feb2661
Showing 1 changed file with 52 additions and 3 deletions.
55 changes: 52 additions & 3 deletions tests/cypress/integration/features/custom-results.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
describe('Custom Results', () => {
it('Can create Custom Results and verify the result on search', () => {
after(() => {
cy.login();
cy.visitAdminPage('edit.php?post_type=ep-pointer');
cy.get('#cb-select-all-1').click();
cy.get('#bulk-action-selector-top').select('trash');
cy.get('#doaction').click();

cy.visitAdminPage('edit.php?post_status=trash&post_type=ep-pointer');
cy.get('.tablenav.top #delete_all').click();
});

it('Can change post position and verify the result on search', () => {
const searchResult = [];
const searchTerm = 'featured image';
const searchTerm = 'Feature';

cy.login();
cy.visitAdminPage('post-new.php?post_type=ep-pointer');
Expand Down Expand Up @@ -29,7 +40,45 @@ describe('Custom Results', () => {
// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);

cy.visit(`?s=${encodeURI(searchTerm)}`);
cy.visit(`?s=${searchTerm}`);

cy.get('article .entry-title').each((post, index) => {
cy.wrap(post).invoke('text').should('eq', searchResult[index]);
});
});

it('Can add the post in result and verify the result on search', () => {
const searchResult = [];
const searchTerm = 'Fantastic';

cy.login();

cy.activatePlugin('woocommerce');
cy.maybeEnableFeature('woocommerce');

cy.visitAdminPage('post-new.php?post_type=ep-pointer');
cy.intercept('GET', 'wp-json/elasticpress/v1/pointer_preview*').as('ajaxRequest');

cy.get('#titlewrap input').type(searchTerm);
cy.wait('@ajaxRequest').its('response.statusCode').should('eq', 200);

cy.intercept('GET', 'wp-json/elasticpress/v1/pointer_search*').as('ajaxRequest');
cy.get('.search-pointers').type('Small Aluminum Wallet');
cy.wait('@ajaxRequest').its('response.statusCode').should('eq', 200);

cy.get('.dashicons-plus.add-pointer').click();
cy.get('.pointers .pointer .title').each((post) => {
cy.wrap(post)
.invoke('text')
.then((text) => searchResult.push(text));
});

cy.get('#publish').click();

// eslint-disable-next-line cypress/no-unnecessary-waiting
cy.wait(2000);

cy.visit(`?s=${searchTerm}`);

cy.get('article .entry-title').each((post, index) => {
cy.wrap(post).invoke('text').should('eq', searchResult[index]);
Expand Down

0 comments on commit feb2661

Please sign in to comment.