From 149ce42e14ef40437fb3eb30203780a93dc00b56 Mon Sep 17 00:00:00 2001 From: rahuljain-dev Date: Mon, 15 Jan 2024 13:55:00 +0530 Subject: [PATCH] WEBUI-1433: Addons: Spreadsheet integration and testing node18 --- addons/nuxeo-spreadsheet/ftest/.eslintrc | 7 ------- .../features/spreadsheet.feature | 0 packages/nuxeo-web-ui-ftest/.eslintrc | 4 +++- .../features/step_definitions/browser.js | 2 +- .../features/step_definitions/login.js | 13 ++++++++----- .../features/step_definitions/search.js | 3 ++- .../features/step_definitions/spreadsheet.js | 6 +++--- packages/nuxeo-web-ui-ftest/pages/login.js | 5 +++-- .../nuxeo-web-ui-ftest}/pages/spreadsheet.js | 0 packages/nuxeo-web-ui-ftest/pages/ui.js | 2 +- packages/nuxeo-web-ui-ftest/pages/ui/browser.js | 4 ++-- .../pages/ui/browser/document_publications.js | 17 ++++++++++------- 12 files changed, 33 insertions(+), 30 deletions(-) delete mode 100644 addons/nuxeo-spreadsheet/ftest/.eslintrc rename {addons/nuxeo-spreadsheet/ftest => ftest}/features/spreadsheet.feature (100%) rename {addons/nuxeo-spreadsheet/ftest => packages/nuxeo-web-ui-ftest}/features/step_definitions/spreadsheet.js (94%) rename {addons/nuxeo-spreadsheet/ftest => packages/nuxeo-web-ui-ftest}/pages/spreadsheet.js (100%) diff --git a/addons/nuxeo-spreadsheet/ftest/.eslintrc b/addons/nuxeo-spreadsheet/ftest/.eslintrc deleted file mode 100644 index df77738a91..0000000000 --- a/addons/nuxeo-spreadsheet/ftest/.eslintrc +++ /dev/null @@ -1,7 +0,0 @@ -{ - "globals": { - "driver": true, - "assert": true, - "expect": true - } -} diff --git a/addons/nuxeo-spreadsheet/ftest/features/spreadsheet.feature b/ftest/features/spreadsheet.feature similarity index 100% rename from addons/nuxeo-spreadsheet/ftest/features/spreadsheet.feature rename to ftest/features/spreadsheet.feature diff --git a/packages/nuxeo-web-ui-ftest/.eslintrc b/packages/nuxeo-web-ui-ftest/.eslintrc index df3fc81d35..c6f9a64870 100644 --- a/packages/nuxeo-web-ui-ftest/.eslintrc +++ b/packages/nuxeo-web-ui-ftest/.eslintrc @@ -11,7 +11,9 @@ "users": true, "groups": true, "browser": true, - "moment": true + "moment": true, + "assert": true, + "expect": true }, "overrides": [ { diff --git a/packages/nuxeo-web-ui-ftest/features/step_definitions/browser.js b/packages/nuxeo-web-ui-ftest/features/step_definitions/browser.js index e6bd6d4506..921a4c586b 100644 --- a/packages/nuxeo-web-ui-ftest/features/step_definitions/browser.js +++ b/packages/nuxeo-web-ui-ftest/features/step_definitions/browser.js @@ -159,7 +159,7 @@ Then('I can see the {string} child document is at position {int}', async functio await browser.waitForVisible(); const childIndex = await browser.indexOfChild(title); if (childIndex !== pos - 1) { - throw Error(`${childIndex} child document not present at expected position`); + throw Error(`${title} child document not present at expected position`); } }); diff --git a/packages/nuxeo-web-ui-ftest/features/step_definitions/login.js b/packages/nuxeo-web-ui-ftest/features/step_definitions/login.js index 6eab5f4826..e9cdeac68a 100644 --- a/packages/nuxeo-web-ui-ftest/features/step_definitions/login.js +++ b/packages/nuxeo-web-ui-ftest/features/step_definitions/login.js @@ -17,8 +17,9 @@ Given('user {string} exists in group {string}', async (username, group) => { }); }); -Given('user {string} exists', (username) => - fixtures.users.create({ +Given('user {string} exists', async (username) => { + const users = await fixtures.users; + await users.create({ 'entity-type': 'user', properties: { username, @@ -26,17 +27,19 @@ Given('user {string} exists', (username) => email: `${username}@test.com`, password: fixtures.users.DEFAULT_PASSWORD, }, - }), -); + }); +}); When('I login as {string}', async function(username) { + await driver.pause(2000); const logIn = await Login.get(); await logIn.username(username); - const password = users[username]; + const password = await users[username]; await logIn.password(password); await logIn.submit(); this.username = username; this.ui = await UI.get(); + await driver.pause(2000); await this.ui.waitForVisible('nuxeo-page'); }); diff --git a/packages/nuxeo-web-ui-ftest/features/step_definitions/search.js b/packages/nuxeo-web-ui-ftest/features/step_definitions/search.js index 434bd1306a..79fda8ba92 100644 --- a/packages/nuxeo-web-ui-ftest/features/step_definitions/search.js +++ b/packages/nuxeo-web-ui-ftest/features/step_definitions/search.js @@ -230,7 +230,8 @@ Then(/^I share my "(.+)" search with (.+)/, async function(searchName, username) const createPermissionButton = await searchForm.permissionsView.createPermissionButton; await createPermissionButton.waitForVisible(); await createPermissionButton.click(); - const permissionVisible = await searchForm.permissionsView.permission('Read', username, 'permanent'); + const permissionView = await searchForm.permissionsView; + const permissionVisible = await permissionView.permission('Read', username, 'permanent'); const isVisible = await permissionVisible.waitForVisible(); isVisible.should.be.true; }); diff --git a/addons/nuxeo-spreadsheet/ftest/features/step_definitions/spreadsheet.js b/packages/nuxeo-web-ui-ftest/features/step_definitions/spreadsheet.js similarity index 94% rename from addons/nuxeo-spreadsheet/ftest/features/step_definitions/spreadsheet.js rename to packages/nuxeo-web-ui-ftest/features/step_definitions/spreadsheet.js index b41a7467e7..a211fe6ef8 100644 --- a/addons/nuxeo-spreadsheet/ftest/features/step_definitions/spreadsheet.js +++ b/packages/nuxeo-web-ui-ftest/features/step_definitions/spreadsheet.js @@ -1,4 +1,4 @@ -import { Then, When } from '@cucumber/cucumber'; +import { Then, When } from '../../node_modules/@cucumber/cucumber'; import Spreadsheet from '../../pages/spreadsheet'; When('I open the spreadsheet', async function() { @@ -11,7 +11,8 @@ When('I open the spreadsheet', async function() { await dialog.waitForVisible(); const iframe = await buttonEle.element('#iframe'); await iframe.waitForExist(); - await browser.switchToFrame(iframe); + const browserEle = await browser.el; + await browserEle.switchToFrame(iframe); this.spreadsheet = await new Spreadsheet(); }); @@ -63,7 +64,6 @@ When('I save the spreadsheet', async function() { When('I close the spreadsheet', async function() { const spreadsheet = await this.spreadsheet; - const browser = await this.ui.browser; if (spreadsheet) { await spreadsheet.close(); await browser.switchToFrame(null); diff --git a/packages/nuxeo-web-ui-ftest/pages/login.js b/packages/nuxeo-web-ui-ftest/pages/login.js index d08b9af216..e9846867bf 100644 --- a/packages/nuxeo-web-ui-ftest/pages/login.js +++ b/packages/nuxeo-web-ui-ftest/pages/login.js @@ -16,8 +16,9 @@ export default class Login { static get() { return (async () => { - const baseUrl = process.env.NUXEO_URL || ''; - await driver.url(baseUrl ? `${baseUrl}/logout` : 'logout'); + const baseUrl = (await process.env.NUXEO_URL) || ''; + await driver.pause(1000); + await browser.url(baseUrl ? `${baseUrl}/logout` : 'logout'); return new this(); })(); } diff --git a/addons/nuxeo-spreadsheet/ftest/pages/spreadsheet.js b/packages/nuxeo-web-ui-ftest/pages/spreadsheet.js similarity index 100% rename from addons/nuxeo-spreadsheet/ftest/pages/spreadsheet.js rename to packages/nuxeo-web-ui-ftest/pages/spreadsheet.js diff --git a/packages/nuxeo-web-ui-ftest/pages/ui.js b/packages/nuxeo-web-ui-ftest/pages/ui.js index 19549ee96d..d8661cfcd8 100644 --- a/packages/nuxeo-web-ui-ftest/pages/ui.js +++ b/packages/nuxeo-web-ui-ftest/pages/ui.js @@ -110,7 +110,7 @@ export default class UI extends BasePage { url(process.env.NUXEO_URL ? '' : 'ui'); if (!(await global.locale)) { await $('nuxeo-app:not([unresolved])').waitForVisible(); - const locale = await browser.execute(() => window.nuxeo.I18n.language || 'en'); + const locale = await browser.execute(async () => (await window.nuxeo.I18n.language) || 'en'); if (locale) { global.locale = locale; await moment.locale(global.locale); diff --git a/packages/nuxeo-web-ui-ftest/pages/ui/browser.js b/packages/nuxeo-web-ui-ftest/pages/ui/browser.js index 9155c65534..c20017e24d 100644 --- a/packages/nuxeo-web-ui-ftest/pages/ui/browser.js +++ b/packages/nuxeo-web-ui-ftest/pages/ui/browser.js @@ -287,11 +287,11 @@ export default class Browser extends BasePage { await this.waitForChildren(); const elementTitle = await browser .$$('nuxeo-data-table[name="table"] nuxeo-data-table-row:not([header])') - .map((img) => img.$('nuxeo-data-table-cell a.title').getText()); + .map(async (img) => img.$('nuxeo-data-table-cell a.title').getText()); let i; for (i = 0; i < elementTitle.length; i++) { - if (elementTitle[i].trim() === title) { + if ((await elementTitle[i].trim()) === title) { return i; } } diff --git a/packages/nuxeo-web-ui-ftest/pages/ui/browser/document_publications.js b/packages/nuxeo-web-ui-ftest/pages/ui/browser/document_publications.js index 64dda54fa2..3acee1a9c7 100644 --- a/packages/nuxeo-web-ui-ftest/pages/ui/browser/document_publications.js +++ b/packages/nuxeo-web-ui-ftest/pages/ui/browser/document_publications.js @@ -32,18 +32,21 @@ export default class DocumentPublications extends BasePage { for (let i = 0; i < rows.length; i++) { const row = rows[i]; if (row.isVisible('nuxeo-data-table-cell a.path')) { - const foundPath = await row.$('nuxeo-data-table-cell a.path').getText(); - const foundPathLowerCase = await foundPath.toLowerCase(); + const foundPathEle = await row.$('nuxeo-data-table-cell a.path'); + const foundPath = await foundPathEle.getText(); + const foundPathLowerCase = await foundPath.trim().toLowerCase(); if (foundPathLowerCase.indexOf(path.trim().toLowerCase()) !== 0) { index = -1; } - const foundRendition = await row.$('nuxeo-data-table-cell .rendition').getText(); + const foundRenditionEle = await row.$('nuxeo-data-table-cell .rendition'); + const foundRendition = await foundRenditionEle.getText(); const foundRenditionLowerCase = foundRendition.trim().toLowerCase(); if (foundRenditionLowerCase !== rendition.toLowerCase()) { index = -1; } - const foundVersion = await row.$('nuxeo-data-table-cell .version').getText(); - const foundVersionLowerCase = foundVersion.trim().toLowerCase(); + const foundVersionEle = await row.$('nuxeo-data-table-cell .version'); + const foundVersion = await foundVersionEle.getText(); + const foundVersionLowerCase = await foundVersion.trim().toLowerCase(); if (foundVersionLowerCase && version != null && foundVersion !== version.toLowerCase()) { index = -1; } @@ -60,8 +63,8 @@ export default class DocumentPublications extends BasePage { const pubRow = await this.getPublicationRow(path, rendition, version); if (pubRow) { await pubRow.waitForVisible('paper-button.republish'); - const xyz = await pubRow.element('paper-button.republish'); - await xyz.click(); + const pubRowEle = await pubRow.element('paper-button.republish'); + await pubRowEle.click(); await driver.alertAccept(); } else { throw new Error(`Could not find publication ${path} ${rendition} ${version}`);