From 113176f6c72840b0de5efd1802f7e3dc38585c47 Mon Sep 17 00:00:00 2001 From: oumaimafisaoui Date: Wed, 17 Jul 2024 21:26:44 +0100 Subject: [PATCH] tests(DPxAI): duplicated the test for embedded organs --- dom/embedded-organs_test.js | 90 +++++++++++++++++++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 dom/embedded-organs_test.js diff --git a/dom/embedded-organs_test.js b/dom/embedded-organs_test.js new file mode 100644 index 000000000..c92a9ecb7 --- /dev/null +++ b/dom/embedded-organs_test.js @@ -0,0 +1,90 @@ +export const tests = [] + +tests.push(async ({ page, eq }) => { + // check that the HTML structure is correct & elements are nested properly + const elements = await page.$$eval('body', (nodes) => { + const toNode = (el) => { + const node = {} + node.tag = el.tagName.toLowerCase() + node.id = el.id + if (el.children.length) { + node.children = [...el.children].map(toNode) + } + return node + } + return [...nodes[0].children].map(toNode) + }) + eq(expectedStructure, elements) +}) + +tests.push(async ({ page, eq }) => { + // check the section selector style has been updated properly + eq.css('section', { + display: 'flex', + justifyContent: 'center', + }) +}) + +tests.push(async ({ page, eq }) => { + // check if the provided CSS has been correctly copy pasted + eq.css('div, p', { + border: '1px solid black', + padding: '10px', + margin: '0px', + borderRadius: '30px', + }) + + eq.css('#face', { alignItems: 'center' }) + + eq.css('#eyes', { + display: 'flex', + backgroundColor: 'yellow', + justifyContent: 'space-between', + alignItems: 'center', + borderRadius: '50px', + width: '200px', + }) + + eq.css('#torso', { + width: '200px', + backgroundColor: 'violet', + }) +}) + +const expectedStructure = [ + { + tag: 'section', + + id: 'face', + children: [ + { + tag: 'div', + + id: 'eyes', + children: [ + { tag: 'p', id: 'eye-left' }, + { tag: 'p', id: 'eye-right' }, + ], + }, + ], + }, + { + tag: 'section', + + id: 'upper-body', + children: [ + { tag: 'div', id: 'arm-left' }, + { tag: 'div', id: 'torso' }, + { tag: 'div', id: 'arm-right' }, + ], + }, + { + tag: 'section', + + id: 'lower-body', + children: [ + { tag: 'div', id: 'leg-left' }, + { tag: 'div', id: 'leg-right' }, + ], + }, +]