|
| 1 | +describe('Test that weblinks API endpoint', () => { |
| 2 | + afterEach(() => cy.task('queryDB', 'DELETE FROM #__weblinks WHERE title LIKE "%automated test weblink%"')); |
| 3 | + |
| 4 | + it('can deliver a list of weblinks', () => { |
| 5 | + cy.db_createWeblink({ title: 'automated test weblink' }) |
| 6 | + .then(() => cy.api_get('/weblinks')) |
| 7 | + .then((response) => cy.wrap(response).its('body').its('data.0').its('attributes') |
| 8 | + .its('title') |
| 9 | + .should('include', 'automated test weblink')); |
| 10 | + }); |
| 11 | + |
| 12 | + it('can deliver a single weblink', () => { |
| 13 | + cy.db_createWeblink({ title: 'automated test weblink' }) |
| 14 | + .then((weblink) => cy.api_get(`/weblinks/${weblink.id}`)) |
| 15 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 16 | + .its('title') |
| 17 | + .should('include', 'automated test weblink')); |
| 18 | + }); |
| 19 | + |
| 20 | + it('can create a weblink', () => { |
| 21 | + cy.db_createCategory({ extension: 'com_weblinks' }) |
| 22 | + .then((categoryId) => cy.api_post('/weblinks', { |
| 23 | + title: 'automated test weblink', |
| 24 | + alias: 'test-weblink', |
| 25 | + url: 'http://example.com', |
| 26 | + description: 'automated test weblink description', |
| 27 | + catid: categoryId, |
| 28 | + state: 1, |
| 29 | + language: '*', |
| 30 | + })) |
| 31 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 32 | + .its('title') |
| 33 | + .should('include', 'automated test weblink')); |
| 34 | + }); |
| 35 | + |
| 36 | + it('can update a weblink', () => { |
| 37 | + cy.db_createWeblink({ title: 'automated test weblink' }) |
| 38 | + .then((weblink) => cy.api_patch(`/weblinks/${weblink.id}`, { title: 'updated automated test weblink' })) |
| 39 | + .then((response) => cy.wrap(response).its('body').its('data').its('attributes') |
| 40 | + .its('title') |
| 41 | + .should('include', 'updated automated test weblink')); |
| 42 | + }); |
| 43 | + |
| 44 | + it('can delete a weblink', () => { |
| 45 | + cy.db_createWeblink({ title: 'automated test weblink', state: -2 }) |
| 46 | + .then((weblink) => cy.api_delete(`/weblinks/${weblink.id}`)); |
| 47 | + }); |
| 48 | +}); |
0 commit comments