@remit/ui 0.0.93 → 0.0.94

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@remit/ui",
3
- "version": "0.0.93",
3
+ "version": "0.0.94",
4
4
  "type": "module",
5
5
  "files": [
6
6
  "src"
@@ -582,6 +582,24 @@ describe("RunStepBody", () => {
582
582
  assert.match(html, /Nothing has changed\./);
583
583
  });
584
584
 
585
+ // #522: the commit resolved no destination, which is a cause the screen knows
586
+ // and a setting the user can change.
587
+ it("names why a commit could not start, and where the fix is", () => {
588
+ const html = renderToString(
589
+ createElement(RunStepBody, {
590
+ ...runProps,
591
+ state: "commitFailed",
592
+ verb: "junk",
593
+ scope: "once",
594
+ failureReason:
595
+ "This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folders.",
596
+ }),
597
+ );
598
+ assert.match(text(html), /no Junk folder appointed/);
599
+ assert.match(text(html), /Settings › Folders/);
600
+ assert.doesNotMatch(html, /Nothing has changed\./);
601
+ });
602
+
585
603
  // A retry that could not be started is not a pass that never ran (#552): the
586
604
  // pass that did run keeps its counts and its bar.
587
605
  it("keeps a finished pass's counts when its retry could not be started", () => {
@@ -671,6 +689,22 @@ describe("RunFooter", () => {
671
689
  assert.match(html, /Close/);
672
690
  });
673
691
 
692
+ it("offers no retry for a commit the same press cannot get past", () => {
693
+ // A Try again here re-sends the identical commit to the same absent
694
+ // destination, forever (#522).
695
+ const html = renderToString(
696
+ createElement(RunFooter, {
697
+ ...runProps,
698
+ state: "commitFailed",
699
+ verb: "junk",
700
+ scope: "once",
701
+ failureReason: "This account has no Junk folder appointed.",
702
+ }),
703
+ );
704
+ assert.doesNotMatch(html, /Try again/);
705
+ assert.match(html, /Close/);
706
+ });
707
+
674
708
  it("offers only a way out once there is nothing outstanding", () => {
675
709
  const html = renderToString(createElement(RunFooter, runProps));
676
710
  assert.match(html, /Done/);
@@ -963,6 +963,12 @@ export interface RunStepProps {
963
963
  * messages behind it; defaults to the ones named here.
964
964
  */
965
965
  failedCount?: number;
966
+ /**
967
+ * Why the commit never started, when the run knows and sending the same one
968
+ * again cannot change it. Stated in place of the generic ending, and in place
969
+ * of the retry that would fail identically (#522).
970
+ */
971
+ failureReason?: string;
966
972
  onRetry: () => void;
967
973
  onDismiss: () => void;
968
974
  /**
@@ -981,6 +987,7 @@ const runOutcomeOf = (props: RunStepProps): RunOutcome => ({
981
987
  matched: props.matched,
982
988
  applied: props.applied,
983
989
  failed: props.failedCount ?? props.failures.length,
990
+ failureReason: props.failureReason,
984
991
  });
985
992
 
986
993
  const runIcon = (tone: RunCopy["tone"]): ReactNode => {
@@ -595,6 +595,31 @@ describe("runCopy", () => {
595
595
  assert.equal(outcome("commitFailed", "once").title, "Couldn't start move");
596
596
  });
597
597
 
598
+ // #522: a commit that resolved no destination fails the same way every time
599
+ // it is sent. Stating "Nothing has changed" over a Try again leaves the user
600
+ // pressing a control that can never work, with nothing naming the setting
601
+ // that would.
602
+ it("carries the reason a commit could not start, in place of a retry", () => {
603
+ const reason =
604
+ "This account has no Junk folder appointed, so there is nowhere to file these. Appoint one under Settings › Folders.";
605
+ const blocked = runCopy({
606
+ state: "commitFailed",
607
+ verb: "junk",
608
+ scope: "once",
609
+ matched: 0,
610
+ applied: 0,
611
+ failed: 0,
612
+ failureReason: reason,
613
+ });
614
+
615
+ assert.equal(blocked.detail, reason);
616
+ assert.doesNotMatch(blocked.detail, /Nothing has changed/);
617
+ assert.equal(blocked.retryLabel, undefined);
618
+ assert.equal(blocked.dismissLabel, "Close");
619
+ assert.equal(blocked.tone, "danger");
620
+ assert.match(blocked.title, /^Couldn't start/);
621
+ });
622
+
598
623
  it("shows progress only while a pass over existing mail is under way or finished", () => {
599
624
  assert.equal(outcome("saving", "standing").showProgress, false);
600
625
  assert.equal(outcome("backApplyRunning", "standing").showProgress, true);
@@ -334,6 +334,13 @@ export interface RunOutcome {
334
334
  applied: number;
335
335
  /** How many the mail server rejected. */
336
336
  failed: number;
337
+ /**
338
+ * Why the commit never started, when sending the same one again cannot get
339
+ * past it — no Junk folder appointed, no destination chosen. The ending states
340
+ * this in place of the generic one and offers no retry, because the identical
341
+ * commit fails identically (#522).
342
+ */
343
+ failureReason?: string;
337
344
  }
338
345
 
339
346
  export interface RunCopy {
@@ -372,6 +379,7 @@ export const runCopy = ({
372
379
  matched,
373
380
  applied,
374
381
  failed,
382
+ failureReason,
375
383
  }: RunOutcome): RunCopy => {
376
384
  const { label, present, past } = verbCopy(verb);
377
385
  const done = past.toLowerCase();
@@ -502,15 +510,17 @@ export const runCopy = ({
502
510
  dismissLabel: "Done",
503
511
  };
504
512
  }
513
+ // A stated reason is a failure the same commit cannot get past, so the way
514
+ // out of it is the sentence rather than a retry that fails identically.
505
515
  return {
506
516
  ...shared,
507
517
  title: standing
508
518
  ? "Couldn't save the rule"
509
519
  : `Couldn't start ${label.toLowerCase()}`,
510
- detail: "Nothing has changed.",
520
+ detail: failureReason ?? "Nothing has changed.",
511
521
  tone: "danger",
512
- dismissLabel: "Not now",
513
- retryLabel: "Try again",
522
+ dismissLabel: failureReason === undefined ? "Not now" : "Close",
523
+ retryLabel: failureReason === undefined ? "Try again" : undefined,
514
524
  };
515
525
  };
516
526