Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: "Tests"

on:
push:
branches: [main]
pull_request:

jobs:
test:
name: "Unit Tests"
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x, 22.x]

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: "npm"

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Run tests with coverage
if: matrix.node-version == '20.x'
run: npm run test:ci

- name: Upload coverage to Codecov
if: matrix.node-version == '20.x'
uses: codecov/codecov-action@v4
with:
files: ./coverage/lcov.info
fail_ci_if_error: false
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ yarn-error.log*

# Build output / coverage
coverage/
.nyc_output/
dist/
build/

Expand Down
13 changes: 13 additions & 0 deletions CLAUDE.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ This is a Node-RED extension providing custom nodes for interacting with the Seq
## Development Commands

```bash
# Install dependencies
npm install

# Run tests
npm test

# Run tests with coverage
npm run test:coverage

# Linting (uses pre-commit hooks)
pre-commit run --all-files

Expand Down Expand Up @@ -246,6 +255,9 @@ nodes/ - Node implementation files (.js + .html pairs)
dataset-*.js - Dataset addition node
datalink-*.js - Data Link list/poll nodes
studios-*.js - Studio addition/monitor nodes
test/ - Mocha test files
helper.js - Shared test utilities and mock factories
*_spec.js - Test files for each node
examples/ - Example flows (.json)
docker/ - Dockerfiles and Node-RED config for containers
docs/ - Documentation and images
Expand All @@ -263,3 +275,4 @@ docs/ - Documentation and images
7. Use `node.status()` to update visual state in editor
8. Register node in [package.json](package.json) under `node-red.nodes`
9. Create corresponding HTML with `<script type="text/html" data-template-name="...">` for editor UI
10. Add tests in `test/<node-name>_spec.js` using shared helpers from `test/helper.js`
47 changes: 47 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,53 @@ After making code changes:
- **JavaScript files (`.js`)**: Restart Node-RED
- **HTML files (`.html`)**: Refresh your browser (Ctrl+Shift+R / Cmd+Shift+R)

## Running Tests

This project uses [Mocha](https://mochajs.org/) for testing with [node-red-node-test-helper](https://github.com/node-red/node-red-node-test-helper) for Node-RED integration testing.

### Install Dependencies

```bash
npm install
```

### Run Tests

```bash
# Run all tests
npm test

# Run tests with coverage report
npm run test:coverage

# Run tests with lcov output (for CI)
npm run test:ci
```

### Test Structure

Tests are located in the `test/` directory:

- `test/helper.js` - Shared test utilities and mock factories
- `test/*_spec.js` - Test files for each node (following Node-RED naming convention)

Each test file covers:

- Node loading and configuration
- Input message handling
- API call mocking (using [nock](https://github.com/nock/nock))
- Output message verification
- Error handling

### Writing Tests

When adding new nodes or modifying existing ones, please add or update tests accordingly. Tests should:

1. Use the shared helper functions from `test/helper.js`
2. Mock all external API calls with nock
3. Test both success and error paths
4. Verify message passthrough (custom properties preserved)

## Docker Development

The project has two Docker images includeed, that bundle and customise a Node-RED installation and come with the Seqera nodes pre-installed.
Expand Down
7 changes: 5 additions & 2 deletions nodes/datalink-poll.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,18 @@ module.exports = function (RED) {
};

// Start the polling interval
let intervalId = null;
if (node.seqeraConfig && config.dataLinkName && config.dataLinkName.trim() !== "") {
const intervalMs = node.pollFrequencySec * 1000;
const intervalId = setInterval(executePoll, intervalMs);
intervalId = setInterval(executePoll, intervalMs);
// run once immediately
executePoll();
}

node.on("close", () => {
clearInterval(intervalId);
if (intervalId) {
clearInterval(intervalId);
}
});
}

Expand Down
Loading