diff --git a/package.json b/package.json index 223c2b5a..e646628f 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,9 @@ "git add" ] }, + "jest": { + "setupFiles": ["./test/setup-jest.js"] + }, "keywords": [ "editor", "wysiwyg", diff --git a/test/ui-testing/publishButton.test.js b/test/ui-testing/publishButton.test.js index e52f7b7d..fc89f967 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'); +const puppeteer = require('puppeteer'); + beforeAll(async () => { + const browser = await puppeteer.launch(); + const page = await browser.newPage(); path = fs.realpathSync('file://../examples/index.html'); await page.goto('file://' + path, {waitUntil: 'domcontentloaded'}); + await page.waitForSelector('body'); + await page.addScriptTag({url: 'https://code.jquery.com/jquery-3.2.1.min.js'}); }); describe('Publish button', () => { - - test('something we are testing described here', () => { - - }); - + test('publish button gets enabled', async () => { + // Check initially that Publish button is disabled. + expect(await page.$('.ple-publish').getAttribute('disabled')).toBe(true); + // Add title. + page.$('.ple-module-title input').innerText.toBe('Title'); + page.type('.ple-module-title input', 'hello'); + // Check final state of Publish button. + expect(page.$('.ple-publish').getAttribute('disabled')).toBe(false); + }, timeout); });