Skip to content

Commit

Permalink
WEBUI-1433: Addons: Spreadsheet integration and testing node18
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuljain-dev committed Jan 17, 2024
1 parent 9640b8e commit 149ce42
Show file tree
Hide file tree
Showing 12 changed files with 33 additions and 30 deletions.
7 changes: 0 additions & 7 deletions addons/nuxeo-spreadsheet/ftest/.eslintrc

This file was deleted.

File renamed without changes.
4 changes: 3 additions & 1 deletion packages/nuxeo-web-ui-ftest/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
"users": true,
"groups": true,
"browser": true,
"moment": true
"moment": true,
"assert": true,
"expect": true
},
"overrides": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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`);
}
});

Expand Down
13 changes: 8 additions & 5 deletions packages/nuxeo-web-ui-ftest/features/step_definitions/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,26 +17,29 @@ 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,
firstName: 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');
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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() {
Expand All @@ -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();
});

Expand Down Expand Up @@ -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);
Expand Down
5 changes: 3 additions & 2 deletions packages/nuxeo-web-ui-ftest/pages/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
})();
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nuxeo-web-ui-ftest/pages/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxeo-web-ui-ftest/pages/ui/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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}`);
Expand Down

0 comments on commit 149ce42

Please sign in to comment.