Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var pageObject = require('./../../../../../../services/pages').container.PageObject;
- var signInPage = pageObject.getSignInPage();
- var dashboardPage = pageObject.getDashboardPage();
- var addCollectionPage = pageObject.getAddCollectionPage();
- var collectionListPage = pageObject.getCollectionListPage();
- var collectionsPage = pageObject.getCollectionsPage();
- var addProductPage = pageObject.getAddProductPage();
- var productListPage = pageObject.getProductListPage();
- var signInData = require('./../../../../../../data/admin/sign_in/index');
- var collectionData = require('./../../../../../../data/admin/collection/index');
- var productData = require('./../../../../../../data/admin/product/index');
- var commonHelper = require('./../../../../../../services/helpers/common.helper.js');
- describe('Add Collection - Auto Manual - Switch Method Scenarios', function () {
- var username = signInData.adminAccount.username;
- var password = signInData.adminAccount.password;
- var firstCollectionTitle = commonHelper.uniqueProductName('switch1');
- var firstCollectionDescription = collectionData.collection.description.first;
- var addCollectionLink = signInData.link + '/collections/create';
- var product = {
- firstTitle: commonHelper.uniqueProductName('switch2'),
- secondTitle: commonHelper.uniqueProductName('switch3'),
- type: productData.product.type,
- price: productData.product.price
- };
- describe('switching from manually add products to auto add product based on conditions', function () {
- var unique_value = commonHelper.uniqueValue();
- var collectionTitle = firstCollectionTitle + unique_value;
- var firstProductTitle = product.firstTitle + unique_value;
- var secondProductTitle = product.secondTitle + unique_value;
- beforeAll(function () {
- commonHelper.acceptAlert();
- browser.get(signInData.link);
- });
- afterAll(function () {
- commonHelper.clearAllData();
- });
- it('should redirect on dashboard page after login', function () {
- signInPage.login(username, password);
- commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
- });
- it('should redirect on add product page', function () {
- browser.get(productData.addLink);
- addProductPage.waitForPublishButton();
- });
- it('should add first product', function () {
- addProductPage.selectType(product.type);
- addProductPage.selectFirstCollection();
- addProductPage.fillTitle(firstProductTitle);
- addProductPage.fillPrice(product.price);
- addProductPage.clickPublish();
- commonHelper.waitUntilElementVisible(productListPage.productEntry(firstProductTitle));
- });
- it('should open new product page', function () {
- browser.get(productData.addLink);
- addProductPage.waitForPublishButton();
- });
- it('should add second product', function () {
- addProductPage.selectType(product.type);
- addProductPage.selectFirstCollection();
- addProductPage.fillTitle(secondProductTitle);
- addProductPage.fillPrice(product.price);
- addProductPage.clickPublish();
- commonHelper.waitUntilElementVisible(productListPage.productEntry(secondProductTitle));
- });
- it('should open new collection page', function () {
- browser.get(addCollectionLink);
- });
- it('should fill title and description fields', function () {
- addCollectionPage.fillTitle(collectionTitle);
- addCollectionPage.fillDescription(firstCollectionDescription);
- });
- it('should add manual product', function () {
- addCollectionPage.clickAddProducts();
- addCollectionPage.clickProduct(secondProductTitle);
- addCollectionPage.clickCloseProducts();
- });
- it('should click auto add product radio button', function () {
- addCollectionPage.clickAddAuto();
- commonHelper.waitUntilElementClickable(addCollectionPage.btnConfirm);
- addCollectionPage.clickConfirm();
- commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
- });
- it('should add condition', function () {
- addCollectionPage.selectConditionVariant(0, 'Product title');
- addCollectionPage.selectConditionRule(0, 'is exactly');
- addCollectionPage.fillConditionValue(0, firstProductTitle);
- });
- it('should add new collection', function () {
- addCollectionPage.clickPublish();
- commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
- });
- it('should show collection page after click on collection link', function () {
- collectionListPage.clickCollection(collectionTitle);
- commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
- expect(collectionsPage.productTitle(firstProductTitle).isDisplayed()).toBeTruthy();
- expect(collectionsPage.productTitle(secondProductTitle).isPresent()).toBeFalsy();
- commonHelper.switchToPreviousTab();
- });
- });
- describe('switching from auto add product based on conditions to manually add products', function () {
- var unique_value = commonHelper.uniqueValue();
- var collectionTitle = firstCollectionTitle + unique_value;
- var firstProductTitle = product.firstTitle + unique_value;
- var secondProductTitle = product.secondTitle + unique_value;
- beforeAll(function () {
- commonHelper.acceptAlert();
- browser.get(signInData.link);
- });
- afterAll(function () {
- commonHelper.clearAllData();
- });
- it('should redirect on dashboard page after login', function () {
- signInPage.login(username, password);
- commonHelper.waitUntilElementPresent(dashboardPage.txtSearch);
- });
- it('should redirect on add product page', function () {
- browser.get(productData.addLink);
- addProductPage.waitForPublishButton();
- });
- it('should add first product', function () {
- addProductPage.selectType(product.type);
- addProductPage.selectFirstCollection();
- addProductPage.fillTitle(firstProductTitle);
- addProductPage.fillPrice(product.price);
- addProductPage.clickPublish();
- commonHelper.waitUntilElementVisible(productListPage.productEntry(firstProductTitle));
- });
- it('should open new product page', function () {
- browser.get(productData.addLink);
- addProductPage.waitForPublishButton();
- });
- it('should add second product', function () {
- addProductPage.selectType(product.type);
- addProductPage.selectFirstCollection();
- addProductPage.fillTitle(secondProductTitle);
- addProductPage.fillPrice(product.price);
- addProductPage.clickPublish();
- commonHelper.waitUntilElementVisible(productListPage.productEntry(secondProductTitle));
- });
- it('should open new collection page', function () {
- browser.get(addCollectionLink);
- });
- it('should fill title and description fields', function () {
- addCollectionPage.fillTitle(collectionTitle);
- addCollectionPage.fillDescription(firstCollectionDescription);
- });
- it('should click auto add product radio button', function () {
- addCollectionPage.clickAddAuto();
- commonHelper.waitUntilElementVisible(addCollectionPage.sel2Type);
- });
- it('should add condition', function () {
- addCollectionPage.selectConditionVariant(0, 'Product title');
- addCollectionPage.selectConditionRule(0, 'is exactly');
- addCollectionPage.fillConditionValue(0, firstProductTitle);
- });
- it('should click manual add product radio button', function () {
- addCollectionPage.clickAddManual();
- commonHelper.waitUntilElementClickable(addCollectionPage.btnConfirm);
- addCollectionPage.clickConfirm();
- });
- it('should add manual product', function () {
- addCollectionPage.clickAddProducts();
- addCollectionPage.clickProduct(secondProductTitle);
- addCollectionPage.clickCloseProducts();
- });
- it('should add new collection', function () {
- addCollectionPage.clickPublish();
- commonHelper.waitUntilElementVisible(collectionListPage.collectionEntry(collectionTitle));
- });
- it('should show collection page after click on collection link', function () {
- collectionListPage.clickCollection(collectionTitle);
- commonHelper.waitUntilElementVisible(collectionsPage.txtTitle);
- expect(collectionsPage.productTitle(secondProductTitle).isDisplayed()).toBeTruthy();
- expect(collectionsPage.productTitle(firstCollectionDescription).isPresent()).toBeFalsy();
- commonHelper.switchToPreviousTab();
- });
- });
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement