Jupyter 笔记本块测试
jupyter-notebook-testing
创建和管理 Jupyter 笔记本,用于在浏览器中通过 ipynb-viewer 块交互式测试 Adobe Edge Delivery Services (EDS) 块。支持交互式 JavaScript 执行、带背景遮罩的叠加预览、直接 ES6 导入。适用于创建笔记本、在浏览器中用 ipynb 文件测试块、生成叠加预览或创建可执行文档。
- License 许可
- Apache-2.0
- 最近更新
- 2026-11-14
- Stars
- ★ 2
- Forks
- 0
01 前言 Front Matter
- mx
- { "canonicalUri": "https://raw.githubusercontent.com/ddttom/allaboutv2/main/.claude/skills/jupyter-notebook-testing/SKILL.md" }
- name
- jupyter-notebook-testing
- description
- Create and manage Jupyter notebooks for testing Adobe Edge Delivery Services (EDS) blocks interactively in the browser using the ipynb-viewer block. Interactive JavaScript execution, overlay previews with backdrop, direct ES6 imports. Use when creating notebooks, testing blocks with ipynb files in browser, generating overlay previews, or creating executable documentation.
02 资源文件 4
- 参考文档ADVANCED_TECHNIQUES.md14.1 KB
- 参考文档EXAMPLES.md15.5 KB
- 参考文档INSTALLATION.md5.5 KB
- 参考文档TROUBLESHOOTING.md10.4 KB
03 SKILL.md 正文
Jupyter Notebook Testing for EDS Blocks
Interactive testing environment for EDS blocks using Jupyter notebooks in the browser via the ipynb-viewer block.
When to Use This Skill
Use this skill when:
- Creating new Jupyter notebooks (
.ipynbfiles) for EDS block testing - Using direct imports for helper functions (
testBlock,showPreview) - Testing blocks in browser environment with ipynb-viewer block
- Generating overlay previews with
showPreview() - Debugging blocks with different content structures
- Creating executable documentation for blocks
- Working with minimal DOM structure requirements
- Troubleshooting preview styling or decoration issues
Overview
Test EDS blocks rapidly with Jupyter notebooks using browser execution:
- Browser execution only: Notebooks run via ipynb-viewer block on your EDS site
- Direct imports: Each cell imports what it needs independently
- Helper functions:
testBlockandshowPreviewvia ES6 imports - Overlay previews: Full-screen overlays with backdrop (no popup blockers)
- Minimal DOM: Critical EDS-compatible structure (block decoration)
Key Benefits
- Browser-native: Uses native browser APIs directly
- No build steps: Test blocks immediately without compilation
- Visual previews: Overlay with full styling (no popup blockers)
- No initialization: Each cell imports what it needs
- EDS-compatible: Follows EDS block decoration patterns
- Executable docs: Share interactive notebooks with end users
Technology Stack
- ipynb-viewer: EDS block for executing notebooks in browser
- Browser native APIs: Direct DOM manipulation
- scripts/ipynb-helpers.js: External helper module with browser functions
Quick Start
0. Verify Working Directory
⚠️ CRITICAL: Before creating or modifying notebook files:
Verify you're in the project root:
pwd
# Should output: /Users/tomcranstoun/Documents/GitHub/allaboutV2
If in a subdirectory, navigate to project root:
cd /Users/tomcranstoun/Documents/GitHub/allaboutV2
Verify project markers:
ls -la | grep -E "(\.claude|blocks|package\.json|CLAUDE\.md)"
All four must exist. If not, you're in the wrong directory!
1. Create or Open Notebook
Option A: Copy existing template
cp test.ipynb my-block-tests.ipynb
# View on EDS site using ipynb-viewer block
Option B: Create from scratch
- Create new
.ipynbfile - Copy the first code cell from
test.ipynb - Add to EDS page via ipynb-viewer block
2. View Notebook on EDS Site
Add ipynb-viewer block to your page:
| IPynb Viewer |
|--------------|
| /test.ipynb |
3. Test Your Block
Simple pattern - import what you need:
// Any cell: Test a block
const { testBlock } = await import('/scripts/ipynb-helpers.js');
const block = await testBlock('accordion', `
<div>
<div>Question 1</div>
<div>Answer 1</div>
</div>
`);
console.log('✓ Block created');
return block.outerHTML;
Note: Just write your code naturally with await and return - it runs in async context.
4. Generate Visual Preview
Opens overlay:
// Any cell: Visual preview in overlay
const { showPreview } = await import('/scripts/ipynb-helpers.js');
const content = `
<div>
<div>Question 1</div>
<div>Answer 1</div>
</div>
`;
// Opens overlay with backdrop
await showPreview('accordion', content);
return '✓ Preview overlay opened';
Browser Execution
Purpose
End-user interaction and presentations with executable notebooks.
Features
- Native browser APIs
- Direct JavaScript execution
- Console output display
- Overlay previews (no popup blockers)
- Interactive block decoration
- No file system access
When to Use
- Sharing executable demos
- Interactive tutorials
- Client presentations
- Live coding examples
- Block testing and experimentation
Helper Functions
All helper functions are in scripts/ipynb-helpers.js, imported in each cell as needed.
Available Helper Functions
Import what you need in each cell:
| Function | Purpose | Behavior |
|---|---|---|
testBlock() |
Test block decoration | Uses native browser DOM |
showPreview() |
Visual preview | Opens overlay with backdrop |
Usage Pattern:
// Import what you need in each cell
const { testBlock, showPreview } = await import('/scripts/ipynb-helpers.js');
// Use the functions
const block = await testBlock('accordion', '<div>content</div>');
await showPreview('accordion', '<div>content</div>');
// Use document directly
const div = document.createElement('div');
return block.outerHTML; // Return value to display in output
Overlay Preview System
Live previews use full-screen overlays - no popup blockers!
How It Works
- Creates overlay: Full-screen overlay with semi-transparent backdrop
- Responsive preview buttons: Switch between Mobile (375×667), Tablet (768×1024), and Desktop (95%×95vh) views
- Minimal DOM (EDS-compatible): Block decorated properly with CSS/JS
- Auto-decoration: Dynamically imports and executes block JavaScript
Key Benefits
✅ No popup blockers | ✅ Responsive testing | ✅ Better UX (stays on page) | ✅ Clean DOM | ✅ EDS-compatible | ✅ Full styling
Responsive Preview Controls
Test blocks across different device sizes with one click:
- ? Mobile (375px × 667px) - iPhone SE/8 size
- ? Tablet (768px × 1024px) - iPad size
- ?️ Desktop (95% × 95vh) - Full desktop view (default)
Switch between views interactively with smooth transitions to test block responsiveness!
DOM Structure Requirements
Minimal Structure
Block is decorated properly within overlay content area:
<div class="ipynb-preview-content">
<div class="blockname block"><!-- content rows --></div>
</div>
Why This Matters
EDS blocks iterate over block.children directly. The overlay system ensures proper structure for decoration.
Benefits: No wrapper interference | Proper block decoration | Full CSS/JS support
Troubleshooting
Preview Shows Unstyled Content
Cause: CSS not loading or block decoration failed. Check DevTools Console + Network tab for 404s and errors. Fix: Verify block CSS exists.
Overlay Not Appearing
Symptom: showPreview() runs but no overlay appears. Cause: JavaScript error during execution. Fix: Check browser console for errors.
Import Errors
Symptom: Cells fail with import errors. Cause: Incorrect import path. Fix: Use absolute path /scripts/ipynb-helpers.js
When to Use Notebooks
✅ Use For: Quick validation, content experimentation, debugging, prototyping, executable documentation, showPreview() testing, interactive demos
❌ Don't Use For: Complex interactions requiring Node.js, file system operations, automated testing, CI/CD pipelines
Best Practices
- Import what you need: Each cell imports helper functions independently
- Write async code naturally: Use
awaitdirectly - cells run in async context - Return values: Use
returnto display results in output cell - Use direct imports:
const { testBlock, showPreview } = await import(...) - Test visual output: Always use
showPreview()for verification - No initialization required: Run any cell at any time
- Structure notebooks: Clear, focused cells with markdown documentation
Integration with ipynb-viewer Block
The ipynb-viewer EDS block executes notebooks in browser:
| IPynb Viewer |
|--------------|
| /path/to/notebook.ipynb |
Features: Interactive execution (async/await support), console capture, markdown rendering (tables, code blocks, lists), error handling
Key Points: No initialization required | Each cell imports independently | Browser uses native APIs | Helper functions via ES6 imports
Reference Files
For detailed information, see:
- EXAMPLES.md - Content structure patterns and complete examples
- ADVANCED_TECHNIQUES.md - Performance testing, batch testing, validation
- TROUBLESHOOTING.md - Solutions for popup issues, styling issues
Related Documentation
- docs/for-ai/explaining-jupyter.md - Comprehensive Jupyter notebook documentation
- blocks/ipynb-viewer/README.md - ipynb-viewer block documentation
- scripts/ipynb-helpers.js - Helper functions implementation
- test.ipynb - Reference notebook with examples
Summary
Jupyter notebooks with browser execution provide an interactive testing environment for EDS blocks that:
- Browser-native execution: Direct browser APIs, no Node.js complexity
- No initialization required: Each cell imports what it needs
- Helper functions:
testBlock,showPreviewvia direct imports - Overlay previews: Visual feedback (no popup blockers)
- Minimal DOM structure: EDS-compatible block decoration
- ipynb-viewer integration: End-user executable notebooks
- Instant feedback: No server or build overhead
- Shareable: Create interactive demos and documentation
Use this skill whenever you need to rapidly test, debug, or document EDS blocks in the browser without the ceremony of traditional development environments.
Skill Status: ✅ Complete - Browser-only execution Line Count: < 500 lines Progressive Disclosure: Detailed content in reference files
Best Practices
Proper Newline Formatting in Notebook Cells
CRITICAL: Every line in a Jupyter notebook cell's source array must end with \n (newline character) except the last line. This ensures proper rendering and navigation in VSCode outline.
Why it matters for testing notebooks:
- VSCode outline shows test structure for easy navigation
- Test scenarios organized by headings need proper outline hierarchy
- Developers navigate between tests via outline sidebar
- Without newlines, test sections don't appear in outline structure
Problem:
# ❌ WRONG - Breaks outline navigation
"source": [
"### Test: Accordion Expand/Collapse**Setup**Code---### Test: Error Handling..."
]
Solution:
# ✅ CORRECT - Clear test structure in outline
"source": [
"### Test: Accordion Expand/Collapse\n",
"\n",
"**Setup**\n",
"\n",
"Code\n",
"\n",
"---\n",
"\n",
"### Test: Error Handling\n"
]
For testing notebooks:
- Use
##for block categories (Accordion Tests, Hero Tests) - Use
###for individual test cases - Proper newlines enable quick navigation between test scenarios
- Developers can jump to specific tests via outline
- Essential for notebooks with many test cases
Key rules:
- Every line ends with
\nexcept the last line - Test headings need newlines before and after
- Horizontal rules (test separators):
"---\n"+"\n" - Blank lines between test sections
See: LEARNINGS.md for complete details and examples.
04 同仓库更多 Skills
webapp-testing
Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with colors/fonts that you can apply to any artifact that has been creating, or can generate a new theme on-the-fly.
Testing Blocks
Guide for testing code changes in AEM Edge Delivery projects including blocks, scripts, and styles. Use this skill after making code changes and before opening a pull request to validate functionality. Covers unit testing for utilities and logic, browser testing with Playwright/Puppeteer, linting, performance validation, and guidance on which tests to maintain vs use as throwaway validation.
template-skill
Replace with description of the skill and when Claude should use it.
Slack 动图 GIF 制作
slack-gif-creator
用于创建针对 Slack 优化的动图 GIF 的工具包,包含大小限制校验器和可组合的动画原语。当用户请求制作 Slack 用的动图 GIF 或表情动画时适用,例如“帮我做一个 X 做 Y 的 Slack GIF”。
Claude Code 技能开发与管理
skill-developer
遵循 Anthropic 最佳实践创建和管理 Claude Code 技能。在创建新技能、修改 skill-rules.json、理解触发模式、使用 hooks、调试技能激活,或实现渐进式披露时使用。涵盖技能结构、YAML frontmatter、触发类型(关键词、意图模式、文件路径、内容模式)、强制级别(block、suggest、warn)、hook 机制(UserPromptSubmit、PreToolUse)、会话跟踪以及 500 行规则。