Skip to content

Commit

Permalink
WEBUI-1415: Update Functional Test Feature: Versions
Browse files Browse the repository at this point in the history
  • Loading branch information
rahuljain-dev committed Jan 3, 2024
1 parent e16986a commit 16e8f9a
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 107 deletions.
64 changes: 36 additions & 28 deletions packages/nuxeo-web-ui-ftest/features/step_definitions/document.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
/* eslint-disable no-await-in-loop */
/* eslint-disable no-undef */
import { Given, When, Then } from '../../node_modules/@cucumber/cucumber';
import { url } from '../../pages/helpers';

Expand Down Expand Up @@ -127,8 +126,8 @@ Then('I navigate to {string} child', async function(title) {
}
});

When(/^I start a (.+)$/, function(workflow) {
this.ui.browser.startWorkflow(workflow);
When(/^I start a (.+)$/, async function(workflow) {
await this.ui.browser.startWorkflow(workflow);
});

When(/^I click the process button$/, async function() {
Expand Down Expand Up @@ -174,15 +173,17 @@ Then(/^I can't edit the document metadata$/, function() {
this.ui.browser.editButton.waitForVisible(browser.options.waitforTimeout, true).should.be.true;
});

Then(/^I can edit the (.*) metadata$/, function(docType) {
const { browser } = this.ui;
browser.editButton.waitForVisible();
browser.editButton.click();
const form = browser.editForm(docType);
form.waitForVisible();
form.title = docType;
form.save();
driver.waitForExist('iron-overlay-backdrop', driver.options.waitForTimeout, true);
Then(/^I can edit the (.*) metadata$/, async function(docType) {
const browser = await this.ui.browser;
const browserEditButton = await browser.editButton;
await browserEditButton.waitForVisible();
await browserEditButton.click();
const form = await browser.editForm(docType);
await form.waitForVisible();
const inputElement = await form.el.element('.input-element input');
await fixtures.layouts.setValue(inputElement, docType);
await form.save();
await driver.waitForExist('iron-overlay-backdrop', driver.options.waitForTimeout, true);
});

Then(/^I can edit the following properties in the (.+) metadata:$/, async function(docType, table) {
Expand Down Expand Up @@ -289,32 +290,39 @@ Then(/^I can see a process is running in the document$/, async function() {
await documentPageInfo.$('[name="process"]').waitForVisible();
});

Then(/^I can see a process is not running in the document$/, function() {
const documentPage = this.ui.browser.documentPage();
Then(/^I can see a process is not running in the document$/, async function() {
const documentPage = await this.ui.browser.documentPage();
// check info bar in the document is not visible
documentPage.infoBar.isVisible().should.be.false;
const infoBar = await documentPage.infoBar;
const infoBarVisible = await infoBar.isVisible();
infoBarVisible.should.be.false;
});

Then(/^I cannot start a workflow$/, function() {
this.ui.browser.startWorkflowButton.isExisting().should.be.false;
Then(/^I cannot start a workflow$/, async function() {
const button = await this.ui.browser.startWorkflowButton;
const isButtonExisting = await button.isExisting();
isButtonExisting.should.be.false;
});

Then(/^I can abandon the workflow$/, function() {
const { abandonWorkflowButton } = this.ui.browser.documentPage();
abandonWorkflowButton.waitForVisible();
abandonWorkflowButton.click();
driver.alertAccept();
const documentPage = this.ui.browser.documentPage();
Then(/^I can abandon the workflow$/, async function() {
const documentPage = await this.ui.browser.documentPage();
const abandonWorkflowButton = await documentPage.abandonWorkflowButton;
await abandonWorkflowButton.waitForVisible();
await abandonWorkflowButton.click();
await driver.alertAccept();
// check info bar in the document is not visible
documentPage.infoBar.waitForVisible(browser.options.waitforTimeout, true);
const infoBar = await documentPage.infoBar;
await infoBar.waitForVisible(browser.options.waitforTimeout, true);
// assert that info bar displays a task is running
documentPage.taskInfo.waitForVisible(browser.options.waitforTimeout, true);
const taskInfo = await documentPage.taskInfo;
await taskInfo.waitForVisible(browser.options.waitforTimeout, true);
// assert that document info says a process is running
documentPage.info.waitForVisible();
documentPage.info.waitForVisible('[name="process"]', browser.options.waitforTimeout, true);
const docPageInfo = await documentPage.info;
await docPageInfo.waitForVisible();
await docPageInfo.waitForVisible('[name="process"]', browser.options.waitforTimeout, true);

// In order to avoid errors when performing the teardown
fixtures.workflows.removeInstance(this.workflowInstance.id);
await fixtures.workflows.removeInstance(this.workflowInstance.id);
});

Then(/^I can see the document is a publication$/, async function() {
Expand Down
8 changes: 4 additions & 4 deletions packages/nuxeo-web-ui-ftest/features/step_definitions/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ When('I click the {string} button', async function(button) {
When('I select {string} from the View menu', function(option) {
return this.ui.view(option);
});
When('I reload the page', function() {
When('I reload the page', async function() {
// XXX temporary fix for async issue with activity feed; will be fixed when NXP-21771 is tackled
driver.pause(3000);
this.ui.reload();
$('#logo').waitForVisible();
await driver.pause(3000);
await this.ui.reload();
await $('#logo').waitForVisible();
});
Then('I can see {string} in the Activity feed', async function(activity) {
// XXX temporary fix for async issue with activity feed; will be fixed when NXP-21771 is tackled
Expand Down
152 changes: 87 additions & 65 deletions packages/nuxeo-web-ui-ftest/features/step_definitions/versions.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { When } from '../../node_modules/@cucumber/cucumber';

When(/^I can see the version info bar with text "(.*)"$/, function(text) {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versionInfoBar.waitForVisible();
page.versionInfoBar.getText().should.equal(text);
When(/^I can see the version info bar with text "(.*)"$/, async function(text) {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
const versionInfoBar = await page.versionInfoBar;
await versionInfoBar.waitForVisible();
const versionInfoBarText = await versionInfoBar.getText();
versionInfoBarText.should.equal(text);
});

When(/^The document is unversioned$/, async function() {
const page = this.ui.browser.documentPage(this.doc.type);
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
await page.versions.waitForVisible();
const createVersionBtn = await page.versions.createVersionButton;
await createVersionBtn.waitForVisible();
});

When(/^I click the Create Version button$/, async function() {
const page = this.ui.browser.documentPage(this.doc.type);
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
await page.versions.waitForVisible();
const createVersionBtn = await page.versions.createVersionButton;
Expand All @@ -25,7 +27,7 @@ When(/^I click the Create Version button$/, async function() {
});

When(/^The create version dialog appears$/, async function() {
const page = this.ui.browser.documentPage(this.doc.type);
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
await page.versions.waitForVisible();
const pageVersionDialog = await page.versions.dialog;
Expand All @@ -34,17 +36,22 @@ When(/^The create version dialog appears$/, async function() {
await pageVersionDialog.waitForVisible('paper-button[dialog-confirm]');
});

When(/^Version options (\d+)\.(\d+) and (\d+)\.(\d+) are presented$/, function(v1, v2, v3, v4) {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versions.waitForVisible();
page.versions.dialog.waitForVisible();
page.versions.dialogNextMinor.getText().should.equal(`${v1}.${v2}`);
page.versions.dialogNextMajor.getText().should.equal(`${v3}.${v4}`);
When(/^Version options (\d+)\.(\d+) and (\d+)\.(\d+) are presented$/, async function(v1, v2, v3, v4) {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
await page.versions.waitForVisible();
const pageVersionDialog = await page.versions.dialog;
await pageVersionDialog.waitForVisible();
const dialogMinor = await page.versions.dialogNextMinor;
const dialogMinorText = await dialogMinor.getText();
dialogMinorText.should.equal(`${v1}.${v2}`);
const dialogMajor = await page.versions.dialogNextMajor;
const dialogMajorText = await dialogMajor.getText();
dialogMajorText.should.equal(`${v3}.${v4}`);
});

When(/^I create a (major|minor) version$/, async function(versionType) {
const page = this.ui.browser.documentPage(this.doc.type);
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
await page.versions.waitForVisible();
const pageVersionDialog = await page.versions.dialog;
Expand All @@ -68,65 +75,80 @@ When(/^I create a (major|minor) version$/, async function(versionType) {
await dialogConfirmBtn.click();
});

When(/^The document version is ([^"]*)$/, function(label) {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versions.waitForVisible();
page.versions.toggle.waitForVisible();
driver.waitUntil(() => page.versions.toggle.getText() === label, `No version found with label "${label}"`);
When(/^The document version is ([^"]*)$/, async function(label) {
await driver.pause(1000);
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
await page.versions.waitForVisible();
const versionsToggle = await page.versions.toggle;
await versionsToggle.waitForVisible();
const versionsToggleText = await versionsToggle.getText();
if (versionsToggleText !== label) {
throw Error(`No version found with label "${label}"`);
}
});

When(/^I click the versions list$/, function() {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versions.waitForVisible();
page.versions.toggle.waitForVisible();
page.versions.toggle.click();
page.versions.listItems.waitForVisible();
When(/^I click the versions list$/, async function() {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
const versions = await page.versions;
await versions.waitForVisible();
const versionsToggle = await versions.toggle;
await versionsToggle.waitForVisible();
await versionsToggle.click();
const versionsListItems = await versions.listItems;
await versionsListItems.waitForVisible();
});

When(/^I click the versions list at index (\d+)$/, function(index) {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versions.waitForVisible();
page.versions.listItem(index).waitForExist();
page.versions.listItems.waitForVisible();
page.versions.listItem(index).waitForExist();
page.versions.listItem(index).waitForVisible();
page.versions.listItem(index).click();
When(/^I click the versions list at index (\d+)$/, async function(index) {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
const versions = await page.versions;
await versions.waitForVisible();
await versions.listItem(index).waitForExist();
await versions.listItems.waitForVisible();
await versions.listItem(index).waitForExist();
await versions.listItem(index).waitForVisible();
await versions.listItem(index).click();
});

When(/^Versions item index at (\d+) is ([^"]*)$/, function(index, text) {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versions.waitForVisible();
page.versions
.listItemTitle(index)
.getText()
.should.equals(text);
When(/^Versions item index at (\d+) is ([^"]*)$/, async function(index, text) {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
const versions = await page.versions;
await versions.waitForVisible();
const listItemTitle = await versions.listItemTitle(index);
const listItemTitleText = await listItemTitle.getText();
listItemTitleText.should.equals(text);
});

When(/^Versions count is (\d+)$/, function(count) {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versions.waitForVisible();
page.versions.listCount.should.equal(count);
When(/^Versions count is (\d+)$/, async function(count) {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
const versions = await page.versions;
await versions.waitForVisible();
const listCount = await versions.listCount;
listCount.should.equal(count);
});

When(/^I click the Create Version button in versions list$/, function() {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.versions.waitForVisible();
page.versions.listItems.waitForVisible();
page.versions.listCreateVersionButton.waitForVisible();
page.versions.listCreateVersionButton.click();
When(/^I click the Create Version button in versions list$/, async function() {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
const versions = await page.versions;
await versions.waitForVisible();
await versions.listItems.waitForVisible();
const listCreateVersionButton = await versions.listCreateVersionButton;
await listCreateVersionButton.waitForVisible();
await listCreateVersionButton.click();
});

When(/^I can restore version$/, function() {
const page = this.ui.browser.documentPage(this.doc.type);
page.waitForVisible();
page.restoreVersionButton.waitForVisible();
page.restoreVersionButton.click();
page.restoreVersionButtonConfirm.waitForVisible();
page.restoreVersionButtonConfirm.click();
When(/^I can restore version$/, async function() {
const page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
const restoreVersionButton = await page.restoreVersionButton;
await restoreVersionButton.waitForVisible();
await restoreVersionButton.click();
const restoreVersionButtonConfirm = await page.restoreVersionButtonConfirm;
await restoreVersionButtonConfirm.waitForVisible();
await restoreVersionButtonConfirm.click();
});
6 changes: 3 additions & 3 deletions packages/nuxeo-web-ui-ftest/pages/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ const _flushProperties = () => {
}, global.config || []);
};

const refresh = () => {
driver.refresh();
_flushProperties();
const refresh = async () => {
await driver.refresh();
await _flushProperties();
};

const url = async (...args) => {
Expand Down
4 changes: 2 additions & 2 deletions packages/nuxeo-web-ui-ftest/pages/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export default class UI extends BasePage {
await logoEle.click();
}

reload() {
refresh();
async reload() {
await refresh();
}

get activityFeed() {
Expand Down
10 changes: 8 additions & 2 deletions packages/nuxeo-web-ui-ftest/pages/ui/browser/document_page.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,17 @@ export default class DocumentPage extends BasePage {
}

get restoreVersionButton() {
return this.versionInfoBar.element('nuxeo-restore-version-button');
return (async () => {
const versionInfoBar = await this.versionInfoBar;
return versionInfoBar.element('nuxeo-restore-version-button');
})();
}

get restoreVersionButtonConfirm() {
return this.versionInfoBar.element('nuxeo-restore-version-button paper-button[dialog-confirm]');
return (async () => {
const versionInfoBar = await this.versionInfoBar;
return versionInfoBar.element('nuxeo-restore-version-button paper-button[dialog-confirm]');
})();
}

get info() {
Expand Down
16 changes: 13 additions & 3 deletions packages/nuxeo-web-ui-ftest/pages/ui/browser/document_versions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,25 @@ export default class DocumentVersions extends BasePage {
}

get dialogMinorOption() {
return this.dialog.$('paper-radio-button[name="minor"]');
return (async () => {
const dialog = await this.dialog;
const element = await dialog.$('paper-radio-button[name="minor"]');
return element;
})();
}

get dialogNextMajor() {
return this.dialog.$('#nextMajor');
return (async () => {
const dialog = await this.dialog;
return dialog.$('#nextMajor');
})();
}

get dialogNextMinor() {
return this.dialog.$('#nextMinor');
return (async () => {
const dialog = await this.dialog;
return dialog.$('#nextMinor');
})();
}

get dialogDismissButton() {
Expand Down

0 comments on commit 16e8f9a

Please sign in to comment.