feat(editorial): review demographic batches before explicit publication
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import fs from 'node:fs';
|
||||
import { createRequire } from 'node:module';
|
||||
import React from 'react';
|
||||
import { renderToStaticMarkup } from 'react-dom/server';
|
||||
import ts from 'typescript';
|
||||
|
||||
const require = createRequire(import.meta.url);
|
||||
const source = fs.readFileSync(
|
||||
new URL(
|
||||
'../../resources/js/pages/management/demography.tsx',
|
||||
import.meta.url,
|
||||
),
|
||||
'utf8',
|
||||
);
|
||||
const code = ts.transpileModule(source, {
|
||||
compilerOptions: {
|
||||
module: ts.ModuleKind.CommonJS,
|
||||
target: ts.ScriptTarget.ES2022,
|
||||
jsx: ts.JsxEmit.ReactJSX,
|
||||
},
|
||||
}).outputText;
|
||||
const module = { exports: {} };
|
||||
new Function('require', 'module', 'exports', code)(
|
||||
(name) => {
|
||||
if (name === '@inertiajs/react')
|
||||
return {
|
||||
Link: ({ href, children }) =>
|
||||
React.createElement('a', { href }, children),
|
||||
router: {},
|
||||
useForm: () => ({ processing: false }),
|
||||
};
|
||||
if (name === './shared')
|
||||
return {
|
||||
Management: ({ children }) =>
|
||||
React.createElement('main', null, children),
|
||||
button: '',
|
||||
control: '',
|
||||
};
|
||||
return require(name);
|
||||
},
|
||||
module,
|
||||
module.exports,
|
||||
);
|
||||
const Page = module.exports.default;
|
||||
const preview = {
|
||||
id: 'qa-batch',
|
||||
file_name: 'synthetic.xlsx',
|
||||
sha256: 'a'.repeat(64),
|
||||
publication_version: 'Edição não indicada',
|
||||
status: 'imported',
|
||||
report: { record_count: 10, issue_counts: {}, issues: [] },
|
||||
matches: [],
|
||||
territory_options: [],
|
||||
events: [],
|
||||
};
|
||||
const render = (changes = {}) =>
|
||||
renderToStaticMarkup(
|
||||
React.createElement(Page, {
|
||||
batches: [],
|
||||
preview,
|
||||
editorialEnabled: true,
|
||||
editorialRevision: 0,
|
||||
...changes,
|
||||
}),
|
||||
);
|
||||
|
||||
test('new imported batches enter review without a combined approval and publication button', () => {
|
||||
const html = render();
|
||||
assert.match(html, /Preparar revisão para publicação/);
|
||||
assert.doesNotMatch(html, /Aprovar utilização em QA/);
|
||||
assert.match(
|
||||
html,
|
||||
/aprovação e a publicação dos novos lotes são operações distintas/,
|
||||
);
|
||||
});
|
||||
|
||||
test('legacy public batches remain accepted and published new batches only offer their history', () => {
|
||||
const legacy = render({ preview: { ...preview, status: 'approved' } });
|
||||
assert.match(legacy, /preservado sem nova aprovação/);
|
||||
assert.doesNotMatch(legacy, /Preparar revisão para publicação/);
|
||||
const published = render({
|
||||
preview: { ...preview, status: 'approved' },
|
||||
editorialRevision: 1,
|
||||
});
|
||||
assert.match(
|
||||
published,
|
||||
/href="\/management\/editorial\/demography\/qa-batch"/,
|
||||
);
|
||||
assert.doesNotMatch(
|
||||
published,
|
||||
/Preparar nova edição de revisão|Desactivar série/,
|
||||
);
|
||||
});
|
||||
@@ -236,3 +236,36 @@ test('portfolio review presents proposed base data and territory without applyin
|
||||
assert.match(html, /Localização proposta: Distrito sintético/);
|
||||
assert.doesNotMatch(html, /qa-district|territory_version/);
|
||||
});
|
||||
|
||||
test('demographic edition presents provenance, warnings and protected original with a separate publication step', () => {
|
||||
const html = render({
|
||||
subject: 'demography',
|
||||
resource: { ...props.resource, id: 'qa-batch', published: false },
|
||||
edition: {
|
||||
...props.edition,
|
||||
state: 'approved',
|
||||
payload: {
|
||||
...props.edition.payload,
|
||||
resource: {
|
||||
title: 'Exemplar sintético',
|
||||
source: 'Fonte QA',
|
||||
publication_version: 'Edição não indicada no original',
|
||||
observations: 10,
|
||||
sha256: 'a'.repeat(64),
|
||||
dataset_hash: 'b'.repeat(64),
|
||||
report: { issue_counts: { unit_not_supplied: 2 } },
|
||||
},
|
||||
files: [],
|
||||
},
|
||||
},
|
||||
});
|
||||
assert.match(html, /10 observações conferidas/);
|
||||
assert.match(html, /Edição não indicada no original/);
|
||||
assert.match(html, /unit_not_supplied: 2 advertências conservadas/);
|
||||
assert.match(
|
||||
html,
|
||||
/href="\/management\/editorial\/demography\/qa-batch\/original"/,
|
||||
);
|
||||
assert.match(html, /value="publish"/);
|
||||
assert.doesNotMatch(html, /Alterar artigo|Alterar ficha da carteira/);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user