2018-11-22 19:19:04 +01:00
|
|
|
let jwt;
|
|
|
|
const animDelay = Cypress.config('animDelay');
|
|
|
|
const frontLoadingDelay = Cypress.config('frontLoadingDelay');
|
|
|
|
const backendUrl = Cypress.config('backendUrl');
|
|
|
|
|
|
|
|
describe('Testing Content Manager ListPages', function() {
|
|
|
|
before(() => {
|
|
|
|
cy.login()
|
|
|
|
.then(data => {
|
|
|
|
jwt = data.jwt;
|
|
|
|
|
2019-05-29 16:54:47 +02:00
|
|
|
return cy.createCTMApis(data.jwt).then(() => jwt);
|
2018-11-22 19:19:04 +01:00
|
|
|
})
|
|
|
|
.then(jwt => {
|
|
|
|
cy.seedData('product', jwt);
|
|
|
|
})
|
|
|
|
.wait(1000);
|
|
|
|
});
|
2019-05-29 16:54:47 +02:00
|
|
|
|
2018-11-22 19:19:04 +01:00
|
|
|
after(() => {
|
|
|
|
cy.deleteAllModelData('product', jwt);
|
|
|
|
cy.deleteApi('tag', jwt)
|
|
|
|
.deleteApi('category', jwt)
|
|
|
|
.deleteApi('product', jwt);
|
|
|
|
});
|
|
|
|
|
|
|
|
context('Testing sorting options', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login()
|
2019-05-29 16:54:47 +02:00
|
|
|
.then(data => {
|
|
|
|
jwt = data.jwt;
|
|
|
|
})
|
|
|
|
.visit('/admin')
|
|
|
|
.wait(frontLoadingDelay);
|
2018-11-22 19:19:04 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should have the Id default sort', () => {
|
2019-05-29 16:54:47 +02:00
|
|
|
cy.get(
|
|
|
|
`a[href="/admin/plugins/content-manager/product?source=content-manager"]`
|
|
|
|
)
|
2018-11-22 19:19:04 +01:00
|
|
|
.click()
|
|
|
|
.wait(frontLoadingDelay);
|
|
|
|
|
|
|
|
cy.get('tr > th:nth-child(2) > span')
|
|
|
|
.children('i')
|
|
|
|
.should('be.visible')
|
|
|
|
.invoke('attr', 'class')
|
|
|
|
.should('includes', 'fa-sort-asc');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should change the default sort of product to name ASC then name DESC', () => {
|
|
|
|
cy.server();
|
2019-05-29 16:54:47 +02:00
|
|
|
cy.route(
|
|
|
|
`${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=_id:ASC&source=content-manager`
|
|
|
|
).as('getProduct');
|
|
|
|
cy.route(
|
|
|
|
`${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=name:ASC&source=content-manager`
|
|
|
|
).as('getSortByNameASC');
|
|
|
|
cy.route(
|
|
|
|
`${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=name:DESC&source=content-manager`
|
|
|
|
).as('getSortByNameDESC');
|
2018-11-22 19:19:04 +01:00
|
|
|
|
2019-05-29 16:54:47 +02:00
|
|
|
cy.get(
|
|
|
|
'a[href="/admin/plugins/content-manager/product?source=content-manager"]'
|
|
|
|
)
|
2018-11-22 19:19:04 +01:00
|
|
|
.click()
|
|
|
|
.wait('@getProduct')
|
2019-05-29 16:54:47 +02:00
|
|
|
.get('tr > th:nth-child(3) > span')
|
|
|
|
.as('getName')
|
2018-11-22 19:19:04 +01:00
|
|
|
.click();
|
|
|
|
|
|
|
|
cy.wait('@getSortByNameASC')
|
|
|
|
.get('@getName')
|
|
|
|
.children('i')
|
|
|
|
.should('be.visible')
|
|
|
|
.invoke('attr', 'class')
|
|
|
|
.should('includes', 'iconAsc')
|
2019-05-29 16:54:47 +02:00
|
|
|
.get('tbody > tr:nth-child(1) > td:nth-child(3)')
|
|
|
|
.as('firstResult')
|
2018-11-22 19:19:04 +01:00
|
|
|
.should('have.text', 'name');
|
|
|
|
|
|
|
|
cy.get('@getName')
|
|
|
|
.click()
|
|
|
|
.wait('@getSortByNameDESC')
|
|
|
|
.get('@getName')
|
|
|
|
.children('i')
|
|
|
|
.should('be.visible')
|
|
|
|
.invoke('attr', 'class')
|
|
|
|
.should('includes', 'iconDesc')
|
|
|
|
.get('@firstResult')
|
|
|
|
.should('have.text', 'name1');
|
|
|
|
});
|
|
|
|
|
|
|
|
it('Should set the product default sort to name', () => {
|
|
|
|
cy.get('a[href="/admin/plugins/content-manager/ctm-configurations"]')
|
|
|
|
.click()
|
|
|
|
.get('#product')
|
|
|
|
.click()
|
2019-05-29 16:54:47 +02:00
|
|
|
.get('select[name="product.defaultSort"]')
|
|
|
|
.as('defaultSort')
|
2018-11-22 19:19:04 +01:00
|
|
|
.select('name')
|
|
|
|
.should('have.value', 'name')
|
2019-05-29 16:54:47 +02:00
|
|
|
.get('select[name="product.sort"]')
|
|
|
|
.as('sortOption')
|
2018-11-22 19:19:04 +01:00
|
|
|
.select('DESC')
|
|
|
|
.should('have.value', 'DESC')
|
|
|
|
.submitForm()
|
|
|
|
.get('#ctaConfirm')
|
|
|
|
.click()
|
|
|
|
.wait(frontLoadingDelay)
|
2019-05-29 16:54:47 +02:00
|
|
|
.get(
|
|
|
|
'a[href="/admin/plugins/content-manager/product?source=content-manager"]'
|
|
|
|
)
|
2018-11-22 19:19:04 +01:00
|
|
|
.click()
|
|
|
|
.wait(frontLoadingDelay)
|
2019-05-29 16:54:47 +02:00
|
|
|
.get('tr > th:nth-child(3) > span')
|
|
|
|
.as('getName')
|
2018-11-22 19:19:04 +01:00
|
|
|
.children('i')
|
|
|
|
.invoke('attr', 'class')
|
|
|
|
.should('includes', 'iconDesc')
|
|
|
|
.get('tbody > tr:nth-child(1) > td:nth-child(3)')
|
|
|
|
.should('have.text', 'name1');
|
2019-05-29 16:54:47 +02:00
|
|
|
|
2018-11-22 19:19:04 +01:00
|
|
|
// Set it back to normal
|
|
|
|
cy.get('a[href="/admin/plugins/content-manager/ctm-configurations"]')
|
|
|
|
.click()
|
|
|
|
.get('#product')
|
|
|
|
.click()
|
|
|
|
.get('@defaultSort')
|
|
|
|
.select('_id')
|
|
|
|
.should('have.value', '_id')
|
|
|
|
.get('@sortOption')
|
|
|
|
.select('ASC')
|
|
|
|
.should('have.value', 'ASC')
|
|
|
|
.submitForm()
|
|
|
|
.get('#ctaConfirm')
|
|
|
|
.click()
|
|
|
|
.wait(frontLoadingDelay)
|
2019-05-29 16:54:47 +02:00
|
|
|
.get(
|
|
|
|
'a[href="/admin/plugins/content-manager/product?source=content-manager"]'
|
|
|
|
)
|
2018-11-22 19:19:04 +01:00
|
|
|
.click()
|
|
|
|
.wait(frontLoadingDelay)
|
|
|
|
.get('tr > th:nth-child(2) > span')
|
|
|
|
.children('i')
|
|
|
|
.invoke('attr', 'class')
|
|
|
|
.should('includes', 'iconAsc');
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
context('Testing filters', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
cy.login()
|
2019-05-29 16:54:47 +02:00
|
|
|
.then(data => {
|
|
|
|
jwt = data.jwt;
|
|
|
|
})
|
|
|
|
.visit('/admin')
|
|
|
|
.wait(frontLoadingDelay);
|
2018-11-22 19:19:04 +01:00
|
|
|
});
|
|
|
|
|
|
|
|
it('Should apply filters for product data', () => {
|
2019-05-29 16:54:47 +02:00
|
|
|
cy.get(
|
|
|
|
`a[href="/admin/plugins/content-manager/product?source=content-manager"]`
|
|
|
|
)
|
2018-11-22 19:19:04 +01:00
|
|
|
.click()
|
|
|
|
.wait(frontLoadingDelay);
|
2019-05-29 16:54:47 +02:00
|
|
|
cy.get('button#addFilterCTA')
|
|
|
|
.as('toggleFilter')
|
2018-11-22 19:19:04 +01:00
|
|
|
.click()
|
|
|
|
.wait(animDelay)
|
2019-05-29 16:54:47 +02:00
|
|
|
.get('div#filterPickWrapper')
|
|
|
|
.as('filterWrapper')
|
2018-11-22 19:19:04 +01:00
|
|
|
.children('div')
|
|
|
|
.should('have.length', 1);
|
2019-05-29 16:54:47 +02:00
|
|
|
|
|
|
|
cy.get('input[name="0.value"]')
|
2018-11-22 19:19:04 +01:00
|
|
|
.type('name')
|
|
|
|
.get('button#newFilter')
|
|
|
|
.click()
|
2019-05-29 16:54:47 +02:00
|
|
|
.get('select[name="1.attr"]')
|
2018-11-22 19:19:04 +01:00
|
|
|
.select('bool')
|
2019-05-29 16:54:47 +02:00
|
|
|
.get(
|
|
|
|
'button[label="content-manager.components.FiltersPickWrapper.PluginHeader.actions.apply"]'
|
|
|
|
)
|
2018-11-22 19:19:04 +01:00
|
|
|
.click()
|
|
|
|
.wait(animDelay)
|
|
|
|
.get('tbody > tr')
|
|
|
|
.should('have.length', 1);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|