docs(production): standardiserad produktionsberedskap och gap-analys
Lägger docs/production-readiness.md och siax/production-gaps.json enligt SIAX Master Definition of Done. Underlag: git-, kod- och live-evidens 2026-11-11. Nivån är evidensbaserad, inte ett leveransgodkännande.
This commit is contained in:
@@ -1,78 +0,0 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import {
|
||||
ALL_CURRENCIES,
|
||||
articleCurrency,
|
||||
listArticleCurrencies,
|
||||
matchesCurrencyScope,
|
||||
resolveCurrencyScope,
|
||||
} from '@/lib/articles/currency-scope'
|
||||
|
||||
describe('articleCurrency', () => {
|
||||
it('normalizes the code', () => {
|
||||
expect(articleCurrency({ currency: 'eur' })).toBe('EUR')
|
||||
})
|
||||
|
||||
it('treats a missing or blank currency as SEK', () => {
|
||||
expect(articleCurrency({})).toBe('SEK')
|
||||
expect(articleCurrency({ currency: null })).toBe('SEK')
|
||||
expect(articleCurrency({ currency: '' })).toBe('SEK')
|
||||
})
|
||||
})
|
||||
|
||||
describe('listArticleCurrencies', () => {
|
||||
it('lists each present currency once, SEK first then alphabetically', () => {
|
||||
expect(
|
||||
listArticleCurrencies([
|
||||
{ currency: 'USD' },
|
||||
{ currency: 'EUR' },
|
||||
{ currency: 'SEK' },
|
||||
{ currency: 'EUR' },
|
||||
{ currency: 'NOK' },
|
||||
]),
|
||||
).toEqual(['SEK', 'EUR', 'NOK', 'USD'])
|
||||
})
|
||||
|
||||
it('folds legacy blank rows into SEK', () => {
|
||||
expect(listArticleCurrencies([{ currency: null }, { currency: 'sek' }])).toEqual(['SEK'])
|
||||
})
|
||||
|
||||
it('is empty for an empty register, so the picker can stay hidden', () => {
|
||||
expect(listArticleCurrencies([])).toEqual([])
|
||||
})
|
||||
})
|
||||
|
||||
describe('resolveCurrencyScope', () => {
|
||||
const available = ['SEK', 'EUR']
|
||||
|
||||
it('defaults to no scope', () => {
|
||||
expect(resolveCurrencyScope(null, available)).toBe(ALL_CURRENCIES)
|
||||
expect(resolveCurrencyScope(undefined, available)).toBe(ALL_CURRENCIES)
|
||||
})
|
||||
|
||||
it('accepts a present currency, case-insensitively', () => {
|
||||
expect(resolveCurrencyScope('eur', available)).toBe('EUR')
|
||||
})
|
||||
|
||||
// A stale or hand-edited link must not empty the register: the fallback is
|
||||
// "show everything", which the user can see and recover from.
|
||||
it('falls back to no scope for a currency that is not in the register', () => {
|
||||
expect(resolveCurrencyScope('USD', available)).toBe(ALL_CURRENCIES)
|
||||
expect(resolveCurrencyScope('nonsense', available)).toBe(ALL_CURRENCIES)
|
||||
expect(resolveCurrencyScope('EUR', [])).toBe(ALL_CURRENCIES)
|
||||
})
|
||||
})
|
||||
|
||||
describe('matchesCurrencyScope', () => {
|
||||
it('keeps every article when unscoped', () => {
|
||||
expect(matchesCurrencyScope({ currency: 'USD' }, ALL_CURRENCIES)).toBe(true)
|
||||
})
|
||||
|
||||
it('keeps only the scoped currency', () => {
|
||||
expect(matchesCurrencyScope({ currency: 'EUR' }, 'EUR')).toBe(true)
|
||||
expect(matchesCurrencyScope({ currency: 'USD' }, 'EUR')).toBe(false)
|
||||
})
|
||||
|
||||
it('matches legacy blank rows under SEK', () => {
|
||||
expect(matchesCurrencyScope({ currency: null }, 'SEK')).toBe(true)
|
||||
})
|
||||
})
|
||||
@@ -1,71 +0,0 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { compareArticles, sortArticles } from '@/lib/articles/sort'
|
||||
|
||||
describe('sortArticles', () => {
|
||||
it('orders by article number numerically, not alphabetically', () => {
|
||||
const sorted = sortArticles([
|
||||
{ article_number: '10', name: 'Tio' },
|
||||
{ article_number: '2', name: 'Två' },
|
||||
{ article_number: '1', name: 'Ett' },
|
||||
])
|
||||
expect(sorted.map((a) => a.article_number)).toEqual(['1', '2', '10'])
|
||||
})
|
||||
|
||||
it('reproduces issue #1053: numbered register no longer sorts by name', () => {
|
||||
const sorted = sortArticles([
|
||||
{ article_number: '2', name: 'Delbehandling' },
|
||||
{ article_number: '4', name: 'Fotvårdsremiss 85+' },
|
||||
{ article_number: '5', name: 'Fotvårdsremiss ej frikort' },
|
||||
{ article_number: '3', name: 'Fotvårdsremiss frikort' },
|
||||
{ article_number: '1', name: 'Medicinsk fotvård' },
|
||||
])
|
||||
expect(sorted.map((a) => a.article_number)).toEqual(['1', '2', '3', '4', '5'])
|
||||
})
|
||||
|
||||
it('puts articles without a number last, sorted by name', () => {
|
||||
const sorted = sortArticles([
|
||||
{ article_number: null, name: 'Zeta' },
|
||||
{ article_number: '7', name: 'Sju' },
|
||||
{ article_number: null, name: 'Alfa' },
|
||||
{ article_number: undefined, name: 'Beta' },
|
||||
])
|
||||
expect(sorted.map((a) => a.name)).toEqual(['Sju', 'Alfa', 'Beta', 'Zeta'])
|
||||
})
|
||||
|
||||
it('treats blank article numbers as unnumbered', () => {
|
||||
const sorted = sortArticles([
|
||||
{ article_number: ' ', name: 'Blank' },
|
||||
{ article_number: '1', name: 'Ett' },
|
||||
])
|
||||
expect(sorted.map((a) => a.name)).toEqual(['Ett', 'Blank'])
|
||||
})
|
||||
|
||||
it('breaks ties on equal numbers by name', () => {
|
||||
const sorted = sortArticles([
|
||||
{ article_number: '1', name: 'B' },
|
||||
{ article_number: '1', name: 'A' },
|
||||
])
|
||||
expect(sorted.map((a) => a.name)).toEqual(['A', 'B'])
|
||||
})
|
||||
|
||||
it('handles alphanumeric numbers with embedded digits', () => {
|
||||
const sorted = sortArticles([
|
||||
{ article_number: 'A10', name: 'x' },
|
||||
{ article_number: 'A2', name: 'y' },
|
||||
])
|
||||
expect(sorted.map((a) => a.article_number)).toEqual(['A2', 'A10'])
|
||||
})
|
||||
|
||||
it('does not mutate the input array', () => {
|
||||
const input = [
|
||||
{ article_number: '2', name: 'b' },
|
||||
{ article_number: '1', name: 'a' },
|
||||
]
|
||||
sortArticles(input)
|
||||
expect(input.map((a) => a.article_number)).toEqual(['2', '1'])
|
||||
})
|
||||
|
||||
it('compareArticles is exported for column sorters', () => {
|
||||
expect(compareArticles({ article_number: '2', name: 'x' }, { article_number: '10', name: 'y' })).toBeLessThan(0)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user