tainacan/cypress/integration/repository/collection/field/field_relationship_spec.js

163 lines
9.3 KiB
JavaScript

context('Relationship field test', function(){
beforeEach(() => {
cy.loginByUI()
})
it('clear DB', function(){
cy.clearDB()
})
it('create collection for create fields', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get('#button-create-collection').click()
cy.get('#tainacan-text-name').type('Book Fields')
cy.get('#tainacan-text-description').type('Descrição book Fields')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('#primary-menu > .menu > .menu-header > .menu-list > li > .router-link-active > .icon > .mdi').click()
cy.get('.b-table').should('contain', 'Book Fields')
})
it('create collection for create relationship', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.contains('New Collection').click()
cy.get('#tainacan-text-name').type('Book relationship')
cy.get('#tainacan-text-description').type('Descrição book relationship')
cy.get('#tainacan-select-status').select('Publish').should('have.value', 'publish')
cy.get('#button-submit-collection-creation').click()
cy.get('#primary-menu > .menu > .menu-header > .menu-list > li > .router-link-active > .icon > .mdi').click()
cy.get('.b-table').should('contain', 'Book relationship')
})
it('canceled create relationship-type field public', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(6)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('relationship name canceled')
cy.get('.textarea').type('name book canceled description')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(1) > .button').click()
cy.get('.active-fields-area >').should('not.contain', 'relationship name canceled')
})
it('create relationship-type field public', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(6)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('relationship name public')
cy.get('.textarea').type('name book description')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get('select').select('Book relationship')
cy.get(':nth-child(1) > .b-checkbox > .check').click()
cy.get('.block > :nth-child(2) > .b-checkbox > .check').click()
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'relationship name public')
})
it('create relationship-type field private', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(6)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('relationship name private')
cy.get('.textarea').type('name book description')
cy.get('#tainacan-select-status-private > .check').click()
cy.get('select').select('Book relationship')
cy.get(':nth-child(1) > .b-checkbox > .check').click()
cy.get('.block > :nth-child(2) > .b-checkbox > .check').click()
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'relationship name private')
})
it('create relationship-type field public required', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(6)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('relationship name public required')
cy.get('.textarea').type('name book description required')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(2) > .b-checkbox > .check').click()
cy.get('select').select('Book relationship')
cy.get(':nth-child(1) > .b-checkbox > .check').click()
cy.get('.block > :nth-child(2) > .b-checkbox > .check').click()
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'relationship name public required')
})
it('create relationship-type field public multiple values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(6)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('relationship name public multiple values')
cy.get('.textarea').type('name book description multiple values')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(3) > .b-checkbox > .check').click()
cy.get('select').select('Book relationship')
cy.get(':nth-child(1) > .b-checkbox > .check').click()
cy.get('.block > :nth-child(2) > .b-checkbox > .check').click()
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'relationship name public multiple values')
})
it('create relationship-type field public unique values', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.field > :nth-child(2) > :nth-child(6)').click()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').clear()
cy.get('#fieldEditForm > :nth-child(1) > .control > .input').type('relationship name public unique values')
cy.get('.textarea').type('name book description multiple values')
cy.get('#tainacan-select-status-publish > .check').click()
cy.get(':nth-child(4) > .b-checkbox > .check').click()
cy.get('select').select('Book relationship')
cy.get(':nth-child(1) > .b-checkbox > .check').click()
cy.get('.block > :nth-child(2) > .b-checkbox > .check').click()
cy.get(':nth-child(2) > .button').click()
cy.get('.active-fields-area >').should('contain', 'relationship name public unique values')
})
it('check if fields are updated to page', function(){
cy.visit('/wp-admin/admin.php?page=tainacan_admin#/collections')
cy.location('hash').should('eq', '#/collections')
cy.get(':nth-child(2) > [data-label="Name"] > :nth-child(1) > .clickable-row').click()
cy.get(':nth-child(4) > .router-link-active').should('contain', 'Items')
cy.get('.menu > :nth-child(2) > :nth-child(5) > a').click()
cy.get('h1').should('contain', 'Collection Fields Edition Page')
cy.get('.active-fields-area >').should('not.contain', 'relationship name canceled')
cy.get('.active-fields-area >').should('contain', 'relationship name public')
cy.get('.active-fields-area >').should('contain', 'relationship name private')
cy.get('.active-fields-area >').should('contain', 'relationship name public required')
cy.get('.active-fields-area >').should('contain', 'relationship name public multiple values')
cy.get('.active-fields-area >').should('contain', 'relationship name public unique values')
})
})