From ad61242aeb107c1c2255733a1c17c528d0f1c290 Mon Sep 17 00:00:00 2001 From: alikon Date: Wed, 25 Dec 2024 11:34:39 +0100 Subject: [PATCH 1/4] com_contenthistory-api --- .../api/com_contenthistory/Banner.cy.js | 70 +++++++++++++++++ .../api/com_contenthistory/Contact.cy.js | 65 ++++++++++++++++ .../api/com_contenthistory/Content.cy.js | 75 +++++++++++++++++++ 3 files changed, 210 insertions(+) create mode 100644 tests/System/integration/api/com_contenthistory/Banner.cy.js create mode 100644 tests/System/integration/api/com_contenthistory/Contact.cy.js create mode 100644 tests/System/integration/api/com_contenthistory/Content.cy.js diff --git a/tests/System/integration/api/com_contenthistory/Banner.cy.js b/tests/System/integration/api/com_contenthistory/Banner.cy.js new file mode 100644 index 0000000000000..de170c8eac4e0 --- /dev/null +++ b/tests/System/integration/api/com_contenthistory/Banner.cy.js @@ -0,0 +1,70 @@ +describe('Test that contenthistory for banners API endpoint', () => { + beforeEach(() => { + cy.task('queryDB', 'DELETE FROM #__banners'); + cy.task('queryDB', 'DELETE FROM #__history'); + }); + + it('can get the history of an existing banner', () => { + cy.db_createCategory({ extension: 'com_banners' }) + .then((categoryId) => cy.api_post('/banners', { + name: 'automated test banner', + alias: 'test-banner', + catid: categoryId, + state: 1, + language: '*', + description: '', + custombannercode: '', + params: { + imageurl: '', width: '', height: '', alt: '', + }, + })) + .then((banner) => cy.api_get(`/banners/${banner.body.data.attributes.id}/contenthistory`)) + .then((response) => { + // Assert response status + expect(response.status).to.eq(200); + + // Extract the `data` array + const historyEntries = response.body.data; + cy.log(`History Entries: ${historyEntries.length}`); + + // Iterate through each history entry + historyEntries.forEach((entry) => { + const attributes = entry.attributes; + + // Access top-level attributes + const historyId = entry.id; + const saveDate = attributes.save_date; + const editor = attributes.editor; + const characterCount = attributes.character_count; + + // Access nested `version_data` + const versionData = attributes.version_data; + const bannerName = versionData.name; + const alias = versionData.alias; + const createdDate = versionData.created; + const modifiedDate = versionData.modified; + + // Log details for debugging + cy.log(`History ID: ${historyId}`); + cy.log(`Save Date: ${saveDate}`); + cy.log(`Editor: ${editor}`); + cy.log(`Character Count: ${characterCount}`); + cy.log(`Banner Name: ${bannerName}`); + cy.log(`Alias: ${alias}`); + cy.log(`Created Date: ${createdDate}`); + cy.log(`Modified Date: ${modifiedDate}`); + + // Perform assertions + expect(attributes).to.have.property('editor_user_id'); + expect(versionData).to.have.property('name'); + expect(versionData).to.have.property('modified'); + expect(bannerName).to.eq('automated test banner'); + }); + + // Check the total pages from metadata + const totalPages = response.body.meta['total-pages']; + expect(totalPages).to.eq(1); + cy.log(`Total Pages: ${totalPages}`); + }); + }); +}); diff --git a/tests/System/integration/api/com_contenthistory/Contact.cy.js b/tests/System/integration/api/com_contenthistory/Contact.cy.js new file mode 100644 index 0000000000000..30caf36e7dcb0 --- /dev/null +++ b/tests/System/integration/api/com_contenthistory/Contact.cy.js @@ -0,0 +1,65 @@ +describe('Test that contenthistory for contact API endpoint', () => { + beforeEach(() => { + cy.task('queryDB', 'DELETE FROM #__contact_details'); + cy.task('queryDB', 'DELETE FROM #__history'); + }); + + it('can get the history of an existing contact', () => { + cy.db_createCategory({ extension: 'com_contact' }) + .then((categoryId) => cy.api_post('/contacts', { + name: 'automated test contact', + alias: 'test-contact', + catid: categoryId, + published: 1, + language: '*', + })) + .then((contact) => cy.api_get(`/contacts/${contact.body.data.attributes.id}/contenthistory`)) + .then((response) => { + // Assert response status + expect(response.status).to.eq(200); + + // Extract the `data` array + const historyEntries = response.body.data; + cy.log(`History Entries: ${historyEntries.length}`); + + // Iterate through each history entry + historyEntries.forEach((entry) => { + const attributes = entry.attributes; + + // Access top-level attributes + const historyId = entry.id; + const saveDate = attributes.save_date; + const editor = attributes.editor; + const characterCount = attributes.character_count; + + // Access nested `version_data` + const versionData = attributes.version_data; + const contactName = versionData.name; + const alias = versionData.alias; + const createdDate = versionData.created; + const modifiedDate = versionData.modified; + + // Log details for debugging + cy.log(`History ID: ${historyId}`); + cy.log(`Save Date: ${saveDate}`); + cy.log(`Editor: ${editor}`); + cy.log(`Character Count: ${characterCount}`); + cy.log(`Contact Name: ${contactName}`); + cy.log(`Alias: ${alias}`); + cy.log(`Created Date: ${createdDate}`); + cy.log(`Modified Date: ${modifiedDate}`); + + // Perform assertions + expect(attributes).to.have.property('editor_user_id'); + expect(versionData).to.have.property('name'); + expect(versionData).to.have.property('modified'); + expect(contactName).to.eq('automated test contact'); + }); + + // Check the total pages from metadata + const totalPages = response.body.meta['total-pages']; + expect(totalPages).to.eq(1); + cy.log(`Total Pages: ${totalPages}`); + }); + }); +}); diff --git a/tests/System/integration/api/com_contenthistory/Content.cy.js b/tests/System/integration/api/com_contenthistory/Content.cy.js new file mode 100644 index 0000000000000..351f1edb5e73e --- /dev/null +++ b/tests/System/integration/api/com_contenthistory/Content.cy.js @@ -0,0 +1,75 @@ +describe('Test that contenthistory for content API endpoint', () => { + beforeEach(() => { + cy.task('queryDB', 'DELETE FROM #__content'); + cy.task('queryDB', 'DELETE FROM #__history'); + }); + + it('can get the history of an existing article', () => { + cy.db_createCategory({ extension: 'com_content' }) + .then((categoryId) => cy.api_post('/content/articles', { + title: 'automated test article', + alias: 'test-article', + catid: categoryId, + introtext: '', + fulltext: '', + state: 1, + access: 1, + language: '*', + created: '2023-01-01 20:00:00', + modified: '2023-01-01 20:00:00', + images: '', + urls: '', + attribs: '', + metadesc: '', + metadata: '', + })) + .then((article) => cy.api_get(`/content/articles/${article.body.data.attributes.id}/contenthistory`)) + .then((response) => { + // Assert response status + expect(response.status).to.eq(200); + + // Extract the `data` array + const historyEntries = response.body.data; + cy.log(`History Entries: ${historyEntries.length}`); + + // Iterate through each history entry + historyEntries.forEach((entry) => { + const attributes = entry.attributes; + + // Access top-level attributes + const historyId = entry.id; + const saveDate = attributes.save_date; + const editor = attributes.editor; + const characterCount = attributes.character_count; + + // Access nested `version_data` + const versionData = attributes.version_data; + const articleTitle = versionData.title; + const alias = versionData.alias; + const createdDate = versionData.created; + const modifiedDate = versionData.modified; + + // Log details for debugging + cy.log(`History ID: ${historyId}`); + cy.log(`Save Date: ${saveDate}`); + cy.log(`Editor: ${editor}`); + cy.log(`Character Count: ${characterCount}`); + cy.log(`Article Title: ${articleTitle}`); + cy.log(`Alias: ${alias}`); + cy.log(`Created Date: ${createdDate}`); + cy.log(`Modified Date: ${modifiedDate}`); + + // Perform assertions + expect(attributes).to.have.property('editor_user_id'); + expect(versionData).to.have.property('title'); + expect(versionData).to.have.property('modified'); + expect(articleTitle).to.eq('automated test article'); + }); + + // Check the total pages from metadata + const totalPages = response.body.meta['total-pages']; + expect(totalPages).to.eq(1); + cy.log(`Total Pages: ${totalPages}`); + }); + }); +}); From 6f1110ca205789ebf96cd9cb5d35bee298cb90d1 Mon Sep 17 00:00:00 2001 From: alikon Date: Wed, 25 Dec 2024 12:03:28 +0100 Subject: [PATCH 2/4] cs --- .../api/com_contenthistory/Banner.cy.js | 120 ++++++++-------- .../api/com_contenthistory/Contact.cy.js | 110 +++++++-------- .../api/com_contenthistory/Content.cy.js | 130 +++++++++--------- 3 files changed, 180 insertions(+), 180 deletions(-) diff --git a/tests/System/integration/api/com_contenthistory/Banner.cy.js b/tests/System/integration/api/com_contenthistory/Banner.cy.js index de170c8eac4e0..07f8217f62984 100644 --- a/tests/System/integration/api/com_contenthistory/Banner.cy.js +++ b/tests/System/integration/api/com_contenthistory/Banner.cy.js @@ -1,70 +1,70 @@ describe('Test that contenthistory for banners API endpoint', () => { - beforeEach(() => { - cy.task('queryDB', 'DELETE FROM #__banners'); - cy.task('queryDB', 'DELETE FROM #__history'); - }); + beforeEach(() => { + cy.task('queryDB', 'DELETE FROM #__banners'); + cy.task('queryDB', 'DELETE FROM #__history'); + }); - it('can get the history of an existing banner', () => { - cy.db_createCategory({ extension: 'com_banners' }) - .then((categoryId) => cy.api_post('/banners', { - name: 'automated test banner', - alias: 'test-banner', - catid: categoryId, - state: 1, - language: '*', - description: '', - custombannercode: '', - params: { - imageurl: '', width: '', height: '', alt: '', - }, - })) - .then((banner) => cy.api_get(`/banners/${banner.body.data.attributes.id}/contenthistory`)) - .then((response) => { - // Assert response status - expect(response.status).to.eq(200); + it('can get the history of an existing banner', () => { + cy.db_createCategory({ extension: 'com_banners' }) + .then((categoryId) => cy.api_post('/banners', { + name: 'automated test banner', + alias: 'test-banner', + catid: categoryId, + state: 1, + language: '*', + description: '', + custombannercode: '', + params: { + imageurl: '', width: '', height: '', alt: '', + }, + })) + .then((banner) => cy.api_get(`/banners/${banner.body.data.attributes.id}/contenthistory`)) + .then((response) => { + // Assert response status + expect(response.status).to.eq(200); - // Extract the `data` array - const historyEntries = response.body.data; - cy.log(`History Entries: ${historyEntries.length}`); + // Extract the `data` array + const historyEntries = response.body.data; + cy.log(`History Entries: ${historyEntries.length}`); - // Iterate through each history entry - historyEntries.forEach((entry) => { - const attributes = entry.attributes; + // Iterate through each history entry + historyEntries.forEach((entry) => { + const attributes = entry.attributes; - // Access top-level attributes - const historyId = entry.id; - const saveDate = attributes.save_date; - const editor = attributes.editor; - const characterCount = attributes.character_count; + // Access top-level attributes + const historyId = entry.id; + const saveDate = attributes.save_date; + const editor = attributes.editor; + const characterCount = attributes.character_count; - // Access nested `version_data` - const versionData = attributes.version_data; - const bannerName = versionData.name; - const alias = versionData.alias; - const createdDate = versionData.created; - const modifiedDate = versionData.modified; + // Access nested `version_data` + const versionData = attributes.version_data; + const bannerName = versionData.name; + const alias = versionData.alias; + const createdDate = versionData.created; + const modifiedDate = versionData.modified; - // Log details for debugging - cy.log(`History ID: ${historyId}`); - cy.log(`Save Date: ${saveDate}`); - cy.log(`Editor: ${editor}`); - cy.log(`Character Count: ${characterCount}`); - cy.log(`Banner Name: ${bannerName}`); - cy.log(`Alias: ${alias}`); - cy.log(`Created Date: ${createdDate}`); - cy.log(`Modified Date: ${modifiedDate}`); + // Log details for debugging + cy.log(`History ID: ${historyId}`); + cy.log(`Save Date: ${saveDate}`); + cy.log(`Editor: ${editor}`); + cy.log(`Character Count: ${characterCount}`); + cy.log(`Banner Name: ${bannerName}`); + cy.log(`Alias: ${alias}`); + cy.log(`Created Date: ${createdDate}`); + cy.log(`Modified Date: ${modifiedDate}`); - // Perform assertions - expect(attributes).to.have.property('editor_user_id'); - expect(versionData).to.have.property('name'); - expect(versionData).to.have.property('modified'); - expect(bannerName).to.eq('automated test banner'); - }); + // Perform assertions + expect(attributes).to.have.property('editor_user_id'); + expect(versionData).to.have.property('name'); + expect(versionData).to.have.property('modified'); + expect(bannerName).to.eq('automated test banner'); + }); - // Check the total pages from metadata - const totalPages = response.body.meta['total-pages']; - expect(totalPages).to.eq(1); - cy.log(`Total Pages: ${totalPages}`); - }); - }); + // Check the total pages from metadata + const totalPages = response.body.meta['total-pages']; + expect(totalPages).to.eq(1); + cy.log(`Total Pages: ${totalPages}`); + }); + }); }); diff --git a/tests/System/integration/api/com_contenthistory/Contact.cy.js b/tests/System/integration/api/com_contenthistory/Contact.cy.js index 30caf36e7dcb0..908ac6cc7f388 100644 --- a/tests/System/integration/api/com_contenthistory/Contact.cy.js +++ b/tests/System/integration/api/com_contenthistory/Contact.cy.js @@ -1,65 +1,65 @@ describe('Test that contenthistory for contact API endpoint', () => { - beforeEach(() => { - cy.task('queryDB', 'DELETE FROM #__contact_details'); - cy.task('queryDB', 'DELETE FROM #__history'); - }); + beforeEach(() => { + cy.task('queryDB', 'DELETE FROM #__contact_details'); + cy.task('queryDB', 'DELETE FROM #__history'); + }); - it('can get the history of an existing contact', () => { - cy.db_createCategory({ extension: 'com_contact' }) - .then((categoryId) => cy.api_post('/contacts', { - name: 'automated test contact', - alias: 'test-contact', - catid: categoryId, - published: 1, - language: '*', - })) - .then((contact) => cy.api_get(`/contacts/${contact.body.data.attributes.id}/contenthistory`)) - .then((response) => { - // Assert response status - expect(response.status).to.eq(200); + it('can get the history of an existing contact', () => { + cy.db_createCategory({ extension: 'com_contact' }) + .then((categoryId) => cy.api_post('/contacts', { + name: 'automated test contact', + alias: 'test-contact', + catid: categoryId, + published: 1, + language: '*', + })) + .then((contact) => cy.api_get(`/contacts/${contact.body.data.attributes.id}/contenthistory`)) + .then((response) => { + // Assert response status + expect(response.status).to.eq(200); - // Extract the `data` array - const historyEntries = response.body.data; - cy.log(`History Entries: ${historyEntries.length}`); + // Extract the `data` array + const historyEntries = response.body.data; + cy.log(`History Entries: ${historyEntries.length}`); - // Iterate through each history entry - historyEntries.forEach((entry) => { - const attributes = entry.attributes; + // Iterate through each history entry + historyEntries.forEach((entry) => { + const attributes = entry.attributes; - // Access top-level attributes - const historyId = entry.id; - const saveDate = attributes.save_date; - const editor = attributes.editor; - const characterCount = attributes.character_count; + // Access top-level attributes + const historyId = entry.id; + const saveDate = attributes.save_date; + const editor = attributes.editor; + const characterCount = attributes.character_count; - // Access nested `version_data` - const versionData = attributes.version_data; - const contactName = versionData.name; - const alias = versionData.alias; - const createdDate = versionData.created; - const modifiedDate = versionData.modified; + // Access nested `version_data` + const versionData = attributes.version_data; + const contactName = versionData.name; + const alias = versionData.alias; + const createdDate = versionData.created; + const modifiedDate = versionData.modified; - // Log details for debugging - cy.log(`History ID: ${historyId}`); - cy.log(`Save Date: ${saveDate}`); - cy.log(`Editor: ${editor}`); - cy.log(`Character Count: ${characterCount}`); - cy.log(`Contact Name: ${contactName}`); - cy.log(`Alias: ${alias}`); - cy.log(`Created Date: ${createdDate}`); - cy.log(`Modified Date: ${modifiedDate}`); + // Log details for debugging + cy.log(`History ID: ${historyId}`); + cy.log(`Save Date: ${saveDate}`); + cy.log(`Editor: ${editor}`); + cy.log(`Character Count: ${characterCount}`); + cy.log(`Contact Name: ${contactName}`); + cy.log(`Alias: ${alias}`); + cy.log(`Created Date: ${createdDate}`); + cy.log(`Modified Date: ${modifiedDate}`); - // Perform assertions - expect(attributes).to.have.property('editor_user_id'); - expect(versionData).to.have.property('name'); - expect(versionData).to.have.property('modified'); - expect(contactName).to.eq('automated test contact'); - }); + // Perform assertions + expect(attributes).to.have.property('editor_user_id'); + expect(versionData).to.have.property('name'); + expect(versionData).to.have.property('modified'); + expect(contactName).to.eq('automated test contact'); + }); - // Check the total pages from metadata - const totalPages = response.body.meta['total-pages']; - expect(totalPages).to.eq(1); - cy.log(`Total Pages: ${totalPages}`); - }); - }); + // Check the total pages from metadata + const totalPages = response.body.meta['total-pages']; + expect(totalPages).to.eq(1); + cy.log(`Total Pages: ${totalPages}`); + }); + }); }); diff --git a/tests/System/integration/api/com_contenthistory/Content.cy.js b/tests/System/integration/api/com_contenthistory/Content.cy.js index 351f1edb5e73e..2be213b0e00ba 100644 --- a/tests/System/integration/api/com_contenthistory/Content.cy.js +++ b/tests/System/integration/api/com_contenthistory/Content.cy.js @@ -1,75 +1,75 @@ describe('Test that contenthistory for content API endpoint', () => { - beforeEach(() => { - cy.task('queryDB', 'DELETE FROM #__content'); - cy.task('queryDB', 'DELETE FROM #__history'); - }); + beforeEach(() => { + cy.task('queryDB', 'DELETE FROM #__content'); + cy.task('queryDB', 'DELETE FROM #__history'); + }); - it('can get the history of an existing article', () => { - cy.db_createCategory({ extension: 'com_content' }) - .then((categoryId) => cy.api_post('/content/articles', { - title: 'automated test article', - alias: 'test-article', - catid: categoryId, - introtext: '', - fulltext: '', - state: 1, - access: 1, - language: '*', - created: '2023-01-01 20:00:00', - modified: '2023-01-01 20:00:00', - images: '', - urls: '', - attribs: '', - metadesc: '', - metadata: '', - })) - .then((article) => cy.api_get(`/content/articles/${article.body.data.attributes.id}/contenthistory`)) - .then((response) => { - // Assert response status - expect(response.status).to.eq(200); + it('can get the history of an existing article', () => { + cy.db_createCategory({ extension: 'com_content' }) + .then((categoryId) => cy.api_post('/content/articles', { + title: 'automated test article', + alias: 'test-article', + catid: categoryId, + introtext: '', + fulltext: '', + state: 1, + access: 1, + language: '*', + created: '2023-01-01 20:00:00', + modified: '2023-01-01 20:00:00', + images: '', + urls: '', + attribs: '', + metadesc: '', + metadata: '', + })) + .then((article) => cy.api_get(`/content/articles/${article.body.data.attributes.id}/contenthistory`)) + .then((response) => { + // Assert response status + expect(response.status).to.eq(200); - // Extract the `data` array - const historyEntries = response.body.data; - cy.log(`History Entries: ${historyEntries.length}`); + // Extract the `data` array + const historyEntries = response.body.data; + cy.log(`History Entries: ${historyEntries.length}`); - // Iterate through each history entry - historyEntries.forEach((entry) => { - const attributes = entry.attributes; + // Iterate through each history entry + historyEntries.forEach((entry) => { + const attributes = entry.attributes; - // Access top-level attributes - const historyId = entry.id; - const saveDate = attributes.save_date; - const editor = attributes.editor; - const characterCount = attributes.character_count; + // Access top-level attributes + const historyId = entry.id; + const saveDate = attributes.save_date; + const editor = attributes.editor; + const characterCount = attributes.character_count; - // Access nested `version_data` - const versionData = attributes.version_data; - const articleTitle = versionData.title; - const alias = versionData.alias; - const createdDate = versionData.created; - const modifiedDate = versionData.modified; + // Access nested `version_data` + const versionData = attributes.version_data; + const articleTitle = versionData.title; + const alias = versionData.alias; + const createdDate = versionData.created; + const modifiedDate = versionData.modified; - // Log details for debugging - cy.log(`History ID: ${historyId}`); - cy.log(`Save Date: ${saveDate}`); - cy.log(`Editor: ${editor}`); - cy.log(`Character Count: ${characterCount}`); - cy.log(`Article Title: ${articleTitle}`); - cy.log(`Alias: ${alias}`); - cy.log(`Created Date: ${createdDate}`); - cy.log(`Modified Date: ${modifiedDate}`); + // Log details for debugging + cy.log(`History ID: ${historyId}`); + cy.log(`Save Date: ${saveDate}`); + cy.log(`Editor: ${editor}`); + cy.log(`Character Count: ${characterCount}`); + cy.log(`Article Title: ${articleTitle}`); + cy.log(`Alias: ${alias}`); + cy.log(`Created Date: ${createdDate}`); + cy.log(`Modified Date: ${modifiedDate}`); - // Perform assertions - expect(attributes).to.have.property('editor_user_id'); - expect(versionData).to.have.property('title'); - expect(versionData).to.have.property('modified'); - expect(articleTitle).to.eq('automated test article'); - }); + // Perform assertions + expect(attributes).to.have.property('editor_user_id'); + expect(versionData).to.have.property('title'); + expect(versionData).to.have.property('modified'); + expect(articleTitle).to.eq('automated test article'); + }); - // Check the total pages from metadata - const totalPages = response.body.meta['total-pages']; - expect(totalPages).to.eq(1); - cy.log(`Total Pages: ${totalPages}`); - }); - }); + // Check the total pages from metadata + const totalPages = response.body.meta['total-pages']; + expect(totalPages).to.eq(1); + cy.log(`Total Pages: ${totalPages}`); + }); + }); }); From 8f2d48405fbf46462734a93a9be5eb8a09184029 Mon Sep 17 00:00:00 2001 From: alikon Date: Wed, 25 Dec 2024 12:32:56 +0100 Subject: [PATCH 3/4] Use object destructuring prefer-destructuring --- tests/System/integration/api/com_contenthistory/Banner.cy.js | 2 +- tests/System/integration/api/com_contenthistory/Contact.cy.js | 2 +- tests/System/integration/api/com_contenthistory/Content.cy.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/System/integration/api/com_contenthistory/Banner.cy.js b/tests/System/integration/api/com_contenthistory/Banner.cy.js index 07f8217f62984..2f5dde9ff1594 100644 --- a/tests/System/integration/api/com_contenthistory/Banner.cy.js +++ b/tests/System/integration/api/com_contenthistory/Banner.cy.js @@ -24,7 +24,7 @@ describe('Test that contenthistory for banners API endpoint', () => { expect(response.status).to.eq(200); // Extract the `data` array - const historyEntries = response.body.data; + const { data: historyEntries } = response.body; cy.log(`History Entries: ${historyEntries.length}`); // Iterate through each history entry diff --git a/tests/System/integration/api/com_contenthistory/Contact.cy.js b/tests/System/integration/api/com_contenthistory/Contact.cy.js index 908ac6cc7f388..238f16e42d773 100644 --- a/tests/System/integration/api/com_contenthistory/Contact.cy.js +++ b/tests/System/integration/api/com_contenthistory/Contact.cy.js @@ -19,7 +19,7 @@ describe('Test that contenthistory for contact API endpoint', () => { expect(response.status).to.eq(200); // Extract the `data` array - const historyEntries = response.body.data; + const { data: historyEntries } = response.body; cy.log(`History Entries: ${historyEntries.length}`); // Iterate through each history entry diff --git a/tests/System/integration/api/com_contenthistory/Content.cy.js b/tests/System/integration/api/com_contenthistory/Content.cy.js index 2be213b0e00ba..a156a21ca780c 100644 --- a/tests/System/integration/api/com_contenthistory/Content.cy.js +++ b/tests/System/integration/api/com_contenthistory/Content.cy.js @@ -29,7 +29,7 @@ describe('Test that contenthistory for content API endpoint', () => { expect(response.status).to.eq(200); // Extract the `data` array - const historyEntries = response.body.data; + const { data: historyEntries } = response.body; cy.log(`History Entries: ${historyEntries.length}`); // Iterate through each history entry From 5330e416d8e463cf79d9b62d6dd112a0553c350e Mon Sep 17 00:00:00 2001 From: alikon Date: Wed, 25 Dec 2024 13:17:48 +0100 Subject: [PATCH 4/4] using object destructuring --- .../System/integration/api/com_contenthistory/Banner.cy.js | 6 +++--- .../System/integration/api/com_contenthistory/Contact.cy.js | 6 +++--- .../System/integration/api/com_contenthistory/Content.cy.js | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/System/integration/api/com_contenthistory/Banner.cy.js b/tests/System/integration/api/com_contenthistory/Banner.cy.js index 2f5dde9ff1594..0b887006c25c4 100644 --- a/tests/System/integration/api/com_contenthistory/Banner.cy.js +++ b/tests/System/integration/api/com_contenthistory/Banner.cy.js @@ -29,18 +29,18 @@ describe('Test that contenthistory for banners API endpoint', () => { // Iterate through each history entry historyEntries.forEach((entry) => { - const attributes = entry.attributes; + const { attributes } = entry; // Access top-level attributes const historyId = entry.id; const saveDate = attributes.save_date; - const editor = attributes.editor; + const { editor } = attributes; const characterCount = attributes.character_count; // Access nested `version_data` const versionData = attributes.version_data; const bannerName = versionData.name; - const alias = versionData.alias; + const { alias } = versionData; const createdDate = versionData.created; const modifiedDate = versionData.modified; diff --git a/tests/System/integration/api/com_contenthistory/Contact.cy.js b/tests/System/integration/api/com_contenthistory/Contact.cy.js index 238f16e42d773..3815e09ad06a9 100644 --- a/tests/System/integration/api/com_contenthistory/Contact.cy.js +++ b/tests/System/integration/api/com_contenthistory/Contact.cy.js @@ -24,18 +24,18 @@ describe('Test that contenthistory for contact API endpoint', () => { // Iterate through each history entry historyEntries.forEach((entry) => { - const attributes = entry.attributes; + const { attributes } = entry; // Access top-level attributes const historyId = entry.id; const saveDate = attributes.save_date; - const editor = attributes.editor; + const { editor } = attributes; const characterCount = attributes.character_count; // Access nested `version_data` const versionData = attributes.version_data; const contactName = versionData.name; - const alias = versionData.alias; + const { alias } = versionData; const createdDate = versionData.created; const modifiedDate = versionData.modified; diff --git a/tests/System/integration/api/com_contenthistory/Content.cy.js b/tests/System/integration/api/com_contenthistory/Content.cy.js index a156a21ca780c..c22a5b25954cf 100644 --- a/tests/System/integration/api/com_contenthistory/Content.cy.js +++ b/tests/System/integration/api/com_contenthistory/Content.cy.js @@ -34,18 +34,18 @@ describe('Test that contenthistory for content API endpoint', () => { // Iterate through each history entry historyEntries.forEach((entry) => { - const attributes = entry.attributes; + const { attributes } = entry; // Access top-level attributes const historyId = entry.id; const saveDate = attributes.save_date; - const editor = attributes.editor; + const { editor } = attributes; const characterCount = attributes.character_count; // Access nested `version_data` const versionData = attributes.version_data; const articleTitle = versionData.title; - const alias = versionData.alias; + const { alias } = versionData; const createdDate = versionData.created; const modifiedDate = versionData.modified;