diff --git a/page-objects/pages/NWSAddEditNewsPage.js b/page-objects/pages/NWSAddEditNewsPage.js index 66285771..3e9afe55 100644 --- a/page-objects/pages/NWSAddEditNewsPage.js +++ b/page-objects/pages/NWSAddEditNewsPage.js @@ -1,54 +1,54 @@ /*[url/news/[newsId]/edit] | [url/news/[newsId]/new]*/ 'use strict'; const elementHelpers = require('../../runtime/helpers/elementHelpers'); -const newsListPage = require('./NWSNewsListPage'); +const newsListPage= require('./NWSNewsListPage'); const waitHelpers = require('../../runtime/helpers/waitHelpers'); const submitNewsBtn = '[data-testid="btn_news_submit"]'; const addNewsBtn = "[data-testid='create-news-btn']"; const titleField = 'input.h1'; const contentField = '.ck-editor [contenteditable="true"]'; -const dateTimeSelector = '[data-testid="news_date"] input'; +const dateTimeSelector = '[data-testid="news_date"] input' -async function goToNewNews() { - await newsListPage.goToNews(); - await clickCreateNewsButton(); +async function goToNewNews () { + await newsListPage.goToNews(); + await clickCreateNewsButton(); } -async function setNewsTitle(newsTitle) { - await waitHelpers.waitAndSetValue(titleField, newsTitle); +async function setNewsTitle (newsTitle) { + await waitHelpers.waitAndSetValue(titleField, newsTitle); } -async function setNewsContent(newsContent) { - await elementHelpers.click(contentField); - await waitHelpers.waitAndSetValue(contentField, newsContent, 1000); +async function setNewsContent (newsContent) { + await elementHelpers.click(contentField); + await waitHelpers.waitAndSetValue(contentField, newsContent, 1000); } -async function setNewsPublishDate(newsDate) { - await waitHelpers.waitAndSetValue(dateTimeSelector, newsDate); +async function setNewsPublishDate (newsDate) { + await waitHelpers.waitAndSetValue(dateTimeSelector, newsDate); } -async function setNewsPublishTime(newsTime) { - await waitHelpers.waitAndSetValue(dateTimeSelector, newsTime); +async function setNewsPublishTime (newsTime) { + await waitHelpers.waitAndSetValue(dateTimeSelector, newsTime); } -async function clickCreateNewsButton() { - await elementHelpers.clickAndWait(addNewsBtn); +async function clickCreateNewsButton () { + await elementHelpers.clickAndWait(addNewsBtn); } -async function clickCreateNewsConfirmationButton() { - await elementHelpers.clickAndWait(submitNewsBtn); +async function clickCreateNewsConfirmationButton () { + await elementHelpers.clickAndWait(submitNewsBtn); } -async function createNews({ newsTitle, newsContent, date, time }) { - await goToNewNews(); - if (newsTitle) await setNewsTitle(newsTitle); - if (newsContent) await setNewsContent(newsContent); - if (date) await setNewsPublishDate(date); - if (time) await setNewsPublishTime(time); - await clickCreateNewsConfirmationButton(); +async function createNews ({ newsTitle, newsContent, date, time}) { + await goToNewNews(); + if (newsTitle) await setNewsTitle(newsTitle); + if (newsContent) await setNewsContent(newsContent); + if (date) await setNewsPublishDate(date); + if (time) await setNewsPublishTime(time); + await clickCreateNewsConfirmationButton(); } module.exports = { - goToNewNews, - createNews, -}; + goToNewNews, + createNews, +} diff --git a/runtime/helpers/waitHelpers.js b/runtime/helpers/waitHelpers.js index 41fbcd43..329cc787 100644 --- a/runtime/helpers/waitHelpers.js +++ b/runtime/helpers/waitHelpers.js @@ -19,8 +19,8 @@ const titleTimeout = 30000; const shortInterval = 50; const mediumInterval = 100; const pageLoadLegacy = "//dl[@role='navigation']"; -const pageLoaded = 'div.topbar'; -const pageNotLoaded = 'div#nuxt-loading'; +const pageLoaded = "div.topbar"; +const pageNotLoaded = "div#nuxt-loading"; async function waitUntilElementIsPresent(selectorOrElement, timeout = elementIsPresentTimeout) { let element = await sharedHelpers.getElement(selectorOrElement); @@ -203,11 +203,11 @@ async function waitUntilNuxtClientLoads(timeout = pageLoadingTimeout) { await waitUntilPageLoads(); while (!nuxtPageLoad) { await waitUntilElementIsNotPresent(pageNotLoaded); - if (await waitUntilElementIsPresent(pageLoaded)) { + if (await waitUntilElementIsPresent(pageLoaded)){ nuxtPageLoad = true; - } else { + }else { await driver.refresh(); - if (await waitUntilElementIsPresent(pageLoaded)) { + if(await waitUntilElementIsPresent(pageLoaded)){ nuxtPageLoad = true; } }