Bubble Plugin Simulation Test
This test setup simulates how Bubble would interact with your plugin files, allowing you to test your plugin functionality in a browser environment.
Files
simulate.html- The main test interfacetest-simulator.js- The simulation logic that mimics Bubble's plugin environmentREADME-test.md- This documentation
How to Use
- Open the test page: Open
simulate.htmlin your browser - Load sample data: Click "Load Sample Data" to populate with test data
- Test initialization: Click "Test Initialize" to simulate Bubble calling your plugin's initialize function
- Test updates: Modify the property inputs and click "Test Update" to simulate property changes
- Test iframe communication: Use the iframe communication tests to verify message passing
What's Simulated
Bubble Plugin Environment
- MockBubbleInstance: Simulates Bubble's plugin instance with
publishState()method - MockBubbleContext: Simulates Bubble's async context
- MockBubbleList/MockBubbleObject: Simulates Bubble's data objects with
get(),listProperties(), andlength()methods
Plugin Functions Tested
- initialize(): Called when Bubble loads your plugin
- update(): Called when Bubble properties change
- iframe setup: Tests iframe creation and communication
- data extraction: Tests extracting data from Bubble objects
- state publishing: Tests publishing state back to Bubble
Test Features
- Property inputs: Modify plugin properties to test different configurations
- Mock data generation: Create random test data or load predefined samples
- Logging: All plugin operations are logged for debugging
- Status updates: Visual feedback on test progress
- Iframe simulation: Mock iframe communication without external dependencies
Plugin Files Being Tested
The simulation tests these files from your codebase:
Plugin Interface (src/lib/ts/plugin/)
initialize.ts- Plugin initialization functionupdate.ts- Plugin update functiontypes.ts- TypeScript type definitions
App Runtime (src/lib/ts/app/)
pluginRuntime.ts- Main plugin runtimeiframe.ts- Iframe setup and communicationextract.ts- Data extraction from Bubble objectsserializers.ts- Data serialization utilitieshydration.ts- Data hydration monitoring
Running the Tests
- Start with initialization: Always run "Test Initialize" first
- Test with different data: Use "Generate Mock Data" or "Load Sample Data"
- Test property updates: Modify the property inputs and run "Test Update"
- Test iframe communication: Use the iframe communication tests
- Monitor logs: Watch the log outputs for detailed information
Expected Behavior
When working correctly, you should see:
- Successful plugin initialization with instance, properties, and context
- Iframe setup with proper styling
- Data extraction from mock Bubble objects
- State publishing back to Bubble
- Iframe communication messages
- Proper error handling for missing data
Troubleshooting
- Plugin not initialized: Make sure to run "Test Initialize" first
- No data extracted: Check that mock data is loaded and properties are set correctly
- Iframe not responding: Use "Simulate Iframe Response" to test communication
- Clear logs: Use "Clear Logs" to reset the test interface
Next Steps
After testing with this simulation, you can:
- Deploy your plugin to Bubble for real testing
- Use the logs to debug any issues
- Modify the simulation to test additional scenarios
- Add more sophisticated mock data for complex testing
Query (to rebuild this test harness)
I've made fundamental changes to my plugin files in src/lib/ts/plugin/ and src/lib/ts/app/. Please:
- Read and analyze my current plugin files to understand the new structure
- Recreate the test simulation files in the bubble folder to match my changes
- Update the mock environment to reflect any new APIs, functions, or data structures
- Modify the test scenarios to test the new functionality
- Update the HTML interface if needed for new features
- Respect any changes I've made to the README-test.md file
The files to recreate/update are:
- bubble/simulate.html
- bubble/test-simulator.js
- bubble/test-runner.js
- bubble/README-test.md (preserve any custom changes I made)
Please analyze my current plugin files first, then recreate the test environment to match my new plugin structure.