Skip to content

Latest commit

 

History

History
75 lines (59 loc) · 3.56 KB

Plugin-Browser-Testing.md

File metadata and controls

75 lines (59 loc) · 3.56 KB

Test a Plugin through the Browser

This test covers installation, an authenticated PHP page, database-backed filtering, sorting, pagination, and realm enforcement. It signs in as two different users in separate Chromium browser contexts. The test starts with the same four records on Cacti develop and 1.2.x.

Prepare the fixture

  1. Start a disposable Cacti web installation backed by a separate MariaDB database. Use an application checkout from the branch under test.
  2. Follow the filterable page walkthrough to install the example plugin and insert the four records. The test expects the initial fixture exactly once.
  3. In Console > Configuration > Users, create two enabled local users who can open the console. Grant View Workflow Example to the first. Leave it unassigned for the second, including through group memberships. Complete any first-login password change before running the test.
  4. Use English for these accounts. The example asserts the labels Name, Next, and No matching devices.

The core plugin test harness supplies locked PHP testing dependencies to CI. Keep its fixture and tooling pins, and keep a plugin's existing database setup and Pest assertions. The browser test below needs a running web server, a database, and the JavaScript Playwright package.

Run the example

Download the browser test as workflowdemo-browser.cjs. Put it in a project directory where Node can resolve the playwright package. For example, copy it to tests/e2e/ in a Cacti develop checkout with that directory's locked dependencies installed. You can use the same runner against a 1.2.x web installation.

Supply CACTI_URL as the base application URL with a trailing slash, including the Cacti subdirectory if present. Supply ALLOWED_USER, ALLOWED_PASSWORD, DENIED_USER, and DENIED_PASSWORD through your local test environment or CI secret store. Point CHROME_BIN at an existing Chromium executable, or install Playwright's matching Chromium.

node workflowdemo-browser.cjs

Exit status zero means all assertions passed. Set SCREENSHOT to a writable PNG path to capture the authorized user's filtered second page.

Know what each assertion proves

Browser action Expected result
Open the example as the permitted user The initial rows are core-a and edge-a.
Search for edge The first page contains edge-a and edge-b.
Select Name to reverse the order The rows become edge-c and edge-b.
Select Next Only edge-a remains. The search and sort survive navigation.
Search for absent The empty-results message appears with zero data rows.
Sign in as the restricted user and open the same URL directly Cacti recognizes the user, denies access, and returns no example rows.

The test checks the logged-in username before opening the plugin. Otherwise a redirect to the login screen could be mistaken for a successful permission check. It asserts row contents after each action so an unchanged page or stale asynchronous response fails the test.

If the first assertion fails, inspect the seeded rows, the account's realm, and the plugin status. If navigation fails, inspect the request after pressing Enter and the returned table. Test the version upgrade separately so a failed schema migration is distinguishable from a browser or permission failure.


Copyright (c) 2004-2026 The Cacti Group