mirror of
https://github.com/strapi/strapi.git
synced 2025-07-23 09:00:19 +00:00
Chore: Remove legacy cypress tests
This commit is contained in:
parent
b0a73c921a
commit
e3f63edf99
@ -1,428 +0,0 @@
|
||||
let jwt;
|
||||
|
||||
const frontEndUrl = Cypress.config('baseUrl');
|
||||
const frontLoadingDelay = Cypress.config('frontLoadingDelay');
|
||||
const backendUrl = Cypress.config('backendUrl');
|
||||
|
||||
const getCreateRedirectUrl = (model, sort = '_id') => {
|
||||
return `${frontEndUrl}/admin/plugins/content-manager/${model}/create?redirectUrl=/plugins/content-manager/${model}?_limit=10&_page=1&_sort=${sort}&source=content-manager`;
|
||||
};
|
||||
const getRequest = (model, sort = '_id') => {
|
||||
return `${backendUrl}/content-manager/explorer/${model}?_limit=10&_start=0&_sort=${sort}:ASC&source=content-manager`;
|
||||
};
|
||||
|
||||
describe('Testing Content Manager createPages', function () {
|
||||
before(() => {
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
|
||||
return cy.createCTMApis(data.jwt).then(() => jwt);
|
||||
})
|
||||
.wait(1000);
|
||||
|
||||
Cypress.Commands.add('ctmTagLink', () => {
|
||||
return cy.get('a[href="/admin/plugins/content-manager/tag?source=content-manager"]');
|
||||
});
|
||||
Cypress.Commands.add('ctmProductLink', () => {
|
||||
return cy.get('a[href="/admin/plugins/content-manager/product?source=content-manager"]');
|
||||
});
|
||||
Cypress.Commands.add('ctmCategoryLink', () => {
|
||||
return cy.get('a[href="/admin/plugins/content-manager/category?source=content-manager"]');
|
||||
});
|
||||
Cypress.Commands.add('ctmAddButton', () => {
|
||||
return cy.get('button#addEntry');
|
||||
});
|
||||
Cypress.Commands.add('inputError', (name) => {
|
||||
return cy.get(`#errorOf${name} > span`);
|
||||
});
|
||||
Cypress.Commands.add('getListTagsOrderedByName', () => {
|
||||
return cy.ctmTagLink().click().get('tr > th:nth-child(3) > span').click();
|
||||
});
|
||||
Cypress.Commands.add('fillProductForm', (product) => {
|
||||
Object.keys(product).forEach((key) => {
|
||||
if (key === 'description') {
|
||||
cy.get(`textarea[name="${key}"]`).type(product[key]);
|
||||
} else {
|
||||
cy.get(`input[name="${key}"]`).type(product[key]);
|
||||
}
|
||||
});
|
||||
});
|
||||
Cypress.Commands.add('getProduct', (index) => {
|
||||
return cy
|
||||
.ctmProductLink()
|
||||
.click()
|
||||
.wait(1000)
|
||||
.get(`tbody > tr:nth-child(${index})`)
|
||||
.click()
|
||||
.wait(1000)
|
||||
.window()
|
||||
.its('__store__')
|
||||
.its('store');
|
||||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.deleteApi('tag', jwt).deleteApi('category', jwt).deleteApi('product', jwt);
|
||||
});
|
||||
|
||||
context('Creating data with no relation', () => {
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
cy.route(`${backendUrl}/content-manager/models`).as('initContentManager');
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
})
|
||||
.visit('/admin')
|
||||
.wait(frontLoadingDelay)
|
||||
.wait('@initContentManager');
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.deleteAllModelData('tag', jwt)
|
||||
.deleteAllModelData('category', jwt)
|
||||
.deleteAllModelData('product', jwt);
|
||||
});
|
||||
|
||||
it('Should create a tag with no relation', () => {
|
||||
cy.server();
|
||||
cy.route(getRequest('tag')).as('getTags');
|
||||
cy.ctmTagLink().click().ctmAddButton().click();
|
||||
const tagsToCreate = [
|
||||
'tag1',
|
||||
'tag2',
|
||||
'tag3',
|
||||
'superTag',
|
||||
'badTag',
|
||||
"I'm running out of idea tag",
|
||||
];
|
||||
// Check redirect url
|
||||
cy.url().should('equal', getCreateRedirectUrl('tag'));
|
||||
|
||||
// Try to save empty data
|
||||
cy.submitForm()
|
||||
.get('input#name')
|
||||
.invoke('attr', 'class')
|
||||
.should('include', 'form-control is-invalid');
|
||||
|
||||
tagsToCreate.forEach((tagName, index) => {
|
||||
cy.get('input#name')
|
||||
.type(tagName)
|
||||
.submitForm()
|
||||
.wait('@getTags')
|
||||
.get('tbody')
|
||||
.children()
|
||||
.should('have.length', index + 1);
|
||||
|
||||
if (index < tagsToCreate.length - 1) {
|
||||
cy.ctmAddButton().click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Should create a category with no relation', () => {
|
||||
cy.server();
|
||||
cy.route(getRequest('category', 'name')).as('getCategories');
|
||||
cy.ctmCategoryLink()
|
||||
.click()
|
||||
.get('tr > th:nth-child(3) > span')
|
||||
.click()
|
||||
.ctmAddButton()
|
||||
.click();
|
||||
const catsToCreate = [
|
||||
'drinks',
|
||||
'food',
|
||||
'junk food',
|
||||
'french food',
|
||||
'good french food',
|
||||
'greasy',
|
||||
"you don't want to eat that",
|
||||
];
|
||||
// Check redirect url
|
||||
cy.url().should('equal', getCreateRedirectUrl('category', 'name'));
|
||||
|
||||
catsToCreate.forEach((catName, index) => {
|
||||
cy.get('input#name')
|
||||
.type(catName)
|
||||
.submitForm()
|
||||
.wait('@getCategories')
|
||||
.get('tbody')
|
||||
.children()
|
||||
.should('have.length', index + 1);
|
||||
|
||||
if (index < catsToCreate.length - 1) {
|
||||
cy.ctmAddButton().click();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
it('Should display an error for unique fields for categories', () => {
|
||||
cy.ctmCategoryLink()
|
||||
.click()
|
||||
.ctmAddButton()
|
||||
.click()
|
||||
.get('input#name')
|
||||
.type('drinks')
|
||||
.submitForm()
|
||||
.get('input#name')
|
||||
.invoke('attr', 'class')
|
||||
.should('includes', 'form-control is-invalid')
|
||||
.get('input#name')
|
||||
.inputError('name')
|
||||
.should('have.text', 'This name is already taken ');
|
||||
});
|
||||
|
||||
it('Should delete all data using the UI', () => {
|
||||
cy.server();
|
||||
cy.route(getRequest('tag')).as('getTags');
|
||||
cy.route(getRequest('category', 'name')).as('getCategories');
|
||||
|
||||
cy.ctmTagLink()
|
||||
.click()
|
||||
.wait('@getTags')
|
||||
.wait(1000)
|
||||
.get('thead > tr > th:first-child')
|
||||
.click()
|
||||
.get('span#deleteAllData')
|
||||
.click()
|
||||
.get('button#ctaConfirm')
|
||||
.click()
|
||||
.wait(2000)
|
||||
.window()
|
||||
.its('__store__')
|
||||
.its('store')
|
||||
.then((pluginStore) => {
|
||||
const records = pluginStore
|
||||
.getState()
|
||||
.getIn(['content-manager_listPage', 'records', 'tag'])
|
||||
.toJS();
|
||||
|
||||
expect(records).to.have.length(0);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
context('Creating and updating data with relation', () => {
|
||||
before(() => {
|
||||
cy.server();
|
||||
cy.route(`${backendUrl}/content-manager/models`).as('initContentManager');
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
|
||||
return data.jwt;
|
||||
})
|
||||
.then((jwt) => {
|
||||
return cy.seedData('tag', jwt).then(() => jwt);
|
||||
})
|
||||
.then((jwt) => {
|
||||
return cy.seedData('category', jwt);
|
||||
});
|
||||
});
|
||||
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
cy.route(`${backendUrl}/content-manager/models`).as('initContentManager');
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
|
||||
return data.jwt;
|
||||
})
|
||||
.visit('/admin')
|
||||
.wait(frontLoadingDelay)
|
||||
.wait('@initContentManager');
|
||||
});
|
||||
|
||||
it('Should create a product and link several tags and 1 category', () => {
|
||||
cy.server();
|
||||
cy.route(
|
||||
`${backendUrl}/content-manager/explorer/tag?_limit=10&_start=0&_sort=name:ASC&source=content-manager`
|
||||
).as('getTags');
|
||||
cy.ctmProductLink().click().ctmAddButton().click();
|
||||
|
||||
// Test default value
|
||||
cy.get('button#__OFF__bool')
|
||||
.invoke('attr', 'class')
|
||||
.should('includes', 'gradientOff')
|
||||
.get('button#__ON__bool1')
|
||||
.invoke('attr', 'class')
|
||||
.should('includes', 'gradientOn');
|
||||
|
||||
// Create a product
|
||||
const product = {
|
||||
name: 'product1',
|
||||
description: 'This is a super description',
|
||||
price: 1337,
|
||||
email: 'hi@strapi.io',
|
||||
};
|
||||
|
||||
Object.keys(product).forEach((key) => {
|
||||
if (key === 'description') {
|
||||
cy.get(`textarea[name="${key}"]`).type(product[key]);
|
||||
} else {
|
||||
cy.get(`input[name="${key}"]`).type(product[key]);
|
||||
}
|
||||
});
|
||||
|
||||
cy.get('button#__ON__bool').click().get('button#__OFF__bool1').click();
|
||||
|
||||
cy.get('input#tags')
|
||||
.type('special t', { force: true })
|
||||
.type('{enter}', { force: true })
|
||||
.type('ta', { force: true })
|
||||
.type('{enter}', { force: true })
|
||||
.get('ul#sortableListOftags')
|
||||
.children('li')
|
||||
.should((children) => {
|
||||
expect(children[0].innerText.trim()).to.equal('special tag');
|
||||
expect(children[1].innerText.trim()).to.equal('tag1');
|
||||
})
|
||||
.get('input#category')
|
||||
.type('french food', { force: true })
|
||||
.type('{enter}')
|
||||
.invoke('attr', 'value')
|
||||
.should('equal', 'french food')
|
||||
.submitForm();
|
||||
|
||||
cy.getListTagsOrderedByName()
|
||||
.wait('@getTags')
|
||||
.wait(1000)
|
||||
.get('tbody > tr:first-child')
|
||||
.click()
|
||||
.get('ul#sortableListOfproducts')
|
||||
.children()
|
||||
.should((children) => {
|
||||
expect(children).to.have.length(1);
|
||||
expect(children[0].innerText.trim()).to.equal('product1');
|
||||
});
|
||||
|
||||
cy.getListTagsOrderedByName()
|
||||
.wait('@getTags')
|
||||
.wait(2000)
|
||||
.get('tbody > tr:nth-child(2)')
|
||||
.click()
|
||||
.get('ul#sortableListOfproducts')
|
||||
.children()
|
||||
.should((children) => {
|
||||
expect(children).to.have.length(1);
|
||||
expect(children[0].innerText.trim()).to.equal('product1');
|
||||
});
|
||||
});
|
||||
|
||||
it('Should delete a product in tag1', () => {
|
||||
cy.getListTagsOrderedByName()
|
||||
.wait(frontLoadingDelay)
|
||||
.get('tbody > tr:nth-child(2)')
|
||||
.click()
|
||||
.wait(1000)
|
||||
.get('ul#sortableListOfproducts > li:nth-child(1) > div:nth-child(2) > img')
|
||||
.click()
|
||||
.submitForm()
|
||||
.ctmProductLink()
|
||||
.click()
|
||||
.wait(1000)
|
||||
.get('tbody > tr:nth-child(1)')
|
||||
.click()
|
||||
.wait(frontLoadingDelay)
|
||||
.get('ul#sortableListOftags')
|
||||
.children()
|
||||
.should((children) => {
|
||||
expect(children).to.have.length(1);
|
||||
expect(children[0].innerText.trim()).to.equal('special tag');
|
||||
});
|
||||
});
|
||||
|
||||
it('Should add several products to category french food', () => {
|
||||
cy.server();
|
||||
cy.route(
|
||||
`${backendUrl}/content-manager/explorer/category?_limit=10&_start=0&_sort=_id:ASC&source=content-manager`
|
||||
).as('getCategories');
|
||||
cy.route(
|
||||
`${backendUrl}/content-manager/explorer/product?_limit=10&_start=0&_sort=_id:ASC&source=content-manager`
|
||||
).as('getProducts');
|
||||
const product = {
|
||||
name: 'MacBook',
|
||||
description: 'A laptop',
|
||||
price: 2000,
|
||||
email: 'kai@strapi.io',
|
||||
};
|
||||
const product2 = {
|
||||
name: 'Dell',
|
||||
description: 'Not a mac',
|
||||
price: 4,
|
||||
email: 'bob@strapi.io',
|
||||
};
|
||||
|
||||
cy.ctmProductLink().click().ctmAddButton().click();
|
||||
|
||||
cy.fillProductForm(product)
|
||||
.submitForm()
|
||||
.ctmAddButton()
|
||||
.click()
|
||||
.fillProductForm(product2)
|
||||
.submitForm();
|
||||
|
||||
cy.ctmCategoryLink()
|
||||
.click()
|
||||
.wait('@getCategories')
|
||||
.wait(1000)
|
||||
.get('tbody > tr:nth-child(5)')
|
||||
.click()
|
||||
.get('ul#sortableListOfproducts')
|
||||
.as('relations')
|
||||
.children()
|
||||
.should((children) => {
|
||||
expect(children).to.have.length(1);
|
||||
expect(children[0].innerText.trim()).to.equal('product1');
|
||||
})
|
||||
.get('ul#sortableListOfproducts > li:nth-child(1) > div:nth-child(2) > img')
|
||||
.click()
|
||||
.get('input#products')
|
||||
.type('mac', { force: true })
|
||||
.type('{enter}', { force: true })
|
||||
.type('dell', { force: true })
|
||||
.type('{enter}', { force: true })
|
||||
.get('@relations')
|
||||
.children()
|
||||
.should((children) => {
|
||||
expect(children).to.have.length(2);
|
||||
expect(children[0].innerText.trim()).to.equal('MacBook');
|
||||
expect(children[1].innerText.trim()).to.equal('Dell');
|
||||
})
|
||||
.submitForm();
|
||||
|
||||
cy.getProduct(1).then((pluginStore) => {
|
||||
const category = pluginStore
|
||||
.getState()
|
||||
.getIn(['content-manager_editPage', 'record', 'category']);
|
||||
|
||||
expect(category).to.equal(null);
|
||||
});
|
||||
|
||||
cy.getProduct(2)
|
||||
.then((pluginStore) => {
|
||||
const category = pluginStore
|
||||
.getState()
|
||||
.getIn(['content-manager_editPage', 'record', 'category', 'name']);
|
||||
|
||||
expect(category).to.equal('french food');
|
||||
})
|
||||
.getProduct(3)
|
||||
.then((pluginStore) => {
|
||||
const category = pluginStore
|
||||
.getState()
|
||||
.getIn(['content-manager_editPage', 'record', 'category', 'name']);
|
||||
|
||||
expect(category).to.equal('french food');
|
||||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.deleteAllModelData('tag', jwt)
|
||||
.deleteAllModelData('category', jwt)
|
||||
.deleteAllModelData('product', jwt);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,90 +0,0 @@
|
||||
let jwt;
|
||||
const animDelay = Cypress.config('animDelay');
|
||||
const backendUrl = Cypress.config('backendUrl');
|
||||
const frontLoadingDelay = Cypress.config('frontLoadingDelay');
|
||||
const links = {
|
||||
Category: '/admin/plugins/content-manager/category?source=content-manager',
|
||||
Product: '/admin/plugins/content-manager/product?source=content-manager',
|
||||
settings: '/admin/plugins/content-manager/ctm-configurations',
|
||||
Tag: '/admin/plugins/content-manager/tag?source=content-manager',
|
||||
User: '/admin/plugins/content-manager/user?source=users-permissions',
|
||||
};
|
||||
|
||||
describe('Testing build and schema core_store', () => {
|
||||
before(() => {
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
|
||||
return cy.createCTMApis(data.jwt);
|
||||
})
|
||||
.wait(1000);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.deleteApi('tag', jwt).deleteApi('category', jwt).deleteApi('product', jwt);
|
||||
});
|
||||
|
||||
context('Testing views', () => {
|
||||
beforeEach(() => {
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
})
|
||||
.visit('/admin')
|
||||
.wait(frontLoadingDelay);
|
||||
});
|
||||
|
||||
it('Should visit all list pages without any errors', () => {
|
||||
cy.server();
|
||||
cy.route(`${backendUrl}/content-manager/models`).as('initCTM');
|
||||
cy.get(`a[href="${links.settings}"]`).click().wait('@initCTM');
|
||||
|
||||
// Check all list views are rendered without any error
|
||||
for (let i = 0; i < 4; i++) {
|
||||
Object.keys(links).forEach((link) => {
|
||||
const name = link === 'settings' ? 'Content Manager' : link;
|
||||
|
||||
cy.get(`a[href="${links[link]}"]`).click().get('h1').should('have', name);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
it('Should visit all views once without any errors', () => {
|
||||
cy.server();
|
||||
cy.route(`${backendUrl}/content-manager/models`).as('initCTM');
|
||||
cy.get(`a[href="${links.settings}"]`).click().wait('@initCTM');
|
||||
|
||||
// Testing errors related to reactstrap
|
||||
cy.get('#cancelChanges')
|
||||
.click()
|
||||
.wait(animDelay)
|
||||
.checkModalOpening()
|
||||
.should('be.visible')
|
||||
.type('{esc}');
|
||||
|
||||
// Test setting view
|
||||
Object.keys(links).forEach((link) => {
|
||||
if (link !== 'settings') {
|
||||
cy.get(`#${link.toLowerCase()}`)
|
||||
.click()
|
||||
.get('h1')
|
||||
.should('have', `Content Manager - ${link}`)
|
||||
.get(`a[href="${links.settings}"]`)
|
||||
.click();
|
||||
}
|
||||
});
|
||||
|
||||
Object.keys(links).forEach((link) => {
|
||||
if (link !== 'settings') {
|
||||
cy.get(`a[href="${links[link]}"]`)
|
||||
.click()
|
||||
.get('button#addEntry')
|
||||
.click()
|
||||
.get('h1')
|
||||
.should('have', 'New Entry');
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
@ -1,179 +0,0 @@
|
||||
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;
|
||||
|
||||
return cy.createCTMApis(data.jwt).then(() => jwt);
|
||||
})
|
||||
.then((jwt) => {
|
||||
cy.seedData('product', jwt);
|
||||
})
|
||||
.wait(1000);
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.deleteAllModelData('product', jwt);
|
||||
cy.deleteApi('tag', jwt).deleteApi('category', jwt).deleteApi('product', jwt);
|
||||
});
|
||||
|
||||
context('Testing sorting options', () => {
|
||||
beforeEach(() => {
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
})
|
||||
.visit('/admin')
|
||||
.wait(frontLoadingDelay);
|
||||
});
|
||||
|
||||
it('Should have the Id default sort', () => {
|
||||
cy.get('a[href="/admin/plugins/content-manager/product?source=content-manager"]')
|
||||
.click()
|
||||
.wait(frontLoadingDelay);
|
||||
|
||||
cy.get('tr > th:nth-child(2) > span')
|
||||
.children('i')
|
||||
.should('be.visible')
|
||||
.invoke('attr', 'class')
|
||||
.should('includes', 'fa-sort-up');
|
||||
});
|
||||
|
||||
it('Should change the default sort of product to name ASC then name DESC', () => {
|
||||
cy.server();
|
||||
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');
|
||||
|
||||
cy.get('a[href="/admin/plugins/content-manager/product?source=content-manager"]')
|
||||
.click()
|
||||
.wait('@getProduct')
|
||||
.get('tr > th:nth-child(3) > span')
|
||||
.as('getName')
|
||||
.click();
|
||||
|
||||
cy.wait('@getSortByNameASC')
|
||||
.get('@getName')
|
||||
.children('i')
|
||||
.should('be.visible')
|
||||
.invoke('attr', 'class')
|
||||
.should('includes', 'iconAsc')
|
||||
.get('tbody > tr:nth-child(1) > td:nth-child(3)')
|
||||
.as('firstResult')
|
||||
.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()
|
||||
.get('select[name="product.defaultSort"]')
|
||||
.as('defaultSort')
|
||||
.select('name')
|
||||
.should('have.value', 'name')
|
||||
.get('select[name="product.sort"]')
|
||||
.as('sortOption')
|
||||
.select('DESC')
|
||||
.should('have.value', 'DESC')
|
||||
.submitForm()
|
||||
.get('#ctaConfirm')
|
||||
.click()
|
||||
.wait(frontLoadingDelay)
|
||||
.get('a[href="/admin/plugins/content-manager/product?source=content-manager"]')
|
||||
.click()
|
||||
.wait(frontLoadingDelay)
|
||||
.get('tr > th:nth-child(3) > span')
|
||||
.as('getName')
|
||||
.children('i')
|
||||
.invoke('attr', 'class')
|
||||
.should('includes', 'iconDesc')
|
||||
.get('tbody > tr:nth-child(1) > td:nth-child(3)')
|
||||
.should('have.text', 'name1');
|
||||
|
||||
// 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)
|
||||
.get('a[href="/admin/plugins/content-manager/product?source=content-manager"]')
|
||||
.click()
|
||||
.wait(frontLoadingDelay)
|
||||
.get('tr > th:nth-child(2) > span')
|
||||
.children('i')
|
||||
.invoke('attr', 'class')
|
||||
.should('includes', 'iconAsc');
|
||||
});
|
||||
});
|
||||
|
||||
context('Testing filters', () => {
|
||||
beforeEach(() => {
|
||||
cy.login()
|
||||
.then((data) => {
|
||||
jwt = data.jwt;
|
||||
})
|
||||
.visit('/admin')
|
||||
.wait(frontLoadingDelay);
|
||||
});
|
||||
|
||||
it('Should apply filters for product data', () => {
|
||||
cy.get('a[href="/admin/plugins/content-manager/product?source=content-manager"]')
|
||||
.click()
|
||||
.wait(frontLoadingDelay);
|
||||
cy.get('button#addFilterCTA')
|
||||
.as('toggleFilter')
|
||||
.click()
|
||||
.wait(animDelay)
|
||||
.get('div#filterPickWrapper')
|
||||
.as('filterWrapper')
|
||||
.children('div')
|
||||
.should('have.length', 1);
|
||||
|
||||
cy.get('input[name="0.value"]')
|
||||
.type('name')
|
||||
.get('button#newFilter')
|
||||
.click()
|
||||
.get('select[name="1.attr"]')
|
||||
.select('bool')
|
||||
.get(
|
||||
'button[label="content-manager.components.FiltersPickWrapper.PluginHeader.actions.apply"]'
|
||||
)
|
||||
.click()
|
||||
.wait(animDelay)
|
||||
.get('tbody > tr')
|
||||
.should('have.length', 1);
|
||||
});
|
||||
});
|
||||
});
|
@ -1,231 +0,0 @@
|
||||
// import 'whatwg-fetch';
|
||||
|
||||
let jwt;
|
||||
let userId;
|
||||
const animDelay = Cypress.config('animDelay');
|
||||
const frontEndUrl = Cypress.config('baseUrl');
|
||||
const frontLoadingDelay = Cypress.config('frontLoadingDelay');
|
||||
const backendUrl = Cypress.config('backendUrl');
|
||||
const pluginUrl = `${frontEndUrl}/admin/plugins/content-type-builder`;
|
||||
const TAG_API = {
|
||||
name: 'tag',
|
||||
description: 'This is a super tag \nwith multi \nlines description.',
|
||||
};
|
||||
|
||||
describe('Test CTB', () => {
|
||||
context('Check create and update API', () => {
|
||||
beforeEach(() => {
|
||||
cy.server();
|
||||
cy.route(`${backendUrl}/content-type-builder/autoReload`).as('initContentTypeBuilder');
|
||||
cy.login().then((data) => {
|
||||
jwt = data.jwt;
|
||||
userId = data.user._id || data.user.id;
|
||||
});
|
||||
cy.visit('/admin');
|
||||
cy.wait(frontLoadingDelay);
|
||||
cy.wait('@initContentTypeBuilder');
|
||||
});
|
||||
|
||||
it('Should visit the content type builder', () => {
|
||||
cy.get('a[href="/admin/plugins/content-type-builder"').click();
|
||||
cy.url().should('equal', pluginUrl);
|
||||
});
|
||||
|
||||
it('Should prevent the user from creating a camelCase api', () => {
|
||||
cy.server();
|
||||
cy.route('GET', `${backendUrl}/content-type-builder/models`).as('models');
|
||||
|
||||
cy.get('a[href="/admin/plugins/content-type-builder"')
|
||||
.click()
|
||||
.wait('@models')
|
||||
.get('#openAddCT')
|
||||
.click()
|
||||
.get('#name')
|
||||
.type('camelCase')
|
||||
.get('#description')
|
||||
.type('\n')
|
||||
.get('#name')
|
||||
.should('have.value', 'camelcase')
|
||||
.get('#name')
|
||||
.type('{selectall}')
|
||||
.type('not camel-case')
|
||||
.get('#description')
|
||||
.type('{backspace}')
|
||||
.get('#name')
|
||||
.should('have.value', 'notcamelcase');
|
||||
});
|
||||
|
||||
it('Should create a TAG API', function () {
|
||||
cy.server();
|
||||
cy.route('GET', `${backendUrl}/content-type-builder/models`).as('models');
|
||||
cy.route('POST', `${backendUrl}/content-type-builder/models`).as('createModel');
|
||||
cy.route('DELETE', `${backendUrl}/content-type-builder/models/tag`).as('deleteTag');
|
||||
|
||||
cy.get('a[href="/admin/plugins/content-type-builder"').click().wait('@models');
|
||||
|
||||
// Open modal
|
||||
cy.get('#openAddCT').click().wait(animDelay);
|
||||
|
||||
// Check the modal is opened this will tell is if we have a build issue
|
||||
cy.checkModalOpening();
|
||||
cy.get('.modal').invoke('show');
|
||||
|
||||
// Fill the form
|
||||
Object.keys(TAG_API).forEach((key) => {
|
||||
cy.log(key);
|
||||
cy.get(`#${key}`).type(TAG_API[key]);
|
||||
});
|
||||
|
||||
// Submit the form and navigate to product page
|
||||
cy.submitForm().url().should('equal', `${pluginUrl}/models/tag`);
|
||||
|
||||
// Open the attributes's modal
|
||||
cy.get('#openAddAttr').click().wait(animDelay);
|
||||
|
||||
// Check that we don't have a build error from reacstrap
|
||||
cy.checkModalOpening().should('be.visible');
|
||||
|
||||
// Ensure the modal is opened to get #attrCardstring
|
||||
cy.wait(1000)
|
||||
.get('button#attrCardstring')
|
||||
.click()
|
||||
.get('input[name="name"]')
|
||||
.type('name')
|
||||
.get('#continue')
|
||||
.click();
|
||||
|
||||
cy.get('button#saveData')
|
||||
.should('have.id', 'saveData')
|
||||
.click()
|
||||
.wait('@createModel')
|
||||
.wait(frontLoadingDelay);
|
||||
|
||||
cy.get('#attributesList li').first().should('contain', 'name');
|
||||
|
||||
// Delete tag API
|
||||
cy.get('a[href="/admin/plugins/content-type-builder"]')
|
||||
.click()
|
||||
.wait(frontLoadingDelay)
|
||||
.wait(frontLoadingDelay)
|
||||
.get('#deletetag')
|
||||
.click()
|
||||
.checkModalOpening()
|
||||
.should('be.visible')
|
||||
.get('#ctaConfirm')
|
||||
.click()
|
||||
.wait('@deleteTag')
|
||||
.wait(frontLoadingDelay)
|
||||
.get('#ctbModelsList li')
|
||||
.should('have.length', 4)
|
||||
.waitRestart();
|
||||
});
|
||||
|
||||
it('Should update PRODUCT API field and visit the create product page', () => {
|
||||
cy.server();
|
||||
cy.createProductAndTagApis(jwt);
|
||||
cy.route(`${backendUrl}/content-type-builder/models/product?`).as('getProductModel');
|
||||
cy.route('PUT', `${backendUrl}/content-type-builder/models/product`).as('updateProductModel');
|
||||
|
||||
cy.visit(
|
||||
'/admin/plugins/content-type-builder/models/product#editproduct::attributestring::baseSettings::0'
|
||||
);
|
||||
cy.wait('@getProductModel');
|
||||
cy.wait(frontLoadingDelay);
|
||||
|
||||
// Open the modal via url
|
||||
cy.checkModalOpening()
|
||||
.should('be.visible')
|
||||
.get('input[name="name"]')
|
||||
.type('{selectall}')
|
||||
.type('updatedName')
|
||||
.get('#continue')
|
||||
.click();
|
||||
|
||||
cy.get('#attributesList li').first().contains('updatedName'); // Yield el in .nav containing 'About'
|
||||
|
||||
cy.get('button#saveData').click().wait('@updateProductModel').wait(frontLoadingDelay);
|
||||
|
||||
// Check that we can still go to the create page
|
||||
cy.get('a[href="/admin/plugins/content-manager/product?source=content-manager"')
|
||||
.click()
|
||||
.get('button[label="content-manager.containers.List.addAnEntry"')
|
||||
.click();
|
||||
|
||||
cy.window()
|
||||
.its('__store__')
|
||||
.its('store')
|
||||
.then((pluginStore) => {
|
||||
const displayedFields = pluginStore
|
||||
.getState()
|
||||
.getIn([
|
||||
'content-manager_global',
|
||||
'schema',
|
||||
'models',
|
||||
'product',
|
||||
'editDisplay',
|
||||
'fields',
|
||||
])
|
||||
.toJS();
|
||||
|
||||
expect(displayedFields).to.include.members([
|
||||
'description',
|
||||
'price',
|
||||
'updatedName',
|
||||
'bool',
|
||||
'bool1',
|
||||
'email',
|
||||
]);
|
||||
});
|
||||
|
||||
cy.waitRestart();
|
||||
});
|
||||
|
||||
it('Should update PRODUCT API name and visit the create product page', () => {
|
||||
cy.server();
|
||||
// cy.createProductAndTagApis(jwt);
|
||||
cy.route(`${backendUrl}/content-type-builder/models/product?`).as('getProductModel');
|
||||
cy.route('PUT', `${backendUrl}/content-type-builder/models/product`).as('updateProductModel');
|
||||
|
||||
cy.visit(
|
||||
'/admin/plugins/content-type-builder/models/product#editproduct::contentType::baseSettings'
|
||||
);
|
||||
cy.wait('@getProductModel');
|
||||
cy.wait(frontLoadingDelay);
|
||||
|
||||
// Open the modal via url
|
||||
cy.checkModalOpening()
|
||||
.should('be.visible')
|
||||
.get('input[name="name"]')
|
||||
.type('{selectall}')
|
||||
.type('produit')
|
||||
.submitForm()
|
||||
.wait('@updateProductModel')
|
||||
.wait(frontLoadingDelay);
|
||||
|
||||
// Check that we can still go to the create page
|
||||
cy.get('a[href="/admin/plugins/content-manager/produit?source=content-manager"')
|
||||
.click()
|
||||
.wait(frontLoadingDelay)
|
||||
.get('button[label="content-manager.containers.List.addAnEntry"')
|
||||
.click()
|
||||
.get('h1')
|
||||
.should('have.id', 'addNewEntry');
|
||||
|
||||
// cy.window()
|
||||
// .its('__store__')
|
||||
// .its('content-manager')
|
||||
// .then(pluginStore => {
|
||||
// const displayedFields = pluginStore
|
||||
// .getState()
|
||||
// .getIn(['global', 'schema', 'models', 'product', 'editDisplay', 'fields'])
|
||||
// .toJS();
|
||||
|
||||
// expect(displayedFields).to.include.members(['description', 'price', 'updatedName', 'bool', 'bool1', 'email']);
|
||||
// });
|
||||
});
|
||||
});
|
||||
|
||||
after(() => {
|
||||
cy.deleteApi('tag', jwt).deleteApi('produit', jwt).deleteUser(userId, jwt);
|
||||
});
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user