Skip to content

Commit

Permalink
clear console
Browse files Browse the repository at this point in the history
  • Loading branch information
alokhyland committed Oct 25, 2024
1 parent f775dee commit 5b64a1d
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 64 deletions.
112 changes: 49 additions & 63 deletions packages/nuxeo-web-ui-ftest/features/step_definitions/browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
// eslint-disable-next-line import/no-extraneous-dependencies
import { Then, When } from '@cucumber/cucumber';

Then('I can see the {word} tree', async function (tab) {
Then('I can see the {word} tree', async function(tab) {
const drawer = await this.ui.drawer;
await drawer._section(tab);
const isVisible = await drawer.waitForVisible();
isVisible.should.be.true;
});

Then('I can see the {string} {word} tree node', async function (title, tab) {
Then('I can see the {string} {word} tree node', async function(title, tab) {
const drawer = await this.ui.drawer;
const sectionTab = await drawer._section(tab);
await sectionTab.waitForVisible();
Expand All @@ -25,7 +25,7 @@ Then('I can see the {string} {word} tree node', async function (title, tab) {
throw new Error(`Expected text to be ${title} but not found`);
});

Then('I can navigate to {word} pill', async function (pill) {
Then('I can navigate to {word} pill', async function(pill) {
await driver.pause(1000);
const browser = await this.ui.browser;
await browser.waitForVisible();
Expand All @@ -36,20 +36,20 @@ Then('I can navigate to {word} pill', async function (pill) {
await driver.pause(1000);
});

Then('I cannot see to {word} pill', async function (pill) {
Then('I cannot see to {word} pill', async function(pill) {
const browser = await this.ui.browser;
await browser.waitForVisible();
const outElement = await browser.waitForNotVisible(`nuxeo-page-item[name='${pill.toLowerCase()}']`);
outElement.should.be.true;
});

Then('I am on the {word} pill', async function (pill) {
Then('I am on the {word} pill', async function(pill) {
await this.ui.browser.waitForVisible();
const currentPageEle = await this.ui.browser.currentPageName;
currentPageEle.should.equal(pill);
});

When('I click {string} in the {word} tree', async function (title, tab) {
When('I click {string} in the {word} tree', async function(title, tab) {
const drawer = await this.ui.drawer;
const sectionTab = await drawer._section(tab);
await sectionTab.waitForVisible();
Expand All @@ -73,45 +73,45 @@ When('I click {string} in the {word} tree', async function (title, tab) {
}
});

Then('I can see the {string} document', async function (title) {
Then('I can see the {string} document', async function(title) {
const browser = await this.ui.browser;
await browser.waitForVisible();
const browserTitle = await browser.hasTitle(title);
browserTitle.should.be.true;
});

Then('I select all child documents', async function () {
Then('I select all child documents', async function() {
const browser = await this.ui.browser;
await browser.waitForVisible();
await browser.selectAllChildDocuments();
});

Then('I select all the documents', async function () {
Then('I select all the documents', async function() {
const browser = await this.ui.browser;
await browser.waitForVisible();
await browser.selectAllDocuments();
});

Then('I deselect the {string} document', async function (title) {
Then('I deselect the {string} document', async function(title) {
const browser = await this.ui.browser;
await browser.waitForVisible();
await browser.deselectChildDocument(title);
});

Then('I select the {string} document', async function (title) {
Then('I select the {string} document', async function(title) {
const browser = await this.ui.browser;
await browser.waitForVisible();
await browser.selectChildDocument(title);
});

Then('I can see the selection toolbar', async function () {
Then('I can see the selection toolbar', async function() {
const browser = await this.ui.browser;
await browser.waitForVisible();
const toolbar = await browser.selectionToolbar;
await toolbar.waitForVisible();
});

When('I cannot see the display selection link', async function () {
When('I cannot see the display selection link', async function() {
const browser = await this.ui.browser;
await browser.waitForVisible();
const selectionToolbarElem = await browser.selectionToolbar;
Expand All @@ -121,36 +121,36 @@ When('I cannot see the display selection link', async function () {
selectionLinkVisible.should.be.true;
});

Then('I can add selection to the {string} collection', async function (collectionName) {
Then('I can add selection to the {string} collection', async function(collectionName) {
const browserEle = await this.ui.browser;
await browserEle.waitForVisible();
const selectionToolEle = await browserEle.selectionToolbar;
const addToDialog = await selectionToolEle.addToCollectionDialog;
await addToDialog.addToCollection(collectionName);
});

Then('I can add selection to clipboard', async function () {
Then('I can add selection to clipboard', async function() {
const browser = await this.ui.browser;
await browser.waitForVisible();
const toolbar = await browser.selectionToolbar;
await toolbar.addToClipboard();
});

Then('I can move selection down', async function () {
Then('I can move selection down', async function() {
const browser = await this.ui.browser;
await browser.waitForVisible();
const selectionToolbar = await browser.selectionToolbar;
await selectionToolbar.moveDown();
});

Then('I can move selection up', async function () {
Then('I can move selection up', async function() {
const browser = await this.ui.browser;
await browser.waitForVisible();
const selectionToolbar = await browser.selectionToolbar;
await selectionToolbar.moveUp();
});

Then('I can see the {string} child document is at position {int}', async function (title, pos) {
Then('I can see the {string} child document is at position {int}', async function(title, pos) {
await driver.pause(1000);
const browser = await this.ui.browser;
await browser.waitForVisible();
Expand All @@ -160,13 +160,13 @@ Then('I can see the {string} child document is at position {int}', async functio
}
});

When('I sort the content by {string} in {string} order', async function (field, order) {
When('I sort the content by {string} in {string} order', async function(field, order) {
const browser = await this.ui.browser;
await browser.waitForVisible();
await browser.sortContent(field, order);
});

Then('I can see {int} document(s)', async function (numberOfResults) {
Then('I can see {int} document(s)', async function(numberOfResults) {
const browser = await this.ui.browser;
const uiResult = await browser.results;
const displayMode = await uiResult.displayMode;
Expand All @@ -176,19 +176,19 @@ Then('I can see {int} document(s)', async function (numberOfResults) {
}
});

Then(/^I can see the permissions page$/, async function () {
Then(/^I can see the permissions page$/, async function() {
await this.ui.browser.permissionsView.waitForVisible();
});

Then(/^I can see the document has (\d+) publications$/, async function (nbPublications) {
Then(/^I can see the document has (\d+) publications$/, async function(nbPublications) {
const browser = await this.ui.browser;
const count = await browser.publicationView.count;
if ((await count) !== nbPublications) {
throw new Error(`Expected count to be equal ${nbPublications}`);
}
});

Then(/^I can see the document has the following publication$/, async function (table) {
Then(/^I can see the document has the following publication$/, async function(table) {
const rows = table.rows();
for (let i = 0; i < rows.length; i++) {
const row = rows[i];
Expand All @@ -198,7 +198,7 @@ Then(/^I can see the document has the following publication$/, async function (t
}
});

Then(/^I can republish the following publication$/, async function (table) {
Then(/^I can republish the following publication$/, async function(table) {
const rows = table.hashes();
for (let i = 0; i < rows.length; i++) {
const { path, rendition, version } = rows[i];
Expand All @@ -221,7 +221,7 @@ Then(/^I can republish the following publication$/, async function (table) {
}
});

Then('I can publish selection to {string}', async function (target) {
Then('I can publish selection to {string}', async function(target) {
const browser = await this.ui.browser;
await browser.waitForVisible();
const selectionToolBar = await browser.selectionToolbar;
Expand All @@ -231,47 +231,33 @@ Then('I can publish selection to {string}', async function (target) {
await driver.pause(1000);
});

Then(/^I can perform the following publications$/, async function (table) {

try {
let page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
let pubCount = await page.publicationsCount;
pubCount.should.not.be.NaN;
const rows = table.hashes();
console.log('tabletabletabletabletabletable', table)
for (let i = 0; i < rows.length; i++) {
const { target, rendition, version, override } = rows[i];
const dialog = await this.ui.browser.publishDialog;
console.log('dialogdialogdialogdialogdialog', dialog)
const isdocumentPublished = await dialog.publish(target, rendition, version, override);
console.log('isdocumentPublishedisdocumentPublishedisdocumentPublished', isdocumentPublished)
isdocumentPublished.should.be.true;
page = await this.ui.browser.documentPage(this.doc.type);
console.log('pagepagepagepage 250', page)
const newCount = await page.publicationsCount;
console.log('newCountnewCountnewCount 252', newCount)
let check;
const bar = await page.isVisible('#versionInfoBar');

console.log('barbarbarbarbar 256', bar)
if (bar) {
check = newCount === 0;
} else {
check = override ? newCount === 1 : newCount > pubCount;
}
if (check) {
pubCount = page.publicationsCount;
}
Then(/^I can perform the following publications$/, async function(table) {
let page = await this.ui.browser.documentPage(this.doc.type);
await page.waitForVisible();
let pubCount = await page.publicationsCount;
pubCount.should.not.be.NaN;
const rows = table.hashes();
for (let i = 0; i < rows.length; i++) {
const { target, rendition, version, override } = rows[i];
const dialog = await this.ui.browser.publishDialog;
const isdocumentPublished = await dialog.publish(target, rendition, version, override);
isdocumentPublished.should.be.true;
page = await this.ui.browser.documentPage(this.doc.type);
const newCount = await page.publicationsCount;
let check;
const bar = await page.isVisible('#versionInfoBar');
if (bar) {
check = newCount === 0;
} else {
check = override ? newCount === 1 : newCount > pubCount;
}
if (check) {
pubCount = page.publicationsCount;
}
}
catch (err) {
console.log('catchError', err)
}

});

Then('I can delete all the documents from the {string} collection', async function (name) {
Then('I can delete all the documents from the {string} collection', async function(name) {
const browser = await this.ui.browser;
await browser.removeSelectionFromCollection(name);
// HACK - because the delete all is async
Expand All @@ -284,4 +270,4 @@ Then('I can see the browser title as {string}', async (title) => {
if (title !== browserTitle) {
throw new Error(`Expected text to be ${title} but not found`);
}
});
});
2 changes: 1 addition & 1 deletion packages/nuxeo-web-ui-ftest/wdio.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ exports.config = {
// WebdriverIO allows it to run your tests in arbitrary locations (e.g. locally or
// on a remote machine).
runner: 'local',
specs: ['../../ftest/features/publication.feature'],
specs: [path.join(process.cwd(), './features/*.feature')],
// check http://webdriver.io/guide/testrunner/debugging.html for more info on debugging with wdio
debug: process.env.DEBUG,
execArgv: process.env.DEBUG ? ['--inspect'] : [],
Expand Down

0 comments on commit 5b64a1d

Please sign in to comment.