Feature: Runner WP-CLI

  Scenario: Path argument should be slashed correctly
  When I try `wp no-such-command --path=/foo --debug`
  Then STDERR should contain:
    """
    ABSPATH defined: /foo/
    """

  When I try `wp no-such-command --path=/foo/ --debug`
  Then STDERR should contain:
    """
    ABSPATH defined: /foo/
    """

  When I try `wp no-such-command --path=/foo\\ --debug`
  Then STDERR should contain:
    """
    ABSPATH defined: /foo/
    """

  Scenario: defining abspath before WP-CLI is loaded
    Given an empty directory
    And a wp-cli.yml file:
      """
      require:
        - abspath.php
      """
    And a abspath.php file:
      """
      <?php
      if ( ! defined( 'ABSPATH' ) ) {
          define( 'ABSPATH', '/wcrtm/' );
      }
      """

    When I try `wp no-such-command --debug`
    Then STDERR should not contain:
      """
      Constant ABSPATH already defined in
      """
    And STDERR should contain:
      """
      ABSPATH defined: /wcrtm/
      """

    When I try `wp no-such-command --path=/foo --debug`
    Then STDERR should contain:
      """
      The --path parameter cannot be used when ABSPATH is already defined elsewhere
      """

Change scenario title and path used

Feature: Runner WP-CLI

  Scenario: Path argument should be slashed correctly
  When I try `wp no-such-command --path=/foo --debug`
  Then STDERR should contain:
    """
    ABSPATH defined: /foo/
    """

  When I try `wp no-such-command --path=/foo/ --debug`
  Then STDERR should contain:
    """
    ABSPATH defined: /foo/
    """

  When I try `wp no-such-command --path=/foo\\ --debug`
  Then STDERR should contain:
    """
    ABSPATH defined: /foo/
    """

  Scenario: ABSPATH can be defined outside of WP-CLI
    Given an empty directory
    And a wp-cli.yml file:
      """
      require:
        - abspath.php
      """
    And a abspath.php file:
      """
      <?php
      if ( ! defined( 'ABSPATH' ) ) {
          define( 'ABSPATH', '/some_path/' );
      }
      """

    When I try `wp no-such-command --debug`
    Then STDERR should not contain:
      """
      Constant ABSPATH already defined in
      """
    And STDERR should contain:
      """
      ABSPATH defined: /some_path/
      """

    When I try `wp no-such-command --path=/foo --debug`
    Then STDERR should contain:
      """
      The --path parameter cannot be used when ABSPATH is already defined elsewhere
      """


@lock-account
Feature: Users are locked if they enter the wrong password too many times

@skip-preview
Scenario: User has 5 failed login attempts and is locked out of their account
  Given I have a supplier user
  When The wrong password is entered 5 times for that user
  Then That user can not log in using their correct password
  # TODO: And the user is shown as 'locked' on the admin users page

@skip-staging
Scenario: User has 10 failed login attempts and is locked out of their account
  Given I have a supplier user
  When The wrong password is entered 10 times for that user
  Then That user can not log in using their correct password
  # TODO: And the user is shown as 'locked' on the admin users page

Remove skip staging flag from password attempts feature

@lock-account
Feature: Users are locked if they enter the wrong password too many times

Scenario: User has 10 failed login attempts and is locked out of their account
  Given I have a supplier user
  When The wrong password is entered 10 times for that user
  Then That user can not log in using their correct password
  # TODO: And the user is shown as 'locked' on the admin users page


Feature: admin_uploader

  @normal
  Scenario: Quickly loading the admin home page
    Given I am benchmarking
    When I visit the admin home page
    Then the elapsed time should be less than 1 seconds

  @normal
  @not_on_staging
  Scenario: Can log in
    When I try to login as a valid admin user
    Then I should be on the admin post-login page

  # Admin UI routing

  @normal
  Scenario: I can access the admin application without a trailing slash
    When I GET https://admin.{PP_APP_DOMAIN}/not-authorized
    Then I should receive an HTTP 200

  @normal
  Scenario: I can access the admin application with a trailing slash
    When I GET https://admin.{PP_APP_DOMAIN}/not-authorized/
    Then I should receive an HTTP 301 redirect to /not-authorized

Add deprecation message to admin uploader tests

# Deprecated: these tests check the admin.backdrop uploader
# New tests should be added to the admin_app feature and this
# file should be deleted "soon".
Feature: admin_uploader

  @normal
  Scenario: Quickly loading the admin home page
    Given I am benchmarking
    When I visit the admin home page
    Then the elapsed time should be less than 1 seconds

  @normal
  @not_on_staging
  Scenario: Can log in
    When I try to login as a valid admin user
    Then I should be on the admin post-login page

  # Admin UI routing

  @normal
  Scenario: I can access the admin application without a trailing slash
    When I GET https://admin.{PP_APP_DOMAIN}/not-authorized
    Then I should receive an HTTP 200

  @normal
  Scenario: I can access the admin application with a trailing slash
    When I GET https://admin.{PP_APP_DOMAIN}/not-authorized/
    Then I should receive an HTTP 301 redirect to /not-authorized


Feature: Lazy XML-RPC encoders

  As a client of a shoddy xml-rpc encoder,
  I want to be able to read their requests and responses correctly,
  so that I can communicate with them.

Scenario: Implicit <string> types in <values>

  Given the following method response:
  """
<methodResponse><params><param><value>987lkjasd</value></param></params>
  """
  When I decode the method response
  Then the first value should be "987lkjasd"

Scenario: Implicit <string> types in <values> starting with whitespace

  Given the following method response:
"""
<methodResponse><params><param><value>
   987lkjasd
</value></param></params>
"""
  When I decode the method response
  Then the first value should be:
"""

   987lkjasd

"""

Scenario: Implicit <string> type starting with an XML entity

  Given the following method response:
  """
<methodResponse><params><param><value> 987lkjasd</value></param></params>
  """
  When I decode the method response
  Then the first value should be " 987lkjasd"

Scenario: Indented, explicit type tags

  Given the following method response:
  """
<methodResponse><params><param><value>
   <string>987lkjasd</string>
</value></param></params>
  """
  When I decode the method response
  Then the first value should be "987lkjasd"

Fix missing closing tag on lazy-encoders.feature

Feature: Lazy XML-RPC encoders

  As a client of a shoddy xml-rpc encoder,
  I want to be able to read their requests and responses correctly,
  so that I can communicate with them.

Scenario: Implicit <string> types in <values>

  Given the following method response:
  """
<methodResponse><params><param><value>987lkjasd</value></param></params></methodResponse>
  """
  When I decode the method response
  Then the first value should be "987lkjasd"

Scenario: Implicit <string> types in <values> starting with whitespace

  Given the following method response:
"""
<methodResponse><params><param><value>
   987lkjasd
</value></param></params></methodResponse>
"""
  When I decode the method response
  Then the first value should be:
"""

   987lkjasd

"""

Scenario: Implicit <string> type starting with an XML entity

  Given the following method response:
  """
<methodResponse><params><param><value> 987lkjasd</value></param></params></methodResponse>
  """
  When I decode the method response
  Then the first value should be " 987lkjasd"

Scenario: Indented, explicit type tags

  Given the following method response:
  """
<methodResponse><params><param><value>
   <string>987lkjasd</string>
</value></param></params></methodResponse>
  """
  When I decode the method response
  Then the first value should be "987lkjasd"


@shard_1
Feature: LMS.Navigate Course
    As a student in an edX course
    In order to access courseware
    I want to be able to navigate through the content

    Scenario: I can navigate to a section
        Given I am viewing a course with multiple sections
        When I navigate to a section
        Then I see the content of the section

    Scenario: I can navigate to subsections
        Given I am viewing a section with multiple subsections
        When I navigate to a subsection
        Then I see the content of the subsection

    Scenario: I can navigate to sequences
        Given I am viewing a section with multiple sequences
        When I navigate to an item in a sequence
        Then I see the content of the sequence item
        And a "seq_goto" browser event is emitted

Comment out flaky lettuce test. TNL-5315

@shard_1
Feature: LMS.Navigate Course
    As a student in an edX course
    In order to access courseware
    I want to be able to navigate through the content

# This scenario is flaky: See TNL-5315
#    Scenario: I can navigate to a section
#        Given I am viewing a course with multiple sections
#        When I navigate to a section
#        Then I see the content of the section

    Scenario: I can navigate to subsections
        Given I am viewing a section with multiple subsections
        When I navigate to a subsection
        Then I see the content of the subsection

    Scenario: I can navigate to sequences
        Given I am viewing a section with multiple sequences
        When I navigate to an item in a sequence
        Then I see the content of the sequence item
        And a "seq_goto" browser event is emitted


Feature: Task
  >In order to remember what I did
  As a person short on time
  I want to keep track of tasks

**Scenarios**

