Skip to content

Commit

Permalink
NXP-32354: Fix functional test cicd failure in retention repo node18
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuljain-dev committed Mar 4, 2024
1 parent 886fc36 commit 61eae01
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 38 deletions.
1 change: 1 addition & 0 deletions ci/Jenkinsfiles/build.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ pipeline {
container('playwright') {
nxWithGitHubStatus(context: 'utests/frontend') {
dir('nuxeo-retention-web') {
sh 'npm install'
sh 'npm install --no-save playwright'
sh 'npx playwright install --with-deps'
sh 'npm run test'
Expand Down
93 changes: 58 additions & 35 deletions nuxeo-retention-web/ftest/features/step_definitions/retention.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { When, Then } from '@cucumber/cucumber';

When('I set a legal hold on the document with description {string}', async function (desc) {
await this.ui.browser.clickDocumentActionMenu('nuxeo-hold-toggle-button:not([hold])');
const dialog = await this.ui.browser.el.element('nuxeo-hold-toggle-button #dialog');
const browser = await this.ui.browser;
await browser.clickDocumentActionMenu('nuxeo-hold-toggle-button:not([hold])');
const dialog = await browser.el.element('nuxeo-hold-toggle-button #dialog');
await dialog.waitForVisible();
const descInput = await dialog.element('nuxeo-textarea[name="description"]');
await fixtures.layouts.setValue(descInput, desc);
Expand All @@ -12,53 +14,61 @@ When('I set a legal hold on the document with description {string}', async funct
});

When('I unset the legal hold on the document', async function () {
await this.ui.browser.clickDocumentActionMenu('nuxeo-hold-toggle-button[hold]');
const browser = await this.ui.browser;
await browser.clickDocumentActionMenu('nuxeo-hold-toggle-button[hold]');
});

Then('I see the document is under legal hold', async function () {
const documentPage = await this.ui.browser.documentPage(this.doc.type);
const browser = await this.ui.browser;
const documentPage = await browser.documentPage(this.doc.type);
const infoBar = await documentPage.infoBar;
await infoBar.waitForVisible();
const ele = await infoBar.element('#retentionInfoBar #legalHold');
await ele.waitForVisible();
});

Then('I see the document is not under legal hold', async function () {
const page = await this.ui.browser.documentPage(this.doc.type);
const browser = await this.ui.browser;
const page = await browser.documentPage(this.doc.type);
const infoBar = await page.infoBar;
await infoBar.waitForExist('#legalHold', false);
});

Then('I can unset the legal hold on the document', async function () {
const ele = await this.ui.browser.el;
const browser = await this.ui.browser;
const ele = await browser.el;
await ele.waitForExist('nuxeo-hold-toggle-button[hold]');
});

Then('I cannot set the legal hold on the document', async function () {
const ele = await this.ui.browser.el;
const browser = await this.ui.browser;
const ele = await browser.el;
await ele.waitForExist('nuxeo-hold-toggle-button', false);
});

Then('I cannot unset the legal hold on the document', async function () {
const ele = await this.ui.browser.el;
const browser = await this.ui.browser;
const ele = await browser.el;
await ele.waitForExist('nuxeo-hold-toggle-button[hold]', false);
});

Then('I cannot edit main blob', async function () {
const page = await this.ui.browser.documentPage(this.doc.type);
const browser = await this.ui.browser;
const page = await browser.documentPage(this.doc.type);
await page.el.waitForExist('nuxeo-replace-blob-button', false);
await page.el.waitForExist('nuxeo-delete-blob-button', false);
});

Then('I can edit main blob', async function () {
const page = await this.ui.browser.documentPage(this.doc.type);
const browser = await this.ui.browser;
const page = await browser.documentPage(this.doc.type);
await page.el.waitForExist('nuxeo-replace-blob-button');
await page.el.waitForExist('nuxeo-delete-blob-button');
});

Then('I can see the retention menu', async function () {
const drawer = await this.ui.drawer;
const ele = await drawer.el.$('nuxeo-menu-icon[name="retention"]');
const ele = await drawer.el.element('nuxeo-menu-icon[name="retention"]');
await ele.waitForVisible;
});

Expand All @@ -68,7 +78,8 @@ Then('I cannot see the retention menu', async function () {
});

When('I go to the retention event', async function () {
const menu = await this.ui.drawer.open('retention');
const drawer = await this.ui.drawer;
const menu = await drawer.open('retention');
try {
// XXX click sometimes hits nuxeo-browser, resulting in an error
const menuElement = await menu.element('nuxeo-menu-item[name="events"]');
Expand All @@ -81,7 +92,8 @@ When('I go to the retention event', async function () {
});

When('I go to the retention rules location', async function () {
const menu = await this.ui.drawer.open('retention');
const drawer = await this.ui.drawer;
const menu = await drawer.open('retention');
try {
// XXX click sometimes hits nuxeo-browser, resulting in an error
const menuElement = await menu.element('nuxeo-menu-item[name="rules"]');
Expand All @@ -94,7 +106,8 @@ When('I go to the retention rules location', async function () {
});

When('I navigate to Retention Search page', async function () {
const menu = await this.ui.drawer.open('retention');
const drawer = await this.ui.drawer;
const menu = await drawer.open('retention');
try {
// XXX click sometimes hits nuxeo-browser, resulting in an error
const menuElement = await menu.element('nuxeo-menu-item[name="search"]');
Expand All @@ -106,8 +119,9 @@ When('I navigate to Retention Search page', async function () {
});

Then('I attach the {string} rule to the document', async function (ruleName) {
await this.ui.browser.clickDocumentActionMenu('nuxeo-attach-rule-button');
const dialog = await this.ui.browser.el.element('nuxeo-attach-rule-button #dialog');
const browser = await this.ui.browser;
await browser.clickDocumentActionMenu('nuxeo-attach-rule-button');
const dialog = await browser.el.element('nuxeo-attach-rule-button #dialog');
await dialog.waitForVisible();
const select = await dialog.element('nuxeo-document-suggestion');
await fixtures.layouts.setValue(select, ruleName);
Expand All @@ -118,15 +132,17 @@ Then('I attach the {string} rule to the document', async function (ruleName) {
});

Then('I see the document is under retention', async function () {
const documentPage = await this.ui.browser.documentPage(this.doc.type);
const browser = await this.ui.browser;
const documentPage = await browser.documentPage(this.doc.type);
const infoBar = await documentPage.infoBar;
await infoBar.waitForVisible();
const ele = await infoBar.element('#retentionInfoBar #retention');
await ele.waitForVisible();
});

Then('I see the document is under retention for {int} days', async function (days) {
const documentPage = await this.ui.browser.documentPage(this.doc.type);
const browser = await this.ui.browser;
const documentPage = await browser.documentPage(this.doc.type);
const infoBar = await documentPage.infoBar;
await infoBar.waitForVisible();
const ele = await infoBar.element('#retentionInfoBar #retention');
Expand All @@ -137,15 +153,17 @@ Then('I see the document is under retention for {int} days', async function (day
});

Then('I see the document is under indeterminate retention', async function () {
const documentPage = await this.ui.browser.documentPage(this.doc.type);
const browser = await this.ui.browser;
const documentPage = await browser.documentPage(this.doc.type);
const infoBar = await documentPage.infoBar;
await infoBar.waitForVisible();
const ele = await infoBar.element('#retentionInfoBar #indeterminateRetention');
await ele.waitForVisible();
});

Then('I cannot see the trash button', async function () {
const trashButton = await this.ui.browser.trashDocumentButton;
const browser = await this.ui.browser;
const trashButton = await browser.trashDocumentButton;
const isButtonVisible = await trashButton.isVisible();
isButtonVisible.should.be.equals(false);
});
Expand All @@ -159,7 +177,8 @@ When('I have a "ContractEnd" retention event', async () => {
});

When('I fire the {string} retention event with {string} input', async function (eventName, eventInput) {
const evtsElement = await this.ui.el.element('nuxeo-retention-events');
const ui = await this.ui;
const evtsElement = await ui.el.element('nuxeo-retention-events');
await evtsElement.waitForVisible();
const eventSelectElt = await evtsElement.element('nuxeo-directory-suggestion[name="event"]');
await eventSelectElt.waitForVisible();
Expand All @@ -173,56 +192,60 @@ When('I fire the {string} retention event with {string} input', async function (
});

When('I search for documents Under legal hold', async function () {
const ele = await this.ui.el.element('nuxeo-search-page#retentionSearch');
const ui = await this.ui;
const ele = await ui.el.element('nuxeo-search-page#retentionSearch');
await ele.waitForVisible();
const searchPage = await this.ui.el.element('nuxeo-search-page#retentionSearch');
const searchPage = await ui.el.element('nuxeo-search-page#retentionSearch');
const filterBtn = await searchPage.element('nuxeo-retention-search-results nuxeo-quick-filters');
await filterBtn.waitForVisible();
await filterBtn.click();
});

When('I search for documents with Retention Rule {string}', async function (retentionRule) {
const searchPage = await this.ui.el.element('nuxeo-search-page#retentionSearch');
const ui = await this.ui;
const searchPage = await ui.el.element('nuxeo-search-page#retentionSearch');
await searchPage.waitForVisible();
const rulesSelectElt = await searchPage.element('nuxeo-dropdown-aggregation');
await rulesSelectElt.waitForVisible();
await fixtures.layouts.setValue(rulesSelectElt, retentionRule);
});

When('I clear the search filters', async function () {
const ele = await this.ui.el.$('nuxeo-search-page#retentionSearch');
await ele.waitForVisible();
const searchPage = await this.ui.el.element('nuxeo-search-page#retentionSearch');
const ui = await this.ui;
const searchPage = await ui.el.element('nuxeo-search-page#retentionSearch');
const clearBtn = await searchPage.element('div.buttons paper-button');
await clearBtn.click();
});

Then('I can see {int} document in search results', async function (results) {
const searchPage = await this.ui.el.element('nuxeo-search-page#retentionSearch');
await driver.pause(2000);
const ui = await this.ui;
const searchPage = await ui.el.element('nuxeo-search-page#retentionSearch');
await searchPage.waitForVisible();
const ele = await searchPage.element('nuxeo-retention-search-results span.resultsCount');
if (results === 0) {
const ele = await searchPage.element('nuxeo-retention-search-results span.resultsCount');
return !ele.isVisible();
}
const ele = await searchPage.element('nuxeo-retention-search-results span.resultsCount');
const text = await ele.getText();
if (text !== `${results} result(s)`) {
throw Error(`Expected count of ${results} but found ${text}`);
throw new Error(`Expected count of ${results} but found ${text}`);
}
return true;
});

Then('I can see the extend retention action', async function () {
await this.ui.browser.clickDocumentActionMenu('nuxeo-retain-button');
const dialog = await this.ui.browser.el.element('nuxeo-retain-button #dialog');
const browser = await this.ui.browser;
await browser.clickDocumentActionMenu('nuxeo-retain-button');
const dialog = await browser.el.element('nuxeo-retain-button #dialog');
await dialog.waitForVisible();
const button = await dialog.element('paper-button[name = "cancel"]');
await button.click();
});

Then('I set the retention to expire in {int} days', async function (days) {
await this.ui.browser.clickDocumentActionMenu('nuxeo-retain-button');
const dialog = await this.ui.browser.el.element('nuxeo-retain-button #dialog');
const browser = await this.ui.browser;
await browser.clickDocumentActionMenu('nuxeo-retain-button');
const dialog = await browser.el.element('nuxeo-retain-button #dialog');
await dialog.waitForVisible();
const dateInput = await dialog.element('#picker');
const futureDate = await moment().add(days, 'days').format(global.dateFormat);
Expand Down
4 changes: 1 addition & 3 deletions nuxeo-retention-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"author": "Nuxeo",
"license": "Apache-2.0",
"devDependencies": {
"@cucumber/cucumber": "^7.0.0",
"@esm-bundle/chai": "^4.3.4",
"@nuxeo/moment": "^2.24.0-nx.0",
"@nuxeo/nuxeo-web-ui-ftest": "3.0.27-rc.0",
Expand All @@ -29,8 +28,7 @@
"rollup-plugin-copy": "^3.3.0",
"rollup-plugin-minify-html-literals": "^1.2.5",
"rollup-plugin-terser": "^7.0.2",
"sinon": "^17.0.1",
"sinon-chai": "^3.7.0"
"sinon": "^17.0.1"
},
"dependencies": {
"@nuxeo/nuxeo-elements": "~3.0.2-rc.0",
Expand Down

0 comments on commit 61eae01

Please sign in to comment.