From ca17c06ec025d84dfdd6c7f97a97e40fbf444149 Mon Sep 17 00:00:00 2001 From: narudesigns Date: Mon, 13 Dec 2021 14:57:59 +0100 Subject: [PATCH] got nodejs to recognise jquery command for publishButton jest test file --- test/ui-testing/publishButton.test.js | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/test/ui-testing/publishButton.test.js b/test/ui-testing/publishButton.test.js index e52f7b7d..4fff2e19 100644 --- a/test/ui-testing/publishButton.test.js +++ b/test/ui-testing/publishButton.test.js @@ -1,14 +1,24 @@ const timeout = process.env.SLOWMO ? 60000 : 10000; const fs = require('fs'); -beforeAll(async () => { - path = fs.realpathSync('file://../examples/index.html'); - await page.goto('file://' + path, {waitUntil: 'domcontentloaded'}); -}); describe('Publish button', () => { - - test('something we are testing described here', () => { + var $; + beforeAll(async () => { + path = fs.realpathSync('file://../examples/index.html'); + await page.goto('file://' + path, {waitUntil: 'domcontentloaded'}); + + const {JSDOM} = require("jsdom"); + const myJSDom = new JSDOM(fs.readFileSync(path)); + $ = require('jquery')(myJSDom.window); + }); + test('something we are testing described here', () => { + // Check initially that Publish button is disabled. + expect($('.ple-publish').prop('disabled')).toBe(true); + // Add title. + $('.ple-module-title input').val('A title'); + $('.ple-module-title input').keydown(); + // Check final state of Publish button. + expect($('.ple-publish').prop('disabled')).toBe(false); }); - -}); +}, timeout);