PrestaFlow

website·Indexed 31 days ago

https://prestaflow.io/docs

Automated end-to-end testing for e-commerce modules, specifically designed for PrestaShop. The platform provides a PHP library for creating test suites with features including visual regression checkpoints, PDF assertions, and theme-aware selectors. It supports PrestaShop versions 1.7, 8, and 9, and offers CI/CD integrations for GitHub Actions, GitLab, Bitbucket, and CircleCI.

Tokens
27.3K
Snippets
144
Records
213
Agent score
53%

What's inside PrestaFlow

  1. Overview of PrestaFlow for PrestaShop

    PrestaFlow is an open-source PHP library designed for the PrestaShop E-commerce software. It provides a set of prebuilt test components and ready-to-use examples, allowing developers to write and manage automated tests for PrestaShop directly in PHP.
  2. Overview of PrestaFlow automated testing for PrestaShop

    PrestaFlow provides automated end-to-end (E2E) testing for e-commerce modules. It allows developers to describe user journeys in YAML, providing visual scenarios with screenshots at every step and built-in visual regression. The service handles shop provisioning and module installation in the cloud, reporting results back to the user.
  3. Overview of PrestaFlow E2E Testing for PrestaShop

    PrestaFlow provides a hosted E2E testing infrastructure for PrestaShop modules. It automates the provisioning of PrestaShop environments, installation of modules, and execution of test suites. Key features include:

    • Visual Scenarios: User journeys are described in YAML with screenshots taken at each step for visual regression testing.
    • Cloud Execution: PrestaShop is provisioned and the module is installed automatically in the cloud.
    • CI Integration: A GitHub Action is provided to run tests on every push and block merges if scenarios fail.
    • Compatibility Matrix: Supports PrestaShop 1.7.x, 8.x, and 9.x on PHP versions 7.4 through 8.3.
  4. Run a single test suite across multiple PrestaShop versions

    PrestaFlow enables a single test suite to be compatible with PrestaShop versions 1.7, 8, and 9. It absorbs version-specific differences (such as BackOffice rebuilds, FrontOffice selector changes on guest checkout/product pages, and URL changes) using per-version Page objects (Pages/v7, Pages/v8, Pages/v9) and runtime auto-detection. This allows developers to write version-agnostic scenarios (e.g., "open the product page") that the library translates into the correct selectors for the detected version.
  5. Integrate PrestaFlow into Bitbucket Pipelines

    The PrestaFlow Bitbucket Pipe runs test suites within a Bitbucket Pipelines step. It can boot a PrestaShop Flashlight instance, execute tests, upload results (including error and visual-regression screenshots), and post a summary comment to the pull request.
  6. Extract and assert text from PDFs using PrestaFlow\[Library\]\[Support\]\[Pdf\]

    The PrestaFlow\Library\Support\Pdf class (available since v1.6.0) is a wrapper around smalot/pdfparser used to assert text content in documents like invoices, credit notes, and delivery slips. The parser is instantiated lazily on the first read and results are cached per instance to allow chaining of methods without re-parsing.
  7. Integrate PrestaFlow with GitHub Actions

    The PrestaFlow GitHub Action runs test suites within a GitHub workflow. It executes the PHP library command composer run prestaflow:json:file, optionally provisions a PrestaShop Flashlight instance, uploads results to the PrestaFlow API, publishes raw reports and screenshots as GitHub artifacts, and posts a summary comment on pull requests.
  8. Implement visual regression testing with PrestaFlow

    PrestaFlow handles visual regression by freezing the baseline in actions/cache. It provides a side-by-side diff (Reference, Actual, and Diff) accessible via a public link for team review, with the ability to refresh the baseline on demand using a salt.
  9. Log output to the console during tests

    Starting from version 1.2.4, you can output logs directly to the console within a test. The log and console methods are aliases and can be used interchangeably to print strings or arrays of data for debugging purposes.
    it('check product price', function () use ($frontOfficeProductPage) {
        $frontOfficeProductPage->goToProduct(42);
    
        $price = $frontOfficeProductPage->getPrice();
        
        // Log a simple string
        $this->log('price: ' . $price);
        
        // Log an array of data
        $this->console(['raw' => $price, 'formatted' => '$' . $price]);
    
        Expect::that($price)->isGreaterThan(0);
    });
  10. Test PrestaShop 9.2 One Page Checkout

    PrestaFlow supports the ps_onepagecheckout module in PrestaShop 9.2. It provides support for the FrontOffice page, BackOffice settings pages, and two ready-to-use scenarios: OnePageCheckoutOrder and OnePageCheckoutGuest. These scenarios automatically skip with an explicit message on versions below 9.2. Note that the one-page layout is only compatible with the Hummingbird theme.
    $this->describe('Place an order through the One Page Checkout')
        ->scenario(\PrestaFlow\Library\Scenarios\OnePageCheckoutOrder::class);
  11. Filter specific test suites to run

    To run only a subset of tests, provide a comma-separated list of sub-folders of your suites path via the suites input. Nested paths (e.g., FrontOffice/Checkout) are supported. This requires prestaflow/php-library version ^1.8.0; earlier versions will ignore the filter and run all suites. If a specified suite name does not match any folder, the run will fail.
    - name: Run selected suites
      uses: PrestaFlow/github-action@v2
      with:
        token: ${{ secrets.PRESTAFLOW_TOKEN }}
        projectId: '42'
        suites: BackOffice,FrontOffice
  12. Create and integrate a reusable Scenario

    Scenarios allow you to encapsulate a set of test steps. Create a class in src/Tests/Scenarios that extends PrestaFlow\Library\Scenarios\Scenario. Implement the steps($testSuite) method to define the logic and return the $testSuite object. You can then reference this scenario in a Test Suite using the scenario() method.
    // src/Tests/Scenarios/DoNothing.php
    namespace Shop\Tests\Scenarios;
    
    use PrestaFlow\Library\Scenarios\Scenario;
    
    class DoNothing extends Scenario
    {
        public function steps($testSuite)
        {
            $testSuite
            ->todo('will do nothing (again)', function () {
            })
            ;
    
            return $testSuite;
        }
    }
    
    // In your Test Suite (e.g., Tests/First.php)
    namespace Tests;
    
    use PrestaFlow\Library\Tests\TestsSuite;
    use Shop\Tests\Scenarios\DoNothing;
    
    class First extends TestsSuite
    {
        public function init()
        {
            $this
            ->describe('PrestaFlow: my first scenario')
            ->scenario(DoNothing::class)
            ;
        }
    }