- [Create new task with title](#1)
- [Create new task with description](#2)

  Background: Signed in
    Given I am signed in as a new user

  Scenario: Create new task with title
    Given I am on the new task page
    And I fill in all required fields
    And I fill in "task_title" with "My first task title"
    When I press "Create"
    Then I should see "Task was successfully created."
    And I should see "My first task title"

  Scenario: Create new task with description
    Given I am on the new task page
    When I fill in all required fields
    And I fill in "task_description" with "A long task description explaining in more detail what the task is about"
    And I press "Create"
    Then I should see "Task was successfully created."
    And I should see "A long task description explaining"

Remove ToC because it adds more noise to Cucumber and it doesn't look all that pretty on RelishApp

Feature: Task
  >In order to remember what I did
  As a person short on time
  I want to keep track of tasks

  Background: Signed in
    Given I am signed in as a new user

  Scenario: Create new task with title
    Given I am on the new task page
    And I fill in all required fields
    And I fill in "task_title" with "My first task title"
    When I press "Create"
    Then I should see "Task was successfully created."
    And I should see "My first task title"

  Scenario: Create new task with description
    Given I am on the new task page
    When I fill in all required fields
    And I fill in "task_description" with "A long task description explaining in more detail what the task is about"
    And I press "Create"
    Then I should see "Task was successfully created."
    And I should see "A long task description explaining"


Feature: User remove

  Background:
    Given user "participant1" exists
    Given user "participant2" exists

  Scenario: Remove a user from all their rooms
    Given user "participant1" creates room "room" (v4)
      | roomType | 1 |
      | invite   | participant2 |
    And invoking occ with "talk:user:remove --user participant2"
    And the command output contains the text "Users successfully removed from all rooms"
    Then the command was successful
    And user "participant2" is participant of the following rooms (v4)
    And user "participant1" is participant of room "room" (v4)

Test with one-to-one and public conversation

Feature: User remove

  Background:
    Given user "participant1" exists
    Given user "participant2" exists

  Scenario: Remove a user from all their rooms
    Given user "participant1" creates room "room1" (v4)
      | roomType | 1 |
      | invite   | participant2 |
    Given user "participant1" creates room "room2" (v4)
      | roomType | 3 |
      | roomName | room |
    And user "participant1" adds user "participant2" to room "room2" with 200 (v4)
    And invoking occ with "talk:user:remove --user participant2"
    And the command output contains the text "Users successfully removed from all rooms"
    Then the command was successful
    And user "participant2" is participant of the following rooms (v4)
    And user "participant1" is participant of the following rooms (v4)
      | id    | name                     | type | participantType |
      | room1 | participant2-displayname | 2    | 1               |
      | room2 | room                     | 3    | 1               |
    And user "participant1" sees the following attendees in room "room1" with 200 (v4)
      | actorType  | actorId      | participantType |
      | users      | participant1 | 1               |
    And user "participant1" sees the following attendees in room "room2" with 200 (v4)
      | actorType  | actorId      | participantType |
      | users      | participant1 | 1               |


Feature: Bus Trip Emissions Calculations
  The bus trip model should generate correct emission calculations

  Scenario: Calculations for bus trip with nothing
    Given a bus trip has nothing
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "0.87"

  Scenario: Calculations for bus trip from distance
    Given a bus trip has "distance" of "100"
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "9.95"

  Scenario: Calculations for bus trip from duration
    Given a bus trip has "duration" of "60"
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "3.15"

  Scenario: Calculations for bus trip from bus class
    Given a bus trip has "bus_class.name" of "city transit"
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "2.64"

Cut gasoline-related stuff because none of our bus classes use gasoline.

Feature: Bus Trip Emissions Calculations
  The bus trip model should generate correct emission calculations

  Scenario: Calculations for bus trip with nothing
    Given a bus trip has nothing
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "0.87"

  Scenario: Calculations for bus trip from distance
    Given a bus trip has "distance" of "100"
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "9.94"

  Scenario: Calculations for bus trip from duration
    Given a bus trip has "duration" of "60"
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "3.15"

  Scenario: Calculations for bus trip from bus class
    Given a bus trip has "bus_class.name" of "city transit"
    When emissions are calculated
    Then the emission value should be within "0.01" kgs of "2.64"


Feature: Review CLI information

  Scenario: Get the path to the packages directory
    Given an empty directory

    When I run `wp cli info --format=json`
    Then STDOUT should be JSON containing:
      """
      {"wp_cli_packages_dir_path":null}
      """

    When I run `wp package install danielbachhuber/wp-cli-reset-post-date-command`
    Then STDERR should be empty

    When I run `wp cli info --format=json`
    Then STDOUT should be JSON containing:
      """
      {"wp_cli_packages_dir_path":"/tmp/wp-cli-home/.wp-cli/packages/"}
      """

    When I run `wp cli info`
    Then STDOUT should contain:
      """
      WP-CLI packages dir:    /tmp/wp-cli-home/.wp-cli/packages/
      """

Fix build error in test of cli info

Feature: Review CLI information

  Scenario: Get the path to the packages directory
    Given an empty directory

    When I run `wp cli info --format=json`
    Then STDOUT should be JSON containing:
      """
      {"wp_cli_packages_dir_path":null}
      """

    When I run `wp package install danielbachhuber/wp-cli-reset-post-date-command`
    Then STDERR should be empty

    When I run `wp cli info --format=json`
    Then STDOUT should be JSON containing:
      """
      {"wp_cli_packages_dir_path":"/tmp/wp-cli-home/.wp-cli/packages/"}
      """

    When I run `wp cli info`
    Then STDOUT should contain:
      """
      WP-CLI packages dir:
      """


Feature: My bootstrapped app kinda works
  In order to get going on coding my awesome app
  I want to have aruba and cucumber setup
  So I don't have to do it myself

  Scenario: App just runs
    When I get help for "spoon"
    Then the exit status should be 0
    And the banner should be present
    And the banner should document that this app takes options
    And the following options should be documented:
      |--version|
    And the banner should document that this app takes no arguments

Update tests to pass w/ minimal tests for now

Feature: My bootstrapped app kinda works
  In order to get going on coding my awesome app
  I want to have aruba and cucumber setup
  So I don't have to do it myself

  Scenario: App just runs
    When I get help for "spoon"
    Then the exit status should be 0
    And the banner should be present
    And the banner should document that this app takes options
    And the following options should be documented:
      |--version|
      |--list|
      |--destroy|
      |--build|
      |--builddir|
      |--pre-build-commands|
      |--url|
      |--list-images|
      |--image|
      |--prefix|
      |--config|
      |--debug|


Feature: helloworld
 Scenario: helloworld orientation
  When launch "helloworld"
   Then I should see view "description=Hello, world!"
    And I press "home" hardware key
    And I press "recent" hardware key
    And I save relative view "className=android.widget.ImageView" on the "right" side of view "text=HelloWorld" to object "hello_app"
    And I click saved object "hello_app"
   Then I should see view "description=Hello, world!"

Update hellow-world name to 'Hello World'

Feature: helloworld
 Scenario: helloworld orientation
  When launch "helloworld"
   Then I should see view "description=Hello, world!"
    And I press "home" hardware key
    And I press "recent" hardware key
    And I save relative view "className=android.widget.ImageView" on the "right" side of view "text=Hello World" to object "hello_app"
    And I click saved object "hello_app"
   Then I should see view "description=Hello, world!"


@smoke-tests @homepage
Feature: Check appropriate links on homepage

Scenario: User can see the main links on the homepage
  Given I visit the homepage
  Then I see the 'Find cloud hosting, software and support' link
  And I see the 'Buy physical datacentre space' link
  And I see the 'Find an individual specialist' link
  And I see the 'Find a team to provide an outcome' link
  And I see the 'Find user research participants' link
  And I see the 'Find a user research lab' link
  And I see the 'View Digital Outcomes and Specialists opportunities' link
  And I see the 'Become a supplier' link
  And I see the 'G-Cloud supplier A to Z' link

Update crown hosting link text

@smoke-tests @homepage
Feature: Check appropriate links on homepage

@skip-local @skip-preview
Scenario: User can see the main links on the homepage
  Given I visit the homepage
  Then I see the 'Find cloud hosting, software and support' link
  And I see the 'Buy physical datacentre space' link
  And I see the 'Find an individual specialist' link
  And I see the 'Find a team to provide an outcome' link
  And I see the 'Find user research participants' link
  And I see the 'Find a user research lab' link
  And I see the 'View Digital Outcomes and Specialists opportunities' link
  And I see the 'Become a supplier' link
  And I see the 'G-Cloud supplier A to Z' link

@skip-staging @skip-production
Scenario: User can see the main links on the homepage
  Given I visit the homepage
  Then I see the 'Find cloud hosting, software and support' link
  And I see the 'Find physical datacentre space' link
  And I see the 'Find an individual specialist' link
  And I see the 'Find a team to provide an outcome' link
  And I see the 'Find user research participants' link
  And I see the 'Find a user research lab' link
  And I see the 'View Digital Outcomes and Specialists opportunities' link
  And I see the 'Become a supplier' link
  And I see the 'G-Cloud supplier A to Z' link


Feature: configuration

  Scenario: Outputting the currng config
    Given the default configuration
    When I run `tam config`
    Then the exit status should be 0
    Then the output should contain:
    """
    duration: 25
    """

  Scenario: Setting the tomato duration
    Given the default configuration
    When I run `tam config duration=15`
    And I run `tam config`
    Then the exit status should be 0
    Then the output should contain:
    """
    duration: 15
    """

  Scenario: Setting invalid duration
    Given the default configuration
    When I run `tam config duration=invalid_input`
    And I run `tam config`
    Then the exit status should be 0
    Then the output should contain:
    """
    duration: 25
    """

  Scenario: Changing the tomato duration
    Given there is no active tomato
    When I run `tam config duration=5`
    And I run `tam start`
    And I run `tam`
    Then the output should contain:
    """
    About 5 minutes
    """
    And the output should not contain:
    """
    About 25 minutes
    """

Mark mystery failure as pending

Feature: configuration

  Scenario: Outputting the currng config
    Given the default configuration
    When I run `tam config`
    Then the exit status should be 0
    Then the output should contain:
    """
    duration: 25
    """

  Scenario: Setting the tomato duration
    Given the default configuration
    When I run `tam config duration=15`
    And I run `tam config`
    Then the exit status should be 0
    Then the output should contain:
    """
    duration: 15
    """

  Scenario: Setting invalid duration
    Given the default configuration
    When I run `tam config duration=invalid_input`
    And I run `tam config`
    Then the exit status should be 0
    Then the output should contain:
    """
    duration: 25
    """

  Scenario: Changing the tomato duration
    # This works in the app, but not here?
    Given pending
    Given there is no active tomato
    When I run `tam config duration=5`
    And I run `tam start`
    And I run `tam`
    Then the output should contain:
    """
    About 5 minutes
    """
    And the output should not contain:
    """
    About 25 minutes
    """


@admin @search-for-buyers
Feature: Find a buyer

Scenario Outline: Correct users can search for buyers by brief id
  Given I am logged in as the existing <role> user
  And I click the 'Find a buyer by opportunity ID' link
  When I enter '18723' in the 'Find a buyer by opportunity ID' field
  And I click the 'Search' button
  Then I am on the 'Find a buyer' page
  And I see the 'User' summary table filled with:
    | Test user | 18723@user.marketplace.team |

  Examples:
    | role                    |
    | admin                   |
    | admin-ccs-category      |

Scenario Outline: Correct users cannot search for buyers by brief id
  Given I am logged in as the existing <role> user
  Then I don't see the 'Find a buyer by opportunity ID' link
  When I visit the /admin/buyers page
  Then I am on the 'You don’t have permission to perform this action' page

  Examples:
    | role                      |
    | admin-framework-manager   |
    | admin-ccs-sourcing        |
    | admin-manager             |
    | admin-ccs-data-controller |

Delete feature which is unit tested


Feature: To Test Checkout Functionality with Logged user and with anonomys user

  Background:
    Given User is on Home Page

  Scenario: To Checkout with valid credentials
    When User Navigate to LogIn Page
    And User enters UserName and Password
    And User Select Product
    And User Press Add To Cart
    And User Press Go to Chekout
    Then User See  Checkout Cart
    Then User Will Close The driver

  Scenario: To Checkout with anonomys User
    When User Select Product
    And User Press Add To Cart
    And User Press Go to Chekout
    Then User See  Checkout Cart
    Then User Will Close The driver

Add Another Scenario in a checkout

Feature: To Test Checkout Functionality with Logged user and with anonomys user

  Background:
    Given User is on Home Page

  Scenario: To Checkout with valid credentials
    When User Navigate to LogIn Page
    And User enters UserName and Password
    And User Select Product
    And User Press Add To Cart
    And User Press Go to Chekout
    Then User See  Checkout Cart
    Then User Will Close The driver

  Scenario: To Checkout with anonomys User
    When User Select Product
    And User Press Add To Cart
    And User Press Go to Chekout
    Then User See  Checkout Cart
    Then User Will Close The driver

    Scenario: To Check That Checkout button is already exist
    When User Navigate to LogIn Page
    And User enters UserName and Password
    And User Select Product
    And User Press Add To Cart
    And User Press Go to Chekout


Feature: Generating thumbnails

  Scenario: Basic useage
    Given a fixture app "automatic-clowncar-app"
    Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
    When I cd to "build"
    #Then the following files should not exist:
    #  | images/photos/test_image.jpg |
    Then the following files should exist:
      | images/photos/test-image/test-image-small.jpg  |
      | images/photos/test-image/test-image-medium.jpg |

Add feature for preview mode

Feature: Generating thumbnails

  Scenario: Basic useage during build
    Given a fixture app "automatic-clowncar-app"
    Given a successfully built app at "automatic-clowncar-app" with flags "--verbose"
    When I cd to "build"
    #Then the following files should not exist:
    #  | images/photos/test_image.jpg |
    Then the following files should exist:
      | images/photos/test-image/test-image-small.jpg  |
      | images/photos/test-image/test-image-medium.jpg |

  Scenario: Basic useage during preview
    Given a fixture app "automatic-clowncar-app"
    And the Server is running at "automatic-clowncar-app"
    When I go to "/images/photos/test-image/test-image-small.jpg"
    Then the content type should be "image/jpeg"
    When I go to "/images/photos/test-image/test-image-medium.jpg"
    Then the content type should be "image/jpeg"


Feature: check

Scenario: Install grin and bottle
    Given I use "standard-2.7" environment
    Given I execute pyg install bottle
    Then the return code is 0
    Given I execute pyg install grin
    Then the return code is 0

Scenario: Check Uninstalled packages
    Given I use "standard-2.7" environment
    When I execute pyg check <pkg>
    Then one line matches False
    Then the return code is 0

        Examples:
            | pkg       |
            | bottle    |
            | flask     |
            | ZODB3     |
            | gevent    |

Scenario: Check Installed packages
    Given I use "standard-2.7" environment
    When I execute pyg check <pkg>
    Then one line matches True
    Then the return code is 0

    Examples:
        | pkg       |
        | bottle    |
        | grin      |

Fix bad element in some test

Feature: check

Scenario: Install grin and bottle
    Given I use "standard-2.7" environment
    Given I execute pyg install bottle
    Then the return code is 0
    Given I execute pyg install grin
    Then the return code is 0

Scenario: Check Uninstalled packages
    Given I use "standard-2.7" environment
    When I execute pyg check <pkg>
    Then one line matches False
    Then the return code is 0

        Examples:
            | pkg       |
            | invalid   |
            | flask     |
            | ZODB3     |
            | gevent    |

Scenario: Check Installed packages
    Given I use "standard-2.7" environment
    When I execute pyg check <pkg>
    Then one line matches True
    Then the return code is 0

    Examples:
        | pkg       |
        | bottle    |
        | grin      |


Feature: Topology editor: Ensure tests environment

  Scenario: Ensure tests environment
    Given I am authenticated with "ADMIN" role
    And I cleanup archives
    And I upload CSAR from path "../../a4c/target/it-artifacts/tosca-normative-types-1.0.0-SNAPSHOT.csar"
    And I upload CSAR from path "../../a4c/target/it-artifacts/tosca-base-types-1.0.csar"
    And I upload CSAR from path "../../a4c/target/it-artifacts/java-types-1.0.csar"

Fix archive relative paths so they do not depends on checkout location.

Feature: Topology editor: Ensure tests environment

  Scenario: Ensure tests environment
    Given I am authenticated with "ADMIN" role
    And I cleanup archives

    And I upload CSAR from path "../target/it-artifacts/tosca-normative-types-1.0.0-SNAPSHOT.csar"
    And I upload CSAR from path "../target/it-artifacts/tosca-base-types-1.0.csar"
    And I upload CSAR from path "../target/it-artifacts/java-types-1.0.csar"


@user
Feature: Ernest user list

  Scenario: Non logged user listing
    Given I setup ernest with target "https://ernest.local"
    And I logout
    When I run ernest with "user list"
    Then The output should contain "You're not allowed to perform this action, please log in"

  Scenario: Logged user listing
    Given I setup ernest with target "https://ernest.local"
    When I'm logged in as "usr" / "secret123"
    And I run ernest with "user list"
    Then The output should contain "usr"
    And The output should not contain "ci_admin"

  Scenario: Admin user listing
    Given I setup ernest with target "https://ernest.local"
    When I'm logged in as "ci_admin" / "secret123"
    And I run ernest with "user list"
    Then The output should contain "usr"
    And The output should contain "ci_admin"

Fix integration tests on user list

@user
Feature: Ernest user list

  Scenario: Non logged user listing
    Given I setup ernest with target "https://ernest.local"
    And I logout
    When I run ernest with "user list"
    Then The output should contain "You're not allowed to perform this action, please log in"

  Scenario: Logged user listing
    Given I setup ernest with target "https://ernest.local"
    When I'm logged in as "usr" / "secret123"
    And I run ernest with "user list"
    Then The output should contain "usr"
    Then The output should contain "ci_admin"
    And The output should not contain "local"

  Scenario: Admin user listing
    Given I setup ernest with target "https://ernest.local"
    When I'm logged in as "ci_admin" / "secret123"
    And I run ernest with "user list"
    Then The output should contain "usr"
    And The output should contain "ci_admin"
    And The output should contain "local"


Feature: Startup performance

    Scenario Outline: Notifier starts in a reasonable time frame
        Given I launch an app with configuration:
            | bugsnag | <config> |
        And I click "performance-metrics"
        Then the total requests received by the server matches:
            | events  | 1        |
        Then the headers of every event request contains:
            | Bugsnag-API-Key   | 6425093c6530f554a9897d2d7d38e248 |
            | Content-Type      | application/json                 |
            | Bugsnag-Integrity | {BODY_SHA1}                      |
        Then the event metadata "performance.startupTime" is less than 100

        Examples:
            | config          |
            | default         |
            | complex-config  |

Increase startup threshold for congested/slow CI compute

Feature: Startup performance

    Scenario Outline: Notifier starts in a reasonable time frame
        Given I launch an app with configuration:
            | bugsnag | <config> |
        And I click "performance-metrics"
        Then the total requests received by the server matches:
            | events  | 1        |
        Then the headers of every event request contains:
            | Bugsnag-API-Key   | 6425093c6530f554a9897d2d7d38e248 |
            | Content-Type      | application/json                 |
            | Bugsnag-Integrity | {BODY_SHA1}                      |
        Then the event metadata "performance.startupTime" is less than 150

        Examples:
            | config          |
            | default         |
            | complex-config  |


@_smoke-tests
Feature: Buyer user journey through Digital Marketplace

Scenario: User can see the main links on the landing page
  Given I am on the homepage
  Then I see the link to 'Find cloud technology and support'
  And I see the link to 'Buy physical datacentre space for legacy systems'
  And I see the link to 'Find an individual specialist'
  And I see the link to 'Find a team to provide an outcome'
  And I see the link to 'Find user research participants'
  And I see the link to 'Find a user research lab'
  And I see the link to 'View Digital Outcomes and Specialists opportunities'

Add checks for supplier account creation link

@_smoke-tests
Feature: Buyer user journey through Digital Marketplace

Scenario: User can see the main links on the landing page
  Given I am on the homepage
  Then I see the link to 'Find cloud technology and support'
  And I see the link to 'Buy physical datacentre space for legacy systems'
  And I see the link to 'Find an individual specialist'
  And I see the link to 'Find a team to provide an outcome'
  And I see the link to 'Find user research participants'
  And I see the link to 'Find a user research lab'
  And I see the link to 'View Digital Outcomes and Specialists opportunities'
  And I see the link to 'Create a supplier account'


@shard_3
Feature: CMS.Video Component Editor
  As a course author, I want to be able to create video components.

  Scenario: User can view Video metadata
    Given I have created a Video component
    And I edit the component
    Then I see the correct video settings and default values

  # Safari has trouble saving values on Sauce
  @skip_safari
  Scenario: User can modify Video display name
    Given I have created a Video component
    And I edit the component
    Then I can modify the display name
    And my video display name change is persisted on save

  # Sauce Labs cannot delete cookies
  @skip_sauce
  Scenario: Captions are hidden when "show captions" is false
    Given I have created a Video component with subtitles
    And I have set "show captions" to False
    Then when I view the video it does not show the captions

  # Sauce Labs cannot delete cookies
  @skip_sauce
  Scenario: Captions are shown when "show captions" is true
    Given I have created a Video component with subtitles
    And I have set "show captions" to True
    Then when I view the video it does show the captions

Disable non-deterministic video caption test to get stability on master

@shard_3
Feature: CMS.Video Component Editor
  As a course author, I want to be able to create video components.

  Scenario: User can view Video metadata
    Given I have created a Video component
    And I edit the component
    Then I see the correct video settings and default values

  # Safari has trouble saving values on Sauce
  @skip_safari
  Scenario: User can modify Video display name
    Given I have created a Video component
    And I edit the component
    Then I can modify the display name
    And my video display name change is persisted on save

  # Disabling this 10/7/13 due to nondeterministic behavior
  # in master.  The failure seems to occur when YouTube does
  # not respond quickly enough, so that the video player
  # doesn't load.
  #
  # Sauce Labs cannot delete cookies
  #  @skip_sauce
  #Scenario: Captions are hidden when "show captions" is false
  #  Given I have created a Video component with subtitles
  #  And I have set "show captions" to False
  #  Then when I view the video it does not show the captions

  # Sauce Labs cannot delete cookies
  @skip_sauce
  Scenario: Captions are shown when "show captions" is true
    Given I have created a Video component with subtitles
    And I have set "show captions" to True
    Then when I view the video it does show the captions


@no-clobber
Feature: vagrant-adam validations
  In order to avoid configuration mistakes for vagrant-adam commands
  As a user
  I should see proper validation errors

  Scenario: raises error if url of file doesnt exist
    Given a Vagrantfile with a adam.provision_url of "https://github.com/petems/vagrant-adam/this_file_doesnt_exist.sh"
    When I run `bundle exec vagrant up`
    Then the exit status should not be 0
    And the output should contain "The requested URL returned error: 404 Not Found"

  Scenario: raises error if path of file doesnt exist
    Given a Vagrantfile with a adam.provision_url of "/tmp/foo_bar_baz.sh"
    When I run `bundle exec vagrant up`
    Then the exit status should not be 0
    And the output should contain "Couldn't open file /tmp/foo_bar_baz.sh"

  Scenario:
    Given a Vagrantfile with no adam.provision_url
    And the environment variable PRE_PROV_URL is "/tmp/foo_bar_baz.sh"
    When I run `bundle exec vagrant up`
    Then the exit status should not be 0
    And the output should contain "Couldn't open file /tmp/foo_bar_baz.sh"

Change cucumber error detection spec...

@no-clobber
Feature: vagrant-adam validations
  In order to avoid configuration mistakes for vagrant-adam commands
  As a user
  I should see proper validation errors

  Scenario: raises error if url of file doesnt exist
    Given a Vagrantfile with a adam.provision_url of "https://github.com/petems/vagrant-adam/this_file_doesnt_exist.sh"
    When I run `bundle exec vagrant up`
    Then the exit status should not be 0
    And the output should contain "The requested URL returned error: 404 Not Found"

  Scenario: raises error if path of file doesnt exist
    Given a Vagrantfile with a adam.provision_url of "/tmp/foo_bar_baz.sh"
    When I run `bundle exec vagrant up`
    Then the exit status should not be 0
    And the output should contain "File '/tmp/foo_bar_baz.sh' could not be found."

  Scenario:
    Given a Vagrantfile with no adam.provision_url
    And the environment variable PRE_PROV_URL is "/tmp/foo_bar_baz.sh"
    When I run `bundle exec vagrant up`
    Then the exit status should not be 0
    And the output should contain "Couldn't open file /tmp/foo_bar_baz.sh"


Feature: As a member of the public
  So that I can see where organisations with volunteer opportunities are located
  I would like to see a map of do-it volunteer opportunities

  @javascript
  Scenario: See a map of current doit volunteer opportunities
    Given that the doit_volunteer_opportunities flag is enabled
    And I visit the volunteer opportunities page
    And cookies are approved
    And I should see 16 markers in the map

Test for two types of markers is added

Feature: As a member of the public
  So that I can see where organisations with volunteer opportunities are located
  I would like to see a map of do-it volunteer opportunities

  @javascript
  Scenario: See a map of current doit volunteer opportunities
    Given that the doit_volunteer_opportunities flag is enabled
    And I visit the volunteer opportunities page
    And cookies are approved
    And I should see 16 markers in the map

  @javascript
  Scenario: See a map of current doit and harrow volunteer opportunities
    Given the following organisations exist:
      | name                      | description          | address        | postcode | website       |
      | Cats Are Us               | Animal Shelter       | 34 pinner road | HA1 4HZ  | http://a.com/ |
      | Indian Elders Association | Care for the elderly | 64 pinner road | HA1 4HZ  | http://b.com/ |
    Given the following users are registered:
      | email                         | password | organisation | confirmed_at         |
      | registered_user-1@example.com | pppppppp | Cats Are Us  | 2007-01-01  10:00:00 |
    Given the following volunteer opportunities exist:
      | title              | description                     | organisation              |
      | Litter Box Scooper | Assist with feline sanitation   | Cats Are Us               |
      | Office Support     | Help with printing and copying. | Indian Elders Association |
    Given that the doit_volunteer_opportunities flag is enabled
    And I visit the volunteer opportunities page
    And cookies are approved
    And I should see 18 markers in the map


Feature: aliasing

  `describe` and `context` are the default aliases for `example_group`.
  You can define your own aliases for `example_group` and give those
  custom aliases default metadata.

  RSpec provides a few built-in aliases:

    * `xdescribe` and `xcontext` add `:pending` metadata to the
      example group in order to temporarily disable the examples.
    * `fdescribe` and `fcontext` add `:focus` metadata to the
      example group in order to make it easy to temporarily
      focus the example group (when combined with `config.filter_run :focus`.)

  Scenario: Custom example group aliases with metadata
    Given a file named "nested_example_group_aliases_spec.rb" with:
    """ruby
    RSpec.configure do |c|
      c.alias_example_group_to :detail, :detailed => true
    end

    RSpec.detail "a detail" do
      it "can do some less important stuff" do
      end
    end

    RSpec.describe "a thing" do
      describe "in broad strokes" do
        it "can do things" do
        end
      end

      detail "something less important" do
        it "can do an unimportant thing" do
        end
      end
    end
    """
    When I run `rspec nested_example_group_aliases_spec.rb --tag detailed -fdoc`
    Then the output should contain:
      """
      a detail
        can do some less important stuff

      a thing
        something less important
      """

Correct note about x-aliases now skipping.

Feature: aliasing

  `describe` and `context` are the default aliases for `example_group`.
  You can define your own aliases for `example_group` and give those
  custom aliases default metadata.

  RSpec provides a few built-in aliases:

    * `xdescribe` and `xcontext` add `:skip` metadata to the
      example group in order to temporarily disable the examples.
    * `fdescribe` and `fcontext` add `:focus` metadata to the
      example group in order to make it easy to temporarily
      focus the example group (when combined with `config.filter_run :focus`.)

  Scenario: Custom example group aliases with metadata
    Given a file named "nested_example_group_aliases_spec.rb" with:
    """ruby
    RSpec.configure do |c|
      c.alias_example_group_to :detail, :detailed => true
    end

    RSpec.detail "a detail" do
      it "can do some less important stuff" do
      end
    end

    RSpec.describe "a thing" do
      describe "in broad strokes" do
        it "can do things" do
        end
      end

      detail "something less important" do
        it "can do an unimportant thing" do
        end
      end
    end
    """
    When I run `rspec nested_example_group_aliases_spec.rb --tag detailed -fdoc`
    Then the output should contain:
      """
      a detail
        can do some less important stuff

      a thing
        something less important
      """


Feature: Scrolling app bar
    Top app bar should become visible when scrolling up and hidden when scrolling down on mobile

  Background:
    Given that I am on a page with lots of content
      And I'm browsing on a small screen

  Scenario: Scrolling down on a small screen
    When I scroll down
    Then The app bar disappears

  Scenario: Scrolling down on a large screen
    When I scroll down
    Then The app bar stays visible

  Scenario: Scrolling up on a small screen
    When I scroll up
    Then The app bar re-appears

Add Gherkin story for momentum scrolling

Feature: Scrolling app bar
    Top app bar should become visible when scrolling up and hidden when scrolling down on mobile

  Background:
    Given that I am on a page with lots of content
      And I'm browsing on a small screen

  Scenario: Scrolling down on a small screen
    When I scroll down
    Then The app bar disappears

  Scenario: Scrolling down on a large screen
    When I scroll down
    Then The app bar stays visible

  Scenario: Scrolling up on a small screen
    When I scroll up
    Then The app bar re-appears

  Scenario: Momentum scrolling works
  # Note: Can also test this on certain EPUB and PDF documents
    When I scroll with my finger very quickly
      And I lift my finger from the screen
    Then the contents of the page continue to move, as if on a slippery surface


Feature: wp-config

  Scenario: Default WordPress install with WP_CONFIG_PATH specified in environment variable
    Given a WP installation
    And a wp-config-override.php file:
      """
      <?php
      define('DB_NAME', 'wp_cli_test');
      define('DB_USER', 'wp_cli_test');
      define('DB_PASSWORD', 'password1');
      define('DB_HOST', '127.0.0.1');
      define('DB_CHARSET', 'utf8');
      define('DB_COLLATE', '');
      $table_prefix = 'wp_';

      // Provide custom define in override only that we can test against
      define('TEST_CONFIG_OVERRIDE', 'success');

      if ( !defined('ABSPATH') )
        define('ABSPATH', dirname(__FILE__) . '/');
      require_once(ABSPATH . 'wp-settings.php');
      """

    When I try `wp eval "echo 'TEST_CONFIG_OVERRIDE => ' . TEST_CONFIG_OVERRIDE;"`
    Then STDOUT should contain:
      """
      TEST_CONFIG_OVERRIDE => TEST_CONFIG_OVERRIDE
      """
    And STDERR should contain:
      """
      Use of undefined constant TEST_CONFIG_OVERRIDE
      """

    When I run `WP_CONFIG_PATH=wp-config-override.php wp eval "echo 'TEST_CONFIG_OVERRIDE => ' . TEST_CONFIG_OVERRIDE;"`
    Then STDERR should be empty
    And STDOUT should contain:
      """
      TEST_CONFIG_OVERRIDE => success
      """

Add missing newline at EOF


Feature: Authenticating users

  In order to use the website
  As a user
  I should be able to sign up & sign in

  Scenario: Signing up
    Given I am on the homepage
    When I follow "Sign up"
    And I fill in "Email" with "john@doe.com"
    And I fill in "Password" with "password"
    And I fill in "Password confirmation" with "password"
    And I press "Sign up"
    Then I should see "You have signed up successfully."

  Scenario: Signing in & Signing out
    Given I am registered
    And I am on the homepage
    When I follow "Sign in"
    And I fill in "Email" with "john@doe.com"
    And I fill in "Password" with "password"
    And I press "Sign in"
    Then I should see "Signed in successfully."
    Given I am on the homepage
    When I follow "Sign out"
    Then I should see "Signed out successfully."

Add Scenario: Sign in thru Facebook.

Feature: Authenticating users

  In order to use the website
  As a user
  I should be able to sign up & sign in

  Scenario: Signing up
    Given I am on the homepage
    When I follow "Sign up"
    And I fill in "Email" with "john@doe.com"
    And I fill in "Password" with "password"
    And I fill in "Password confirmation" with "password"
    And I press "Sign up"
    Then I should see "You have signed up successfully."

  Scenario: Signing in & Signing out
    Given I am registered
    And I am on the homepage
    When I follow "Sign in"
    And I fill in "Email" with "john@doe.com"
    And I fill in "Password" with "password"
    And I press "Sign in"
    Then I should see "Signed in successfully."
    Given I am on the homepage
    When I follow "Sign out"
    Then I should see "Signed out successfully."

@omniauth_test
  Scenario: Sign in thru Facebook
    Given I am on the homepage
    And I follow "Sign in with Facebook"
    Then I should see "Successfully authorized from Facebook account."


Feature: engine named routes

  Generated requeset specs inside a Rails Engine is able to use route and url helpers.

  Scenario: include engine route helpers
    Given a file named "spec/requests/widgets_spec.rb" with:
      """ruby
      require "rails_helper"

      # A very simple Rails engine
      module MyEngine
        class Engine < ::Rails::Engine
          isolate_namespace MyEngine
        end

        class LinksController < ::ActionController::Base
          def index
            render plain: 'hit_engine_route'
          end
        end
      end

      MyEngine::Engine.routes.draw do
        resources :links, :only => [:index]
      end

      Rails.application.routes.draw do
        mount MyEngine::Engine => "/my_engine"
      end

      module MyEngine
        RSpec.describe "Links", :type => :request do

          include Engine.routes.url_helpers

          it "redirects to a random widget" do
            get links_url
            expect(response.body).to eq('hit_engine_route')
          end
        end
      end
      """
    When I run `rspec spec`
    Then the example should pass

  Scenario: do not include engine route helpers
    Given a file named "spec/requests/widgets_spec.rb" with:
      """ruby
      require "rails_helper"

      # A very simple Rails engine
      module MyEngine
        class Engine < ::Rails::Engine
          isolate_namespace MyEngine
        end

        class LinksController < ::ActionController::Base
          def index
            render plain: 'hit_engine_route'
          end
        end
      end

      MyEngine::Engine.routes.draw do
        resources :links, :only => [:index]
      end

      Rails.application.routes.draw do
        mount MyEngine::Engine => "/my_engine"
      end

      module MyEngine
        RSpec.describe "Links", :type => :request do

          it "redirects to a random widget" do
            get links_url
            expect(response.body).to eq('hit_engine_route')
          end
        end
      end
      """
    When I run `rspec spec`
    Then the example should fail

Update feature test with PR feedback

Feature: engine named routes

  Request specs inside a Rails Engine can include the engines routes to use url helpers.

  Scenario: using engine route helpers
    Given a file named "spec/requests/widgets_spec.rb" with:
      """ruby
      require "rails_helper"

      # A very simple Rails engine
      module MyEngine
        class Engine < ::Rails::Engine
          isolate_namespace MyEngine
        end

        class LinksController < ::ActionController::Base
          def index
            render plain: 'hit_engine_route'
          end
        end
      end

      MyEngine::Engine.routes.draw do
        resources :links, :only => [:index]
      end

      Rails.application.routes.draw do
        mount MyEngine::Engine => "/my_engine"
      end

      module MyEngine
        RSpec.describe "Links", :type => :request do
          include Engine.routes.url_helpers

          it "redirects to a random widget" do
            get links_url
            expect(response.body).to eq('hit_engine_route')
          end
        end
      end
      """
    When I run `rspec spec`
    Then the example should pass


Feature: spotlight

  @normal
  Scenario: I can access the homepage
    When I GET https://spotlight.{PP_APP_DOMAIN}/performance
    Then I should receive an HTTP 200
      And I should see a strong ETag

Use full app domain for Spotlight

Feature: spotlight

  @normal
  Scenario: I can access the homepage
    When I GET https://spotlight.{PP_FULL_APP_DOMAIN}/performance
    Then I should receive an HTTP 200
      And I should see a strong ETag


Feature: Request times plugin
  In order to have a plugin to play around with
  As user
  I want to be able to collect the amount of time it is taking to make a given request

  @wip @plugin
  Scenario: I should be able to define a plugin that tracks the request times for each request
    Given I have a application I want to track
    And I created the following plugin
    """
      Nark::Plugin.define :request_times do |plugin|
        plugin.variables :last_request_time => nil
        plugin.variables :request_times => []

        plugin.add_hook :before_call do |env|
          @start_time = Time.now
        end

        plugin.add_hook :after_call do |status, header, body, env|
          plugin.request_times << { url: env['PATH_INFO'], total: (Time.now - @start_time) }
          plugin.last_request_time = (Time.now - @start_time)
        end
      end
    """
    When I request a page
    And the last request should store the url
    And the last request should store the total amount of time a request took

Tweak the request times plugin scenario

Feature: Request times plugin
  In order to have a plugin to play around with
  As a plugin developer
  I want to be able to collect the amount of time it is taking to make a given request

  @plugin
  Scenario: I should be able to define a plugin that tracks the request times for each request
    Given I have a application I want to track
    And I created the following plugin
    """
      Nark::Plugin.define :request_times do |plugin|
        plugin.variables :last_request_time => nil
        plugin.variables :request_times => []

        plugin.add_hook :before_call do |env|
          @start_time = Time.now
        end

        plugin.add_hook :after_call do |status, header, body, env|
          plugin.request_times << { url: env['PATH_INFO'], total: (Time.now - @start_time) }
          plugin.last_request_time = (Time.now - @start_time)
        end
      end
    """
    When I request a page
    And the last request should store the url
    And the last request should store the total amount of time a request took


Feature: Teacher navigates using left pane

  As a teacher
  I want to visit various pages using left pane
  In order to make navigation more effective

  Background:
    Given The default project and jnlp resources exist using factories
    And the following teachers exist:
      | login    | password | first_name   | last_name |
      | teacher  | teacher  | John         | Nash      |

    And the following classes exist:
      | name       | teacher | class_word   |
      | My Class   | teacher | PhysicsClass |

   And I login with username: teacher

  @javascript
  Scenario: Teachers can see their class name
    Then I should see "My Class"

  @javascript
  Scenario: Teacher visits Student Roster page
    When I follow "My Class"
    And I follow "Student Roster"
    Then I should be on "Student Roster" page for "My Class"

  @javascript
  Scenario: Teacher visits Class Setup page
    When I follow "My Class"
    And I follow "Class Setup"
    Then I should be on the class edit page for "My Class"

  @javascript
  Scenario: Teacher visits Materials page
    When I follow "My Class"
    And I follow "Materials"
    Then I should be on Instructional Materials page for "My Class"

#  @pending
#  Scenario: Teacher visits Full Status page
#    When I follow "My Class"
#    And I follow "Full Status"
#    Then I should see Full Status page of "My Class"

Modify feature test for left panel navigation

Feature: Teacher navigates using left pane

  As a teacher
  I want to visit various pages using left pane
  In order to make navigation more effective

  Background:
    Given The default project and jnlp resources exist using factories
    And the following teachers exist:
      | login    | password | first_name   | last_name |
      | teacher  | teacher  | John         | Nash      |

    And the following classes exist:
      | name       | teacher | class_word   |
      | My Class   | teacher | PhysicsClass |

   And I login with username: teacher

  @javascript
  Scenario: Teachers can see their class name
    Then I should see "My Class"

  @javascript
  Scenario: Teacher visits Student Roster page
    When I follow "My Class"
    And I follow "Student Roster"
    Then I should be on "Student Roster" page for "My Class"

  @javascript
  Scenario: Teacher visits Class Setup page
    When I follow "My Class"
    And I follow "Class Setup"
    Then I should be on the class edit page for "My Class"

  @javascript
  Scenario: Teacher visits Materials page
    When I follow "My Class"
    And I follow "Materials"
    Then I should be on Instructional Materials page for "My Class"

  @javascript
  Scenario: Teacher visits Full Status page
    When I follow "My Class"
    And I follow "Full Status"
    Then I should be on the full status page for "My Class"


Feature: wrt-ux-app
 Scenario: Crosswalk WebApp Touch Gesture Click
  When I launch "XWalkViewShell" with "org.xwalk.core.xwview.shell" and "XWalkViewShellActivity" on android
    And I edit index 0 EditText to input "http://www.w3.org"
    And I press "enter" hardware key
   Then I should see view "text=World Wide Web Consortium (W3C)" in 60 seconds
    And I click view "className=android.widget.TextView^^^text=New Tab"
    And I edit index 0 EditText to input "http://www.intel.com"
    And I press "enter" hardware key
   Then I should see view "text=Intel: Tablet, 2in1, Laptop, Desktop, Smartphone, Server, Embedded" in 60 seconds

Update test steps for coreshell

Feature: wrt-ux-app
 Scenario: Crosswalk WebApp Touch Gesture Click
  When I launch "XWalkViewShell" with "org.xwalk.core.xwview.shell" and "XWalkViewShellActivity" on android
    And I edit index 0 EditText to input "http://www.w3.org"
    And I press "enter" hardware key
   Then I should see view "text=World Wide Web Consortium (W3C)" in 60 seconds
    And I click view "className=android.widget.TextView^^^text=New Tab"
    And I edit index 0 EditText to input "http://www.intel.com/content/www/us/en/homepage.html"
    And I press "enter" hardware key
   Then I should see view "text=Intel: Tablet, 2in1, Laptop, Desktop, Smartphone, Server, Embedded" in 60 seconds


@managing_channels
Feature: Selecting available locales for a channel
    In order to present stores website in different languages
    As an Administrator
    I want to be able to select available locales

    Background:
        Given the store has currency "Euro"
        And the store has locale "English (United States)"
        And I am logged in as an administrator

    @ui
    Scenario: Adding a new channel with locales
        Given I want to create a new channel
        When I specify its code as "MOBILE"
        And I name it "Mobile channel"
        And I make it available in "English (United States)"
        And I choose "Euro" as the base currency
        And I choose "English (United States)" as a default locale
        And I add it
        Then I should be notified that it has been successfully created
        And the channel "Mobile channel" should be available in "English (United States)"

    @ui
    Scenario: Adding locales to an existing channel
        Given the store operates on a channel named "Web Channel"
        And I want to modify this channel
        When I make it available in "English (United States)"
        And I save my changes
        Then I should be notified that it has been successfully edited
        And the channel "Web channel" should be available in "English (United States)"

Add scenarios for validating default locale for a channel

@managing_channels
Feature: Selecting available locales for a channel
    In order to present stores website in different languages
    As an Administrator
    I want to be able to select available locales

    Background:
        Given the store has currency "Euro"
        And the store has locale "English (United States)"
        And I am logged in as an administrator

    @ui
    Scenario: Adding a new channel with locales
        Given I want to create a new channel
        When I specify its code as "MOBILE"
        And I name it "Mobile channel"
        And I make it available in "English (United States)"
        And I choose "Euro" as the base currency
        And I choose "English (United States)" as a default locale
        And I add it
        Then I should be notified that it has been successfully created
        And the channel "Mobile channel" should be available in "English (United States)"

    @ui
    Scenario: Adding locales to an existing channel
        Given the store operates on a channel named "Web Channel"
        And I want to modify this channel
        When I make it available in "English (United States)"
        And I save my changes
        Then I should be notified that it has been successfully edited
        And the channel "Web channel" should be available in "English (United States)"

    @todo @ui
    Scenario: Being unable to disable locale used as the default one for a channel
        Given the store operates on a channel named "Web"
        And this channel allows to shop using the "English (United States)" locale
        And this channel uses the "English (United States)" locale as default
        When I try to disable the "English (United States)" locale for this channel
        Then I should be notified that the default locale should be enabled

    @todo @ui
    Scenario: Being unable to set disabled locale as a default one for a channel
        Given the store has locale "Polish (Poland)"
        And the store operates on a channel named "Web"
        And this channel allows to shop using the "English (United States)" locale
        And this channel uses the "English (United States)" locale as default
        When I try to choose "Polish (Poland)" locale as default for this channel
        Then I should be notified that the default locale should be enabled


# Copyright (c) 2010-2011 SUSE Linux Products GmbH.
# Licensed under the terms of the MIT license.

Feature: Test XML-RPC "api" namespace.

  Scenario: Public API test
    Given I am logged in via XML-RPC/api as user "admin" and password "admin"
    When I call getVersion, I should get "11.1" as result
    When I call systemVersion, I should get "1.7" as result
    When I call getApiNamespaces, I should get 39 namespaces
    When I call getApiNamespaceCallList, I should get 515 available api calls
    When I call getApiCallList, I should get 39 available groups

Fix No. of API calls to 516 after upstream added provisionVirtualGuest

# Copyright (c) 2010-2011 SUSE Linux Products GmbH.
# Licensed under the terms of the MIT license.

Feature: Test XML-RPC "api" namespace.

  Scenario: Public API test
    Given I am logged in via XML-RPC/api as user "admin" and password "admin"
    When I call getVersion, I should get "11.1" as result
    When I call systemVersion, I should get "1.7" as result
    When I call getApiNamespaces, I should get 39 namespaces
    When I call getApiNamespaceCallList, I should get 516 available api calls
    When I call getApiCallList, I should get 39 available groups


Feature: 3scale API

    Scenario: Check if 3scale staging url requires authentication
        Given 3scale staging pod is running
        When I access get_route API end point for 3scale without authorization
        Then I should get 400 status code as response

    @requires_authorization_token
    Scenario: Check the POST API  endpoint get-route returns the required information
        Given 3scale staging pod is running
        When I make a post call with proper authentication token
        Then I should get json object

Add functioanlity to get authetication token for 3scale tests

Feature: 3scale API

    Scenario: Check if 3scale staging url requires authentication
        Given 3scale staging pod is running
        When I access get_route API end point for 3scale without authorization
        Then I should get 400 status code as response

    @requires_authorization_token
    Scenario: Check the POST API  endpoint get-route returns the required information
        When I acquire the authorization token
        Then I should get the proper authorization token
        Given 3scale staging pod is running
        When I make a post call with proper authentication token
        Then I should get json object


Feature: Show Select Edit Entries
    Add edit to each entry on the add entry screen.

    Scenario: Edit a post
        Given a post with id 1
        When I call edit_entry
        Then I see the edit entry screen for that entry

    Scenario: Submit an edit
        Given an edited post with id 1
        When I call submit_edit
        Then I see the updated entry

Add scenarios to .feature for lettuce tests

Feature: Add ability to edit entries
    Add edit to each entry on the add entry screen.

    Scenario: Anonymous user can't see add entry form
        Given an anonymous user
        When I view the home page
        Then I do not see the new entry form

    Scenario: Logged in user can see add entry form
        Given an authenticated user
        When I view the home page
        Then I do see the new entry form

    Scenario: Anonymous user can't see edit entry link
        Given an anonymous user
        And any text
        And an existing entry
        When I view the home page
        Then I do not see the edit entry link

    Scenario: Logged in user can see edit entry link
        Given an authenticated user
        And any text
        And an existing entry
        When I view the home page
        Then I do see the edit entry link

    Scenario: Anonymous user can't see edit entry form
        Given an anonymous user
        When I add '/edit/1' to the home page url
        Then I do not see the edit entry form

    Scenario: Logged in user can see edit entry form
        Given an anonymous user
        When I add '/edit/1' to the home page url
        Then I do see the edit entry form

    Scenario: Anonymous user cannot submit add form
        Given an anonymous user
        And the title "New Post"
        And the text "This is a new post"
        When I submit the add form
        Then I am redirected to the home page
        And I do not see my new entry

    Scenario: Logged in user can submit add form
        Given an authenticated user
        And the title "New Post"
        And the text "This is a new post"
        When I submit the add form
        Then I am redirected to the home page
        And I see my new entry

    Scenario: Anonymous user cannot submit edit entry form
        Given an anonymous user
        And the title "Edited Post"
        And the text "This is an edited post"
        When I submit the edit form
        Then I am redirected to the home page
        And I do not see my new entry

    Scenario: Logged in user can submit edit entry form
        Given an authenticated user
        And the title "Edited Post"
        And the text "This is an edited post"
        When I submit the edit form
        Then I am redirected to the home page
        And I see my new entry

    Scenario: Users can see colorized code samples
        Given text containing markdown and plain text
        And an existing entry
        When I view the home page
        Then I see code highlighted in color
        And I see plain text without color


@vcr @timecop
Feature: Generate membership metrics

  In order to track the health of our membership model
  As a member of the commercial team
  I want to generate various important metrics for display on a dashboard

  Background:
    Given the following members exist in CapsuleCRM:
      | level     |
      | sponsor   |
      | partner   |
      | partner   |
      | member    |
      | member    |
      | member    |
      | supporter |
      | supporter |
      | supporter |
      | supporter |
    And that time is frozen

  Scenario: Total number of members
    Then the following data should be stored in the "membership-count" metric
      """
      {
        "name": "membership-count",
        "time": "<%= @time.xmlschema %>",
        "value": 10,
      }
      """
    When the membership count job runs

  Scenario: Precentage of members per level
    Then the following data should be stored in the "membership-breakdown" metric
      """
      {
        "name": "membership-breakdown",
        "time": "<%= @time.xmlschema %>",
        "value": {
          "sponsor": 0.1,
          "partner": 0.2,
          "member": 0.3,
          "supporter": 0.4,
        },
      }
      """
    When the membership breakdown job runs

Remove JSON wrapping from feature files

@vcr @timecop
Feature: Generate membership metrics

  In order to track the health of our membership model
  As a member of the commercial team
  I want to generate various important metrics for display on a dashboard

  Background:
    Given the following members exist in CapsuleCRM:
      | level     |
      | sponsor   |
      | partner   |
      | partner   |
      | member    |
      | member    |
      | member    |
      | supporter |
      | supporter |
      | supporter |
      | supporter |
    And that time is frozen

  Scenario: Total number of members
    Then the following data should be stored in the "membership-count" metric
    """
    10
    """
    When the membership count job runs

  Scenario: Precentage of members per level
    Then the following data should be stored in the "membership-breakdown" metric
      """
      {
        "sponsor": 0.1,
        "partner": 0.2,
        "member": 0.3,
        "supporter": 0.4,
      }
      """
    When the membership breakdown job runs


Feature: Coach changes profile information
  Coach needs to be able to change their own profile information

  Background:
    Given I am signed in to Kolibri as a coach user
      And I am on my <username> *Profile > Details* page
      And facility is set up to allow learners and coaches to edit full names, usernames, and change their passwords

  Scenario: Coach changes username and full name
    When I click the *Edit* button
    Then I see the *Edit profile* page
    When I change my full name
      And I change my username
      And if my changes are valid (I did not leave the fields empty)
      And I click the “Save” button
    Then I see the *Profile details updated* snackbar notification
    When I go back to my *Profile > Details* page
    Then I see the new full name and username on the profile page
      And I see the new username in the user menu

    Scenario: Coach selects gender and birth year
    When I click the *Edit* button
    Then I see the *Edit profile* page
    When I select my gender
      And I select my birth year
      And I click the “Save” button
    Then I see the *Profile details updated* snackbar notification
    When I go back to my *Profile > Details* page
    Then I see my selected gender and birth year on the profile page

  Scenario: Coach changes password
    When I click the “Change password” link
    Then I see the “Change password” modal
    When I enter the new password
      And I re-enter the new password
      And if my changes are valid (I did not leave the fields empty, or entered two different passwords)
      And I click the “Update” button
    Then I see the *Your password has been changed* snackbar notification

Update gherkin scenario according to these changes

Feature: Coach changes profile information
  Coach needs to be able to change their own profile information

  Background:
    Given I am signed in to Kolibri as a coach user
      And I am on my <username> *Profile > Details* page

  Scenario: Coach changes username and full name
    When I click the *Edit* button
    Then I see the *Edit profile* page
    When I change my full name
      And I change my username
      And if my changes are valid (I did not leave the fields empty)
      And I click the “Save” button
    Then I see the *Profile details updated* snackbar notification
    When I go back to my *Profile > Details* page
    Then I see the new full name and username on the profile page
      And I see the new username in the user menu

    Scenario: Coach selects gender and birth year
    When I click the *Edit* button
    Then I see the *Edit profile* page
    When I select my gender
      And I select my birth year
      And I click the “Save” button
    Then I see the *Profile details updated* snackbar notification
    When I go back to my *Profile > Details* page
    Then I see my selected gender and birth year on the profile page

  Scenario: Coach changes password
    When I click the “Change password” link
    Then I see the “Change password” modal
    When I enter the new password
      And I re-enter the new password
      And if my changes are valid (I did not leave the fields empty, or entered two different passwords)
      And I click the “Update” button
    Then I see the *Your password has been changed* snackbar notification


Feature: Action Plan Reading
  As a visitor to the website
  I want to view an action plan
  So that I can understand the subject matter

  Scenario: Viewing a published action plan
    Given that there is an action plan
    And it is published
    When I view an action plan
    Then the action plan should be displayed

  Scenario: Viewing an unpublished action plan
    Given that I have a link to an action plan
    And it is unpublished
    When I visit the link
    Then I should see an error page

  Scenario: View welsh action plan
    Given I am viewing an action plan
    When I choose to view the Welsh version
    Then I should see an action plan in my language

Update the step definitions based on feedback.

Feature: Read an Action Plan
  As a visitor to the website
  I want to view an action plan
  So I can understand the subject matter

  Scenario: View a published action plan
    Given there is an action plan
    And it is published
    When I view the action plan
    Then the action plan should be displayed

  Scenario: View an unpublished action plan
    Given I have a link to an action plan
    And it is unpublished
    When I visit the link
    Then I should see an error page

  Scenario: View an action plan in Welsh
    Given I view an action plan
    When I view the Welsh version
    Then I should see the action plan in Welsh


# See https://github.com/silverstripe/silverstripe-subsites/issues/357
Feature: Insert an internal link into content
  As a CMS user
  I can insert internal links into my content
  So that I can direct users to different parts of my website

  Background:
    Given a "subsite" "Subsite B"
    And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content"
    And a "page" "Another page" with "URLSegment"="another-page", "Content"="My other page content"
    And I am logged in with "CMS_ACCESS_CMSMain" permissions
    Then I go to "admin/pages"
    And I click on "My page" in the tree

  @javascript
  Scenario: I can insert an internal link
    # See "insert-a-link.feature" from silverstripe/cms
    When I select "My page" in the "Content" HTML field
    And I press the "Insert link" HTML field button
    And I click "Page on this site" in the ".mce-menu" element
    Then I should see an "form#Form_editorInternalLink" element
    When I click "(Choose Page)" in the ".Select-multi-value-wrapper" element
    And I click "Another page" in the ".treedropdownfield__menu" element
    And I fill in "my desc" for "Link description"
    And I press the "Insert" button
    Then the "Content" HTML field should contain "<a title="my desc" href="[sitetree_link"
    And the "Content" HTML field should contain "My page"
    # Required to avoid "unsaved changes" browser dialog
    Then I press the "Save" button

FIX Update Behat assertion to use correct field label for SilverStripe 4.4

# See https://github.com/silverstripe/silverstripe-subsites/issues/357
Feature: Insert an internal link into content
  As a CMS user
  I can insert internal links into my content
  So that I can direct users to different parts of my website

  Background:
    Given a "subsite" "Subsite B"
    And a "page" "My page" with "URLSegment"="my-page", "Content"="My page content"
    And a "page" "Another page" with "URLSegment"="another-page", "Content"="My other page content"
    And I am logged in with "CMS_ACCESS_CMSMain" permissions
    Then I go to "admin/pages"
    And I click on "My page" in the tree

  @javascript
  Scenario: I can insert an internal link
    # See "insert-a-link.feature" from silverstripe/cms
    When I select "My page" in the "Content" HTML field
    And I press the "Insert link" HTML field button
    And I click "Page on this site" in the ".mce-menu" element
    Then I should see an "form#Form_editorInternalLink" element
    When I click "(Choose page)" in the ".Select-multi-value-wrapper" element
    And I click "Another page" in the ".treedropdownfield__menu" element
    And I fill in "my desc" for "Link description"
    And I press the "Insert" button
    Then the "Content" HTML field should contain "<a title="my desc" href="[sitetree_link"
    And the "Content" HTML field should contain "My page"
    # Required to avoid "unsaved changes" browser dialog
    Then I press the "Save" button


Feature: backdrop_read

  @normal
  Scenario: I can access Backdrop without a trailing slash
    When I GET https://www.{PP_APP_DOMAIN}/data/test/test?limit=1
    Then I should receive an HTTP 200

  @normal
  Scenario: I can access Backdrop with a trailing slash
    When I GET https://www.{PP_APP_DOMAIN}/data/test/test/
    Then I should receive an HTTP 301 redirect to /data/test/test

  # BUG: see https://www.pivotaltracker.com/story/show/67097376
  @normal, @knownfailing
  Scenario: I can access Backdrop with a trailing slash and query parameters
    When I GET https://www.{PP_APP_DOMAIN}/data/test/test/?limit=1
    Then I should receive an HTTP 301 redirect to www.{PP_APP_DOMAIN}/data/test/test?limit=1

Remove test for unsupported functionality

Feature: backdrop_read

  @normal
  Scenario: I can access Backdrop without a trailing slash
    When I GET https://www.{PP_APP_DOMAIN}/data/test/test?limit=1
    Then I should receive an HTTP 200

  # BUG: see https://www.pivotaltracker.com/story/show/67097376
  @normal, @knownfailing
  Scenario: I can access Backdrop with a trailing slash and query parameters
    When I GET https://www.{PP_APP_DOMAIN}/data/test/test/?limit=1
    Then I should receive an HTTP 301 redirect to www.{PP_APP_DOMAIN}/data/test/test?limit=1


Feature: Install Candidate

	Scenario: Install a default Candidate
		Given the default "grails" candidate is "2.1.0"
		When I enter "gvm install grails"
		Then the candidate "grails" version "2.1.0" is installed
		And I see "Done installing!"

	Scenario: Install a specific Candidate
		When I enter "gvm install grails 1.3.9"
		Then the candidate "grails" version "1.3.9" is installed
		And I see "Done installing!"

	Scenario: Install a Candidate version that does not exist
		When I enter "gvm install grails 1.4.4"
		Then I see "Stop! 1.4.4 is not a valid grails version."

	Scenario: Install a Candidate version that is already installed
		Given the candidate "grails" version "1.3.9" is already installed
		When I enter "gvm install grails 1.3.9"
		Then I see "Stop! grails 1.3.9 is already installed."

	Scenario: Abort installation on download of a corrupt Candidate archive
		Given the archive for candidate "grails" version "1.3.6" is corrupt
		When I enter "gvm install grails 1.3.6"
		Then I see "Stop! The download failed! Please try again."
		And the candidate "grails" version "1.3.6" is not installed
		And the archive for candidate "grails" version "1.3.6" is removed

Fix broken cucumber spec on abort for corrupt archive.

Feature: Install Candidate

	Scenario: Install a default Candidate
		Given the default "grails" candidate is "2.1.0"
		When I enter "gvm install grails"
		Then the candidate "grails" version "2.1.0" is installed
		And I see "Done installing!"

	Scenario: Install a specific Candidate
		When I enter "gvm install grails 1.3.9"
		Then the candidate "grails" version "1.3.9" is installed
		And I see "Done installing!"

	Scenario: Install a Candidate version that does not exist
		When I enter "gvm install grails 1.4.4"
		Then I see "Stop! 1.4.4 is not a valid grails version."

	Scenario: Install a Candidate version that is already installed
		Given the candidate "grails" version "1.3.9" is already installed
		When I enter "gvm install grails 1.3.9"
		Then I see "Stop! grails 1.3.9 is already installed."

	Scenario: Abort installation on download of a corrupt Candidate archive
		Given the archive for candidate "grails" version "1.3.6" is corrupt
		When I enter "gvm install grails 1.3.6"
		Then I see "Stop! The archive was corrupt and has been removed! Please try installing again."
		And the candidate "grails" version "1.3.6" is not installed
		And the archive for candidate "grails" version "1.3.6" is removed


Feature: Read an Action Plan
  As a visitor to the website
  I want to view an action plan
  So I can understand the subject matter

  Scenario: View a published action plan
    Given there is an action plan
    And it is published
    When I view the action plan
    Then the action plan should be displayed

  Scenario: View an unpublished action plan
    Given I have a link to an action plan
    And it is unpublished
    When I visit the link
    Then I should see an error page

  Scenario: View an action plan in Welsh
    Given I view an action plan
    When I view the Welsh version
    Then I should see the action plan in Welsh

Add scenario for translating article and change language not to mention an error page.

Feature: Read an action plan
  As a visitor to the website
  I want to view an action plan
  So I can understand the subject matter

  Scenario: View a published action plan
    Given there is an action plan
    And it is published
    When I view the action plan
    Then the action plan should be displayed

  Scenario: View an unpublished action plan
    Given I have a link to an action plan
    And it is unpublished
    When I visit the link
    Then I should see that the action plan is not found

  Scenario: View an action plan in Welsh
    When I view an action plan in Welsh
    Then I should see the action plan in Welsh

  Scenario outline: Translate an action plan
    Given I view an action plan in <original_language>
    When I translate the action plan into <translated_language>
    Then I should see the action plan in <translated_language>

  Examples:
  | original_language | translated_language |
  | English           | Welsh               |
  | Welsh             | English             |


@typical_usage
Feature: Update Vim plugins
  In order to automate boring steps,
  as a lazy Vim user,
  I want to use a declarative way to update my favorite Vim plugins.

  Background:
    Given a repository "foo" with versions "1.0.0 1.0.1 1.0.2"

  Scenario: Update with lockfile
    Given a flavorfile with:
      """ruby
      flavor '$foo_uri'
      """
    And a lockfile with:
      """
      $foo_uri (1.0.0)
      """
    When I run `vim-flavor update`
    Then it should pass
    And the lockfile is updated with:
      """
      $foo_uri (1.0.2)
      """
    And a bootstrap script is created in "$home/.vim"
    And a flavor "$foo_uri" version "1.0.2" is deployed to "$home/.vim"

Fix a scenario name a bit

@typical_usage
Feature: Update Vim plugins
  In order to automate boring steps,
  as a lazy Vim user,
  I want to use a declarative way to update my favorite Vim plugins.

  Background:
    Given a repository "foo" with versions "1.0.0 1.0.1 1.0.2"

  Scenario: Update with a lockfile
    Given a flavorfile with:
      """ruby
      flavor '$foo_uri'
      """
    And a lockfile with:
      """
      $foo_uri (1.0.0)
      """
    When I run `vim-flavor update`
    Then it should pass
    And the lockfile is updated with:
      """
      $foo_uri (1.0.2)
      """
    And a bootstrap script is created in "$home/.vim"
    And a flavor "$foo_uri" version "1.0.2" is deployed to "$home/.vim"


Feature: Learner take the exam
  learner to be able to take the exam

  Background:
    Given I am signed in to Kolibri as a Learner user
      And I have active and not started exam
      And I am on the *learn > classes > exam* page

  Scenario: Learner take the exam
    When I fill out all questions with answers
    Then That my answers are valid
    When I click *Submit exam* button
    Then The submit modal show up
    When I click *Submit exam* button
    Then I see exam completed

Edit some sentences at the learner take exam.

Feature: Learner take exam
  Learner can access the exam that has been assigneed by coach

  Background:
    Given I am signed in to Kolibri as a Learner user
      And I am on *learn > classes* page
      And I see an exam not started
      And I am on the *learn > classes > exam* page

  Scenario: Learner take an exam after it has been assigned
    When I fill out all questions with answers
    When I click *Submit exam* button
    Then The submit exam modal show up
    When I click *Submit exam* button
    Then I see exam completed


@RALLY_US5074

Feature: List-Attendance endpoint should return a list of all student attendances

  Scenario Outline: Check that I can get all attendances for a school
    Given I am logged in using "cgray" "cgray1234" to realm "IL"
    When I navigate to <url> with <id>
    Then I should receive a valid return code
    And I can see all the attendances in a school
  Examples:
    | url                                                                         | id                                     |
    | "/schools/#{id}/studentSchoolAssociations/students/attendances"             | "92d6d5a0-852c-45f4-907a-912752831772" |
# TODO: Fix this - offset makes API throw out of bound exception.`
#    | "/schools/#{id}/studentSchoolAssociations/students/attendances?offset=50"   | "92d6d5a0-852c-45f4-907a-912752831772" |

Remove TODO that is no longer relevant

@RALLY_US5074

Feature: List-Attendance endpoint should return a list of all student attendances

  Scenario Outline: Check that I can get all attendances for a school
    Given I am logged in using "cgray" "cgray1234" to realm "IL"
    When I navigate to <url> with <id>
    Then I should receive a valid return code
    And I can see all the attendances in a school
  Examples:
    | url                                                                         | id                                     |
    | "/schools/#{id}/studentSchoolAssociations/students/attendances"             | "92d6d5a0-852c-45f4-907a-912752831772" |
    | "/schools/#{id}/studentSchoolAssociations/students/attendances?offset=50"   | "92d6d5a0-852c-45f4-907a-912752831772" |


Feature: Use public pages as a subscriber
  In order to interact with a phplist installation
  As a subscriber
  I need to be able to view and use public pages

Scenario: Use public pages links
    Given I am on "/lists"
    Then I should see "Subscribe to our Newsletter"
    Then I should see "Update your preferences"
    Then I should see "Unsubscribe from our Newsletters"
    Then I should see "Contact the administrator"
    Given I follow "Subscribe to our Newsletter"
    Then I should see "Email address *"
    Given I go back
    And I follow "Update your preferences"
    Then I should see "This page requires a personal identification that can be found on each message that you receive."
    Given I go back
    And I follow "Unsubscribe from our Newsletters"
    Then I should see "Please enter a valid email address:"

Switch to 'And' from 'Then'

Feature: Use public pages as a subscriber
  In order to interact with a phplist installation
  As a subscriber
  I need to be able to view and use public pages

Scenario: Use public pages links
    Given I am on "/lists"
    Then I should see "Subscribe to our Newsletter"
    And I should see "Update your preferences"
    And I should see "Unsubscribe from our Newsletters"
    And I should see "Contact the administrator"
    Given I follow "Subscribe to our Newsletter"
    Then I should see "Email address *"
    Given I go back
    And I follow "Update your preferences"
    Then I should see "This page requires a personal identification that can be found on each message that you receive."
    Given I go back
    And I follow "Unsubscribe from our Newsletters"
    Then I should see "Please enter a valid email address:"


# Copyright (c) 2016 SUSE LLC
# Licensed under the terms of the MIT license.

Feature: Test the remote commands via salt
  In Order to test action picked up state
  As an authorized user
  I want to verify that the remote command show status picked up as long as the command is running

  Scenario: Run a remote command from the systems overview page
    Given I am authorized as "testing" with password "testing"
    And I follow "Systems"
    Then I follow this minion link
    When I follow "Remote Command" in the content area
    And I enter as remote command this script in
      """
      #!/bin/bash
      while [ ! -f /tmp/PICKED-UP.test ]
      do
        sleep 1
      done
      rm /tmp/PICKED-UP.test
      """
    And I click on "Schedule"
    Then I should see a "Remote Command has been scheduled successfully" text
    And I follow "Events" in the content area
    And I follow "History" in the content area
    And I wait for "1" seconds
    Then I follow first "Run an arbitrary script scheduled by testing" in the content area
    And I should see a "This action's status is: Picked Up" text
    And I create picked-up test file on sle minion
    And I follow "History" in the content area
    Then I follow first "Run an arbitrary script scheduled by testing" in the content area
    And I should see a "This action's status is: Completed" text

Add more flexibility with timeout.

# Copyright (c) 2016 SUSE LLC
# Licensed under the terms of the MIT license.

Feature: Test the remote commands via salt
  In Order to test action picked up state
  As an authorized user
  I want to verify that the remote command show status picked up as long as the command is running

  Scenario: Run a remote command from the systems overview page
    Given I am authorized as "testing" with password "testing"
    And I follow "Systems"
    Then I follow this minion link
    When I follow "Remote Command" in the content area
    And I enter as remote command this script in
      """
      #!/bin/bash
      while [ ! -f /tmp/PICKED-UP.test ]
      do
        sleep 1
      done
      rm /tmp/PICKED-UP.test
      """
    And I click on "Schedule"
    Then I should see a "Remote Command has been scheduled successfully" text
    And I follow "Events" in the content area
    And I follow "History" in the content area
    And I wait for "1" seconds
    Then I follow first "Run an arbitrary script scheduled by testing" in the content area
    And I should see a "This action's status is: Picked Up" text
    And I create picked-up test file on sle minion
    And I wait for "6" seconds
    And I follow "History" in the content area
    Then I follow first "Run an arbitrary script scheduled by testing" in the content area
    And I should see a "This action's status is: Completed" text


Feature: CLI Cache

  Scenario: Remove all files from cache directory
    Given an empty cache

    When I run `wp cli cache clear`
    Then STDOUT should be:
      """
      Success: Cache cleared.
      """

  Scenario: Remove all but newest files from cache directory
    Given an empty cache

    When I run `wp cli cache prune`
    Then STDOUT should be:
      """
      Success: Cache pruned.
      """

Test `wp cache clear` command

Feature: CLI Cache

  Scenario: Remove all files from cache directory
    Given an empty cache

    When I run `wp core download --path={CACHE_DIR} --version=4.9 --force`
    And I run `wp core download --path={CACHE_DIR} --version=4.9 --force --locale=de_DE`
    Then the {SUITE_CACHE_DIR}/core directory should contain:
      """
      wordpress-4.9-de_DE.tar.gz
      wordpress-4.9-en_US.tar.gz
      """

    When I run `wp cli cache clear`
    Then STDOUT should be:
      """
      Success: Cache cleared.
      """
    And STDERR should be empty
    And the {SUITE_CACHE_DIR}/core directory should not contain:
      """
      wordpress-4.9-de_DE.tar.gz
      """
    And the {SUITE_CACHE_DIR}/core directory should not contain:
      """
      wordpress-4.9-en_US.tar.gz
      """

  Scenario: Remove all but newest files from cache directory
    Given an empty cache

    When I run `wp cli cache prune`
    Then STDOUT should be:
      """
      Success: Cache pruned.
      """


Feature: Inbox task association
  As someone collecting tasks
  I can associate a task to another one
  In order to deal with complex tasks requiring several steps

  Scenario: Dropping a task on another one makes it a child
    Given I display the "Inbox" page
    And there is an item named "Buy apples" in the central list
    When I drop the item on "Errands" in the central list
    And I list the items
    Then the list is:
       | display                                       |
       | Errands                                       |
       | Errands / Buy apples                          |
       | "The Pragmatic Programmer" by Hunt and Thomas |
       | Buy cheese                                    |
       | Buy pears                                     |
       | 21/04/2014 14:49                              |

Add acceptance test for dropping tasks on the inbox

Feature: Inbox task association
  As someone collecting tasks
  I can associate a task to another one
  In order to deal with complex tasks requiring several steps

  Scenario: Dropping a task on another one makes it a child
    Given I display the "Inbox" page
    And there is an item named "Buy apples" in the central list
    When I drop the item on "Errands" in the central list
    And I list the items
    Then the list is:
       | display                                       |
       | Errands                                       |
       | Errands / Buy apples                          |
       | "The Pragmatic Programmer" by Hunt and Thomas |
       | Buy cheese                                    |
       | Buy pears                                     |
       | 21/04/2014 14:49                              |

  @wip
  Scenario: Dropping a child task on the inbox makes it top-level
    Given I display the "Inbox" page
    And there is an item named "Errands / Buy apples" in the central list
    When I drop the item on "Inbox" in the page list
    And I list the items
    Then the list is:
       | display                                       |
       | Errands                                       |
       | Buy apples                                    |
       | "The Pragmatic Programmer" by Hunt and Thomas |
       | Buy cheese                                    |
       | Buy pears                                     |
       | 21/04/2014 14:49                              |


Feature: Regression tests

  @requires_authorization_token
  Scenario: Check the issue #847 (https://github.com/openshiftio/openshift.io/issues/847)
    Given System is running
    When I acquire the authorization token
    Then I should get the proper authorization token
    When I send Python package manifest requirements_click_compatible_with_6_7.txt to stack analysis with authorization token
    Then I should get 200 status code
    When I wait for stack analysis to finish with authorization token
    Then I should get 200 status code
    Then I should find the value click under the path result/0/user_stack_info/analyzed_dependencies/0/package in the JSON response
    Then I should find the value 6.7 under the path result/0/user_stack_info/analyzed_dependencies/0/version in the JSON response

  @requires_authorization_token
  Scenario: Check the issue #848 (https://github.com/openshiftio/openshift.io/issues/848)
    Given System is running
    When I acquire the authorization token
    Then I should get the proper authorization token
    When I send Python package manifest requirements_click_6_star.txt to stack analysis with authorization token
    Then I should get 200 status code
    When I wait for stack analysis to finish with authorization token
    Then I should get 200 status code
    Then I should find the value click under the path result/0/user_stack_info/analyzed_dependencies/0/package in the JSON response
    Then I should find the value 6.7 under the path result/0/user_stack_info/analyzed_dependencies/0/version in the JSON response

Test against click 0.7, not against the latest version

Feature: Regression tests

  @requires_authorization_token
  Scenario: Check the issue #847 (https://github.com/openshiftio/openshift.io/issues/847)
    Given System is running
    When I acquire the authorization token
    Then I should get the proper authorization token
    When I send Python package manifest requirements_click_compatible_with_0_7.txt to stack analysis with authorization token
    Then I should get 200 status code
    When I wait for stack analysis to finish with authorization token
    Then I should get 200 status code
    Then I should find the value click under the path result/0/user_stack_info/analyzed_dependencies/0/package in the JSON response
    Then I should find the value 0.7 under the path result/0/user_stack_info/analyzed_dependencies/0/version in the JSON response

  @requires_authorization_token
  Scenario: Check the issue #848 (https://github.com/openshiftio/openshift.io/issues/848)
    Given System is running
    When I acquire the authorization token
    Then I should get the proper authorization token
    When I send Python package manifest requirements_click_0_star.txt to stack analysis with authorization token
    Then I should get 200 status code
    When I wait for stack analysis to finish with authorization token
    Then I should get 200 status code
    Then I should find the value click under the path result/0/user_stack_info/analyzed_dependencies/0/package in the JSON response
    Then I should find the value 0.7 under the path result/0/user_stack_info/analyzed_dependencies/0/version in the JSON response


Feature: Create a tag

  Scenario: Create a tag
    Given the Git server is ready
    When
    Then

Add scenario for creating a tag

Feature: Create a tag

  Scenario: Create a tag
    Given the Git server is ready
    And   the following permissions:
      | user-a | READ_WRITE |
    And   I create repository "merge-test"
    And   I clone repository "merge-test"
    And   I create the file "README.md" with the contents
      """
      Hello Sir.
      """
    And   I have added "README.md" to the index
    When I commit the result
    Then a tag is added to the commit