Conservar progresso editorial entre renovações MFA e tornar a retoma visível
tests / ci (push) Canceled after 0s
tests / ci (push) Canceled after 0s
This commit is contained in:
@@ -124,7 +124,13 @@ const text = (node) =>
|
||||
? text(node.props?.children)
|
||||
: String(node ?? "");
|
||||
|
||||
test("assisted editorial preparation never publishes until a separate confirmation and retries the same publication", async () => {
|
||||
test("assisted editor resumes after renewed authentication without preparing completed fiches or automatically publishing", async () => {
|
||||
const previousStorage = globalThis.sessionStorage;
|
||||
const tab = new Map();
|
||||
globalThis.sessionStorage = {
|
||||
getItem: (key) => tab.get(key) ?? null,
|
||||
setItem: (key, value) => tab.set(key, value),
|
||||
};
|
||||
const states = [],
|
||||
refs = [],
|
||||
calls = [];
|
||||
@@ -133,9 +139,13 @@ test("assisted editorial preparation never publishes until a separate confirmati
|
||||
lost = true;
|
||||
const hooks = {
|
||||
...React,
|
||||
useEffect(fn) {
|
||||
fn();
|
||||
},
|
||||
useState(initial) {
|
||||
const i = si++;
|
||||
if (!(i in states)) states[i] = initial;
|
||||
if (!(i in states))
|
||||
states[i] = typeof initial === "function" ? initial() : initial;
|
||||
return [
|
||||
states[i],
|
||||
(v) => {
|
||||
@@ -175,10 +185,11 @@ test("assisted editorial preparation never publishes until a separate confirmati
|
||||
return { package_sha256: "qa-dataset", hash: "qa-source" };
|
||||
},
|
||||
},
|
||||
}).default;
|
||||
}).AssistedEditor;
|
||||
const props = {
|
||||
batch: {
|
||||
dataset_hash: "qa-dataset",
|
||||
editor_id: 42,
|
||||
items: [
|
||||
{
|
||||
code: "qa",
|
||||
@@ -214,6 +225,23 @@ test("assisted editorial preparation never publishes until a separate confirmati
|
||||
assert.equal(calls.length, 2);
|
||||
assert.ok(calls.every((c) => !c.url.endsWith("/publicar")));
|
||||
tree = render();
|
||||
states.length = 0;
|
||||
refs.length = 0; // Full page remount after login/MFA in the same tab.
|
||||
tree = render();
|
||||
assert.match(text(tree), /1 seleccionadas/);
|
||||
assert.match(text(tree), /1 preparadas nesta retoma/);
|
||||
boxes = flatten(tree).filter((n) => n.type === "input");
|
||||
assert.equal(boxes[1].props.checked, false);
|
||||
boxes[1].props.onChange({ target: { checked: true } });
|
||||
tree = render();
|
||||
click(tree, "1.");
|
||||
await new Promise((resolve) => setImmediate(resolve));
|
||||
assert.equal(
|
||||
calls.length,
|
||||
2,
|
||||
"A completed fiche must not be prepared again",
|
||||
);
|
||||
tree = render();
|
||||
assert.equal(
|
||||
flatten(tree).find(
|
||||
(n) => n.type === "button" && text(n).startsWith("2."),
|
||||
@@ -246,6 +274,25 @@ test("assisted editorial preparation never publishes until a separate confirmati
|
||||
assert.deepEqual(calls[3], calls[2]);
|
||||
assert.equal(calls[2].body.confirm, true);
|
||||
assert.match(text(render()), /Publicação confirmada/);
|
||||
props.batch.editor_id = 43;
|
||||
states.length = 0;
|
||||
refs.length = 0;
|
||||
assert.match(
|
||||
text(render()),
|
||||
/0 seleccionadas/,
|
||||
"Another account must not inherit progress",
|
||||
);
|
||||
props.batch.editor_id = 42;
|
||||
props.batch.dataset_hash = "changed-source";
|
||||
states.length = 0;
|
||||
refs.length = 0;
|
||||
assert.match(
|
||||
text(render()),
|
||||
/0 seleccionadas/,
|
||||
"Changed sources must not inherit receipts",
|
||||
);
|
||||
if (previousStorage === undefined) delete globalThis.sessionStorage;
|
||||
else globalThis.sessionStorage = previousStorage;
|
||||
});
|
||||
test("actual dossier continuation freezes a lost response retry and retains dossier/opportunity and selected product", async () => {
|
||||
const states = [],
|
||||
@@ -255,9 +302,11 @@ test("actual dossier continuation freezes a lost response retry and retains doss
|
||||
const calls = [];
|
||||
const hooks = {
|
||||
...React,
|
||||
useEffect() {},
|
||||
useState(initial) {
|
||||
const i = stateIndex++;
|
||||
if (!(i in states)) states[i] = initial;
|
||||
if (!(i in states))
|
||||
states[i] = typeof initial === "function" ? initial() : initial;
|
||||
return [states[i], (value) => (states[i] = value)];
|
||||
},
|
||||
useRef(initial) {
|
||||
|
||||
Reference in New Issue
Block a user