fix: onboarding feedback follow-ups: root files warning, pins, help texts, docs (#446) #475

Open
maximus wants to merge 5 commits from issue-446-review-followups into issue-384-onboarding-followups
2 changed files with 39 additions and 5 deletions
Showing only changes of commit a62150d926 - Show all commits

View file

@ -222,6 +222,34 @@ describe("wizardReducer — rootFiles (#427)", () => {
const after = wizardReducer(before, { type: "SET_ERROR", payload: "folder not found" });
expect(after.rootFiles).toBe(before.rootFiles);
});
it("choosing another folder empties the root files until its own scan lands (#446)", () => {
const before = reduce([
{ type: "SET_IMPORT_FOLDER", payload: "/releves" },
{ type: "SET_SCANNED_SOURCES", payload: scan(["a.csv"]) },
]);
const changed = wizardReducer(before, { type: "SET_IMPORT_FOLDER", payload: "/autre" });
// The warning would name "a.csv" of /releves under the name of /autre.
expect(changed.importFolder).toBe("/autre");
expect(changed.rootFiles).toEqual([]);
// Prior behaviour, kept: the sources of the last scan stay until the new one.
expect(changed.scannedSources).toBe(before.scannedSources);
const scanned = wizardReducer(changed, { type: "SET_SCANNED_SOURCES", payload: scan(["b.csv"], []) });
expect(scanned.rootFiles).toEqual(["b.csv"]);
expect(scanned.scannedSources).toEqual([]);
});
it("a scan error after a folder change names no root file of the previous folder (#446)", () => {
const after = reduce([
{ type: "SET_IMPORT_FOLDER", payload: "/releves" },
{ type: "SET_SCANNED_SOURCES", payload: scan(["a.csv"]) },
{ type: "SET_IMPORT_FOLDER", payload: "/autre" },
{ type: "SET_LOADING", payload: true },
{ type: "SET_ERROR", payload: "folder not found" },
]);
expect(after.rootFiles).toEqual([]);
});
});
describe("sampleFolderError — the refusals of create_sample_import_folders (#384, D2)", () => {

View file

@ -110,9 +110,11 @@ export interface WizardState {
/**
* Names of the CSV/TXT files placed directly at the root of the import
* folder, which no source reads (#427). Set with `scannedSources` by the
* same action, so the warning and the source list always come from the same
* scan; kept by `RESET` like them. Shown on screen only, never logged: a
* statement name often carries an account number.
* same action, so the warning and the source list come from the same scan;
* kept by `RESET` like them. Emptied by `SET_IMPORT_FOLDER`, which leaves
* `scannedSources` alone (#446): another folder shows no warning until its
* own scan. Shown on screen only, never logged: a statement name often
* carries an account number.
*/
rootFiles: string[];
selectedSource: ScannedSource | null;
@ -252,8 +254,12 @@ export function wizardReducer(state: WizardState, action: WizardAction): WizardS
case "SET_STEP":
return { ...state, step: action.payload };
case "SET_IMPORT_FOLDER":
// The sample-folder banner describes the previous folder: drop it.
return { ...state, importFolder: action.payload, sampleCreated: null };
// The sample-folder banner describes the previous folder: drop it. So do
// the root files (#446): until the new folder's scan lands, or for good
// if it fails, the warning would name the previous folder's files under
// the new folder's name. The scanned sources stay until that scan, as
// they always did.
return { ...state, importFolder: action.payload, rootFiles: [], sampleCreated: null };
case "SET_IMPORT_FOLDER_LOADED":
return { ...state, importFolderLoaded: true };
case "SET_SCANNED_SOURCES":