How to use the cypress-cucumber-preprocessor/steps.Given function in cypress-cucumber-preprocessor

To help you get started, we’ve selected a few cypress-cucumber-preprocessor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LiskHQ / lisk-desktop / test / cypress / features / delegateReg / delegateReg.js View on Github external
/* eslint-disable */
import { Given } from 'cypress-cucumber-preprocessor/steps';
import urls from '../../../constants/urls';
import ss from '../../../constants/selectors';

const txConfirmationTimeout = 12000;
const txDelegateRegPrice = 25;
const getRandomDelegateName = () => Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);

Given(/^I enter the delegate name$/, function () {
  const randomDelegateName = getRandomDelegateName();
  cy.get(ss.delegateNameInput).click().type(randomDelegateName);
  cy.wait(1200);
});

Given(/^I go to confirmation$/, function () {
  cy.get(ss.chooseDelegateName).click();
});

Given(/^I confirm transaction$/, function () {
  cy.get(ss.confirmDelegateButton).click();
});

Given(/^I see successful message$/, function () {
  cy.wait(txConfirmationTimeout);
  cy.get(ss.app).contains('Delegate registration submitted');
github LiskHQ / lisk-desktop / test / cypress / features / login / login.js View on Github external
/* eslint-disable */
import { Given } from 'cypress-cucumber-preprocessor/steps';
import urls from '../../../constants/urls';
import accounts from '../../../constants/accounts';
import networks from '../../../constants/networks';
import ss from '../../../constants/selectors';
import numeral from 'numeral';
import { fromRawLsk } from '../../../../src/utils/lsk';

Given(/^showNetwork setting is true$/, function () {
  cy.mergeObjectWithLocalStorage('settings', { showNetwork: true });
});

Given(/^I should be connected to ([^\s]+)$/, function (networkName) {
  const castNumberToBalanceString = number => (
    numeral(fromRawLsk(number)).format('0,0.[0000000000000]') + ' LSK'
  );
  switch (networkName) {
    case 'mainnet':
      cy.get(ss.headerBalance).should('have.text', castNumberToBalanceString(0));
      break;
    case 'testnet':
      cy.get(ss.headerBalance).should('have.text', castNumberToBalanceString(accounts['testnet_guy'].balance));
      break;
    case 'devnet':
      cy.get(ss.headerBalance).should('contain', castNumberToBalanceString(accounts.genesis.balance).substring(0, 3));
      break;
    default:
      throw new Error(`Network should be one of : mainnet , testnet, devnet. Was: ${networkName}`);
  }
github Human-Connection / Human-Connection / cypress / integration / common / steps.js View on Github external
/* global cy  */

let lastPost = {};

let loginCredentials = {
  email: "peterpan@example.org",
  password: "1234"
};
const narratorParams = {
  name: "Peter Pan",
  slug: "peter-pan",
  avatar: "https://s3.amazonaws.com/uifaces/faces/twitter/nerrsoft/128.jpg",
  ...loginCredentials
};

Given("I am logged in", () => {
  cy.login(loginCredentials);
});

Given("we have a selection of tags and categories as well as posts", () => {
  cy.factory()
    .authenticateAs(loginCredentials)
    .create("Category", {
      id: "cat1",
      name: "Just For Fun",
      slug: "justforfun",
      icon: "smile"
    })
    .create("Category", {
      id: "cat2",
      name: "Happyness & Values",
      slug: "happyness-values",
github LiskHQ / lisk-desktop / test / cypress / features / login / login.js View on Github external
case 'mainnet':
      cy.get(ss.headerBalance).should('have.text', castNumberToBalanceString(0));
      break;
    case 'testnet':
      cy.get(ss.headerBalance).should('have.text', castNumberToBalanceString(accounts['testnet_guy'].balance));
      break;
    case 'devnet':
      cy.get(ss.headerBalance).should('contain', castNumberToBalanceString(accounts.genesis.balance).substring(0, 3));
      break;
    default:
      throw new Error(`Network should be one of : mainnet , testnet, devnet. Was: ${networkName}`);
  }
  cy.get(ss.networkStatus).contains(`Connected to:${networkName}`);
});

Given(/^I choose ([^\s]+)$/, function (networkName) {
  switch (networkName) {
    case 'mainnet':
      cy.get(ss.networkDropdown).click();
      cy.get(ss.networkOptions).eq(0).click();
      break;
    case 'testnet':
      cy.get(ss.networkDropdown).click();
      cy.get(ss.networkOptions).eq(1).click();
      break;
    case 'devnet':
      cy.get(ss.networkDropdown).click();
      cy.get(ss.networkOptions).eq(2).click();
      cy.get(ss.addressInput).type(networks.devnet.node);
      cy.get(ss.connectButton).click();
      break;
    case 'invalid':
github LiskHQ / lisk-desktop / test / cypress / features / secondPassphraseReg / secondPassphraseReg.js View on Github external
cy.get(ss.goToConfirmation).click();
});

Given(/^I confirm my passphrase$/, function () {
  cy.get(ss.copyPassphrase).each(($wordElement) => {
    if ($wordElement[0].className.includes('empty')) {
      cy.wrap($wordElement).click();
      cy.get(ss.passphraseWordConfirm).each(($option) => {
        if (this.passphrase.includes($option[0].textContent)) cy.wrap($option).click();
      });
    }
  });
  cy.get(ss.passphraseConfirmButton).click();
});

Given(/^I confirm transaction$/, function () {
  cy.get(ss.confirmationCheckbox).click();
  cy.get(ss.confirmButton).click();
});
github Human-Connection / Human-Connection / cypress / integration / common / steps.js View on Github external
cy.get(".notifications-menu").should("contain", "0");
});

Given("there is an annoying user called {string}", name => {
  const annoyingParams = {
    email: "spammy-spammer@example.org",
    password: "1234"
  };
  cy.factory().create("User", {
    ...annoyingParams,
    id: "annoying-user",
    name
  });
});

Given("I am on the profile page of the annoying user", name => {
  cy.openPage("/profile/annoying-user/spammy-spammer");
});

When("I visit the profile page of the annoying user", name => {
  cy.openPage("/profile/annoying-user");
});

When("I ", name => {
  cy.openPage("/profile/annoying-user");
});

When(
  "I click on {string} from the content menu in the user info box",
  button => {
    cy.get(".user-content-menu .content-menu-trigger").click();
    cy.get(".popover .ds-menu-item-link")
github TheBrainFamily / cypress-cucumber-preprocessor / cypress / support / step_definitions / before_and_after_steps.js View on Github external
});

After({ tags: "@willNeverRun" }, () => {
  throw new Error("XXX: after hook unexpectedly called.");
});

After(() => {
  beforeCounter = 0;
  flagSetByUntaggedAfter = true;
});

After({ tags: "@withTaggedAfter" }, () => {
  flagSetByTaggedAfter = true;
});

Given("I executed empty step", () => {});

Then("Untagged Before was called once", () => {
  expect(beforeCounter).to.equal(1);
});

Then("Untagged Before was not called", () => {
  expect(beforeCounter).to.equal(0);
});

Then("Tagged Before was called once", () => {
  expect(beforeWithTagCounter).to.equal(1);
});

Then("Tagged Before was called twice", () => {
  expect(beforeWithTagCounter).to.equal(2);
});
github Human-Connection / Human-Connection / cypress / integration / common / steps.js View on Github external
});

Then("the list of posts of this user is empty", () => {
  cy.get(".ds-card-content").not(".post-link");
  cy.get(".main-container").find(".ds-space.hc-empty");
});

Then("nobody is following the user profile anymore", () => {
  cy.get(".ds-card-content").not(".post-link");
  cy.get(".main-container").contains(
    ".ds-card-content",
    "is not followed by anyone"
  );
});

Given("I wrote a post {string}", title => {
  cy.factory()
    .authenticateAs(loginCredentials)
    .create("Post", { title });
});

When("I block the user {string}", name => {
  cy.neode()
    .first("User", { name })
    .then(blocked => {
      cy.neode()
        .first("User", { name: narratorParams.name })
        .relateTo(blocked, "blocked");
    });
});

When("I log in with:", table => {
github Human-Connection / Human-Connection / cypress / integration / common / steps.js View on Github external
cy.get(".popover .ds-menu-item-link")
      .contains(button)
      .click({ force: true });
  }
);

When("I navigate to my {string} settings page", settingsPage => {
  cy.get(".avatar-menu").click();
  cy.get(".avatar-menu-popover")
    .find("a[href]")
    .contains("Settings")
    .click();
  cy.contains(".ds-menu-item-link", settingsPage).click();
});

Given("I follow the user {string}", name => {
  cy.neode()
    .first("User", { name })
    .then(followed => {
      cy.neode()
        .first("User", { name: narratorParams.name })
        .relateTo(followed, "following");
    });
});

Given('"Spammy Spammer" wrote a post {string}', title => {
  cy.factory()
    .authenticateAs({
      email: "spammy-spammer@example.org",
      password: "1234"
    })
    .create("Post", { title });
github Human-Connection / Human-Connection / cypress / integration / common / steps.js View on Github external
cy.contains("button", label);
});

When(`I click on {string}`, linkOrButton => {
  cy.contains(linkOrButton).click();
});

When(`I click on the menu item {string}`, linkOrButton => {
  cy.contains(".ds-menu-item", linkOrButton).click();
});

When("I press {string}", label => {
  cy.contains(label).click();
});

Given("we have the following posts in our database:", table => {
  table.hashes().forEach(({ Author, ...postAttributes }, i) => {
    Author = Author || `author-${i}`;
    const userAttributes = {
      name: Author,
      email: `${slugify(Author, { lower: true })}@example.org`,
      password: "1234"
    };
    postAttributes.deleted = Boolean(postAttributes.deleted);
    const disabled = Boolean(postAttributes.disabled);
    cy.factory()
      .create("User", userAttributes)
      .authenticateAs(userAttributes)
      .create("Post", postAttributes);
    if (disabled) {
      const moderatorParams = {
        email: "moderator@example.org",