From 0b6294560b4d0fdf28a6c71338f70761b6140fdd Mon Sep 17 00:00:00 2001 From: Louis TOUSSAINT Date: Tue, 20 Aug 2024 02:08:37 +0200 Subject: [PATCH] Tests(DPxAI): upload test for quest02 first-wink --- dom/first-wink_test.js | 45 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 dom/first-wink_test.js diff --git a/dom/first-wink_test.js b/dom/first-wink_test.js new file mode 100644 index 000000000..1a72cb4fb --- /dev/null +++ b/dom/first-wink_test.js @@ -0,0 +1,45 @@ +export const tests = [] + +tests.push(async ({ eq, page }) => { + // check the initial class name of the eye left + const eyeLeft = await page.$eval('#eye-left', (node) => node.className) + eq(eyeLeft, 'eye') + + // check that the text of the button says 'close' + const buttonText = await page.$eval('button', (node) => node.textContent) + eq(buttonText, 'Click to close the left eye') +}) + +tests.push(async ({ eq, page }) => { + // click the button to close the left eye + const button = await page.$('button') + button.click() + + // check that the class has been added + await page.waitForSelector('#eye-left.eye.eye-closed', { timeout: 150 }) + + // check the background color has changed + await eq.$('#eye-left.eye.eye-closed', { + style: { backgroundColor: 'black' }, + }) + + // check that the text of the button changed to 'open' + await eq.$('button', { textContent: 'Click to open the left eye' }) +}) + +tests.push(async ({ eq, page }) => { + // click the button a second time to open the left eye + const button = await page.$('button') + button.click() + + // check that the class has been removed + await page.waitForSelector('#eye-left.eye:not(.eye-closed)', { timeout: 150 }) + + // check the background color has changed + await eq.$('#eye-left.eye:not(.eye-closed)', { + style: { backgroundColor: 'red' }, + }) + + // check that the text of the button changed to 'close' + await eq.$('button', { textContent: 'Click to close the left eye' }) +}) \ No newline at end of file