|
| 1 | +import { readFileSync } from 'fs' |
| 2 | +import Joi from 'joi' |
| 3 | +import { createServiceTester } from '../tester.js' |
| 4 | + |
| 5 | +export const t = await createServiceTester() |
| 6 | + |
| 7 | +const isVersion = Joi.string().regex(/^v\d+(\.\d+)*/) |
| 8 | + |
| 9 | +const fixture = JSON.parse( |
| 10 | + readFileSync( |
| 11 | + new URL('./__fixtures__/comfyui_node.json', import.meta.url), |
| 12 | + 'utf8', |
| 13 | + ), |
| 14 | +) |
| 15 | + |
| 16 | +t.create('Version (latest_version.version)') |
| 17 | + .get('/comfyui-image-captioner/version.json') |
| 18 | + .intercept(nock => |
| 19 | + nock('https://api.comfy.org') |
| 20 | + .get('/nodes/comfyui-image-captioner') |
| 21 | + .reply(200, fixture), |
| 22 | + ) |
| 23 | + .expectBadge({ |
| 24 | + label: 'comfyui', |
| 25 | + message: isVersion, |
| 26 | + }) |
| 27 | + |
| 28 | +t.create('Version (top-level version field)') |
| 29 | + .get('/comfyui-image-captioner/version.json') |
| 30 | + .intercept(nock => |
| 31 | + nock('https://api.comfy.org') |
| 32 | + .get('/nodes/comfyui-image-captioner') |
| 33 | + .reply(200, { |
| 34 | + id: 'comfyui-image-captioner', |
| 35 | + name: 'ComfyUI-Image-Captioner', |
| 36 | + downloads: 4894, |
| 37 | + github_stars: 19, |
| 38 | + version: '2.3.4', |
| 39 | + }), |
| 40 | + ) |
| 41 | + .expectBadge({ |
| 42 | + label: 'comfyui', |
| 43 | + message: isVersion, |
| 44 | + }) |
| 45 | + |
| 46 | +t.create('Version (info.version)') |
| 47 | + .get('/comfyui-image-captioner/version.json') |
| 48 | + .intercept(nock => |
| 49 | + nock('https://api.comfy.org') |
| 50 | + .get('/nodes/comfyui-image-captioner') |
| 51 | + .reply(200, { |
| 52 | + id: 'comfyui-image-captioner', |
| 53 | + name: 'ComfyUI-Image-Captioner', |
| 54 | + downloads: 4894, |
| 55 | + github_stars: 19, |
| 56 | + info: { version: '0.9.0' }, |
| 57 | + }), |
| 58 | + ) |
| 59 | + .expectBadge({ |
| 60 | + label: 'comfyui', |
| 61 | + message: isVersion, |
| 62 | + }) |
| 63 | + |
| 64 | +t.create('Version (latest.version)') |
| 65 | + .get('/comfyui-image-captioner/version.json') |
| 66 | + .intercept(nock => |
| 67 | + nock('https://api.comfy.org') |
| 68 | + .get('/nodes/comfyui-image-captioner') |
| 69 | + .reply(200, { |
| 70 | + id: 'comfyui-image-captioner', |
| 71 | + name: 'ComfyUI-Image-Captioner', |
| 72 | + downloads: 4894, |
| 73 | + github_stars: 19, |
| 74 | + latest: { version: '3.0' }, |
| 75 | + }), |
| 76 | + ) |
| 77 | + .expectBadge({ |
| 78 | + label: 'comfyui', |
| 79 | + message: isVersion, |
| 80 | + }) |
| 81 | + |
| 82 | +t.create('Version (not found - no version fields)') |
| 83 | + .get('/comfyui-image-captioner/version.json') |
| 84 | + .intercept(nock => |
| 85 | + nock('https://api.comfy.org') |
| 86 | + .get('/nodes/comfyui-image-captioner') |
| 87 | + .reply(200, { |
| 88 | + id: 'comfyui-image-captioner', |
| 89 | + name: 'ComfyUI-Image-Captioner', |
| 90 | + downloads: 4894, |
| 91 | + github_stars: 19, |
| 92 | + }), |
| 93 | + ) |
| 94 | + .expectBadge({ label: 'comfyui', message: 'version not found' }) |
| 95 | + |
| 96 | +t.create('Version (node not found)') |
| 97 | + .get('/nonexistent-node/version.json') |
| 98 | + .expectBadge({ label: 'comfyui', message: 'node not found' }) |
0 commit comments