fix: resolve remaining CI failures - mock test and gh-pages branch

- Fixed n8n-nodes-base mock test by properly handling mocked function overrides
- Added automatic gh-pages branch creation in benchmark workflow
- Ensured benchmark workflow handles first run without existing gh-pages
- Fixed deploy job to handle missing branch gracefully

All CI workflows should now pass successfully.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
czlonkowski
2025-07-28 23:33:38 +02:00
parent 4c87e4d0a6
commit fb4fdcdfe7
2 changed files with 41 additions and 9 deletions

View File

@@ -52,6 +52,22 @@ jobs:
benchmark-results-formatted.json
benchmark-summary.json
# Ensure gh-pages branch exists
- name: Check and create gh-pages branch
run: |
git fetch origin gh-pages:gh-pages 2>/dev/null || {
echo "gh-pages branch doesn't exist. Creating it..."
git checkout --orphan gh-pages
git rm -rf .
echo "# Benchmark Results" > README.md
git add README.md
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git commit -m "Initial gh-pages commit"
git push origin gh-pages
git checkout -
}
# Store benchmark results and compare
- name: Store benchmark result
uses: benchmark-action/github-action-benchmark@v1
@@ -132,6 +148,16 @@ jobs:
uses: actions/checkout@v4
with:
ref: gh-pages
continue-on-error: true
# If gh-pages checkout failed, create a minimal structure
- name: Ensure gh-pages content exists
run: |
if [ ! -f "index.html" ]; then
echo "Creating minimal gh-pages structure..."
mkdir -p benchmarks
echo '<!DOCTYPE html><html><head><title>n8n-mcp Benchmarks</title></head><body><h1>n8n-mcp Benchmarks</h1><p>Benchmark data will appear here after the first run.</p></body></html>' > index.html
fi
- name: Setup Pages
uses: actions/configure-pages@v4

View File

@@ -41,12 +41,12 @@ class WorkflowService {
}
// Mock the module at the top level
vi.mock('n8n-nodes-base', () => ({
getNodeTypes: vi.fn(() => {
const { getNodeTypes } = require('../__mocks__/n8n-nodes-base');
return getNodeTypes();
})
}));
vi.mock('n8n-nodes-base', () => {
const { getNodeTypes: mockGetNodeTypes } = require('../__mocks__/n8n-nodes-base');
return {
getNodeTypes: mockGetNodeTypes
};
});
describe('WorkflowService with n8n-nodes-base mock', () => {
let service: WorkflowService;
@@ -173,20 +173,26 @@ describe('WorkflowService with n8n-nodes-base mock', () => {
});
it('should handle missing slack node', async () => {
// Save the original mock implementation
const originalImplementation = vi.mocked(getNodeTypes).getMockImplementation();
// Override getNodeTypes to return undefined for slack
const getNodeTypes = vi.fn(() => ({
vi.mocked(getNodeTypes).mockImplementation(() => ({
getByName: vi.fn((name: string) => {
if (name === 'slack') return undefined;
return null;
}),
getByNameAndVersion: vi.fn()
}));
vi.mocked(require('n8n-nodes-base').getNodeTypes).mockImplementation(getNodeTypes);
await expect(
service.validateSlackMessage('#general', 'Hello')
).rejects.toThrow('Slack node not found');
// Restore the original implementation
if (originalImplementation) {
vi.mocked(getNodeTypes).mockImplementation(originalImplementation);
}
});
});