tainacan/cypress/integration/repository/collection/item_spec.js

258 lines
14 KiB
JavaScript
Raw Normal View History

2018-04-10 19:38:27 +00:00
describe('Item tests', function () {
2018-04-02 19:16:37 +00:00
beforeEach(() => {
cy.loginByUI()
})
it('clear DB', function(){
cy.clearDB()
})
it('create collection for crud items', function(){
2018-04-02 19:16:37 +00:00
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
cy.get('#button-create-collection').click()
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections/new')
cy.get('#tainacan-text-name').type('Book Items')
cy.get('#tainacan-text-description').type('description book items')
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('.breadcrumbs > :nth-child(2) > .router-link-active').click()
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
cy.get('.b-table').should('contain', 'Book Items')
2018-04-02 19:16:37 +00:00
})
2018-04-10 19:38:27 +00:00
context('CRUD items', function(){
2018-04-02 19:16:37 +00:00
it('canceled create item', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item canceled')
cy.get('#tainacan-textarea-description').type('Item canceled description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-cancel-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('not.contain', 'Item canceled')
})
it('create item with status publish', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item publish')
cy.get('#tainacan-textarea-description').type('Item publish description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item publish')
})
it('create item with status private', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item private')
cy.get('#tainacan-textarea-description').type('Item private description')
cy.get('#status-select').select('Private').should('have.value', 'private')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item private')
})
it('create item with status draft', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item draft')
cy.get('#tainacan-textarea-description').type('Item draft description')
cy.get('#status-select').select('Draft').should('have.value', 'draft')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
2018-04-10 19:38:27 +00:00
cy.get('.b-table').should('not.contain', 'Item draft')
2018-04-02 19:16:37 +00:00
})
it('create item with status trash', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item trash')
cy.get('#tainacan-textarea-description').type('Item trash description')
cy.get('#status-select').select('Trash').should('have.value', 'trash')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
2018-04-10 19:38:27 +00:00
cy.get('.b-table').should('not.contain', 'Item trash')
2018-04-02 19:16:37 +00:00
})
it('delete item', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item delete')
cy.get('#tainacan-textarea-description').type('Item delete description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item delete')
cy.get(':nth-child(1) > [data-label="Actions"] > :nth-child(1) > #button-delete > .icon > .mdi').click()
cy.get('.modal-card').should('have.class', 'animation-content')
cy.get('.is-primary').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('not.contain', 'Item delete')
})
})
context('Create many collections for verify persistence the datas', function(){
it('create many items', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 1')
cy.get('#tainacan-textarea-description').type('Item 1 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 1')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 2')
cy.get('#tainacan-textarea-description').type('Item 2 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 2')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 3')
cy.get('#tainacan-textarea-description').type('Item 3 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 3')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 4')
cy.get('#tainacan-textarea-description').type('Item 4 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 4')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 5')
cy.get('#tainacan-textarea-description').type('Item 5 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 5')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 6')
cy.get('#tainacan-textarea-description').type('Item 6 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 6')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 7')
cy.get('#tainacan-textarea-description').type('Item 7 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 7')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 8')
cy.get('#tainacan-textarea-description').type('Item 8 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 8')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 9')
cy.get('#tainacan-textarea-description').type('Item 9 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 9')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 10')
cy.get('#tainacan-textarea-description').type('Item 10 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 10')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 11')
cy.get('#tainacan-textarea-description').type('Item 11 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 11')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 12')
cy.get('#tainacan-textarea-description').type('Item 12 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 12')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 13')
cy.get('#tainacan-textarea-description').type('Item 13 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 13')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 14')
cy.get('#tainacan-textarea-description').type('Item 14 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 14')
cy.get('#button-create-item').click()
2018-04-02 19:16:37 +00:00
cy.get('#tainacan-text-title').type('Item 15')
cy.get('#tainacan-textarea-description').type('Item 15 description')
cy.get('#status-select').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-item-creation').click()
cy.get('.breadcrumbs > :nth-child(3) > .router-link-active').click()
cy.get('.b-table').should('contain', 'Item 15')
})
})
context('Check all items', function(){
it('check if collections are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
2018-04-10 19:38:27 +00:00
cy.location('hash').should('eq', '#/collections')
2018-04-02 19:16:37 +00:00
cy.get('[data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
2018-04-10 19:38:27 +00:00
cy.get('.field-body > .field > .control > .select > select').select('24').should('have.value', '24')
cy.get('.table').should('contain', 'Item publish')
2018-04-02 19:16:37 +00:00
.and('contain', 'Item private')
2018-04-10 19:38:27 +00:00
.and('not.contain', 'Item draft')
.and('not.contain', 'Item trash')
2018-04-02 19:16:37 +00:00
.and('contain', 'Item 1')
.and('contain', 'Item 2')
.and('contain', 'Item 3')
.and('contain', 'Item 4')
.and('contain', 'Item 5')
.and('contain', 'Item 6')
.and('contain', 'Item 7')
.and('contain', 'Item 8')
.and('contain', 'Item 9')
.and('contain', 'Item 10')
.and('contain', 'Item 11')
.and('contain', 'Item 12')
.and('contain', 'Item 13')
.and('contain', 'Item 14')
.and('contain', 'Item 15')
})
})
})