diff --git a/server/services/projectKinds.js b/server/services/projectKinds.js new file mode 100644 index 0000000..7148c5e --- /dev/null +++ b/server/services/projectKinds.js @@ -0,0 +1,28 @@ +// Katalog der Projektarten und ihrer Zusatzfunktionen. +// preview: 'yes' = Vorschau immer, 'possible' = möglich, 'no' = keine. + +export const FEATURES = { + analyse: { label: 'Website-Analyse', status: 'in_development' }, +} + +export const KINDS = [ + { key: 'website', label: 'Website', preview: 'yes', features: ['analyse'], ticketType: 'Webpage', + description: 'Internetauftritt inkl. Landingpage oder Shop' }, + { key: 'webapp', label: 'Web-App', preview: 'possible', features: [], ticketType: 'Webpage', + description: 'Individuelle Anwendung im Browser, z. B. Portal oder Buchungssystem' }, + { key: 'app', label: 'App', preview: 'no', features: [], ticketType: 'Webpage', + description: 'Mobile App für iOS und Android' }, + { key: 'migration', label: 'Migration/Umzug', preview: 'no', features: [], ticketType: 'Migration', + description: 'Umzug bestehender Seiten, Server oder Systeme' }, + { key: 'automation', label: 'Automation/Skript', preview: 'no', features: [], ticketType: 'Webpage', + description: 'Automatisierte Abläufe, Schnittstellen und Skripte' }, + { key: 'other', label: 'Sonstiges', preview: 'no', features: [], ticketType: 'Webpage', + description: 'Alles, was in keine andere Art passt' }, +] + +const find = (key) => KINDS.find(k => k.key === key) + +export const isKind = (key) => !!find(key) +export const kindLabel = (key) => find(key)?.label || '' +export const ticketTypeFor = (key) => (find(key)?.ticketType === 'Migration' ? 'Migration' : 'Webpage') +export const servicesCatalog = () => ({ kinds: KINDS, features: FEATURES }) diff --git a/test/projectKinds.test.js b/test/projectKinds.test.js new file mode 100644 index 0000000..92b8217 --- /dev/null +++ b/test/projectKinds.test.js @@ -0,0 +1,36 @@ +import { test } from 'node:test' +import assert from 'node:assert/strict' +import { KINDS, FEATURES, isKind, kindLabel, ticketTypeFor, servicesCatalog } from '../server/services/projectKinds.js' + +test('Schlüssel und Labels in fester Reihenfolge', () => { + assert.deepEqual(KINDS.map(k => k.key), ['website', 'webapp', 'app', 'migration', 'automation', 'other']) + assert.deepEqual(KINDS.map(k => k.label), ['Website', 'Web-App', 'App', 'Migration/Umzug', 'Automation/Skript', 'Sonstiges']) +}) +test('isKind', () => { + assert.equal(isKind('website'), true) + assert.equal(isKind('shop'), false) + assert.equal(isKind(''), false) +}) +test('kindLabel', () => { + assert.equal(kindLabel('migration'), 'Migration/Umzug') + assert.equal(kindLabel('xyz'), '') +}) +test('ticketTypeFor', () => { + assert.equal(ticketTypeFor('migration'), 'Migration') + assert.equal(ticketTypeFor('app'), 'Webpage') +}) +test('Preview-Werte', () => { + const p = Object.fromEntries(KINDS.map(k => [k.key, k.preview])) + assert.deepEqual(p, { website: 'yes', webapp: 'possible', app: 'no', migration: 'no', automation: 'no', other: 'no' }) +}) +test('Features nur bei Website', () => { + assert.deepEqual(KINDS.find(k => k.key === 'website').features, ['analyse']) + for (const k of KINDS.filter(k => k.key !== 'website')) assert.deepEqual(k.features, []) + assert.deepEqual(FEATURES.analyse, { label: 'Website-Analyse', status: 'in_development' }) +}) +test('servicesCatalog und Beschreibungen', () => { + const c = servicesCatalog() + assert.equal(c.kinds, KINDS) + assert.equal(c.features, FEATURES) + for (const k of KINDS) assert.ok(k.description.length > 0) +})