From f470f167e32d8f7775ad994f09afb1d353b0b300 Mon Sep 17 00:00:00 2001
From: Sebastian <sebasjm@gmail.com>
Date: Fri, 21 Apr 2023 10:47:47 -0300
Subject: integrate anastasis to the web-utils testing api

---
 .../pages/home/ChallengeOverviewScreen.stories.tsx | 145 +++++++++++----------
 1 file changed, 75 insertions(+), 70 deletions(-)

(limited to 'packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.stories.tsx')

diff --git a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.stories.tsx b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.stories.tsx
index d2471755a..f41f894e8 100644
--- a/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.stories.tsx
+++ b/packages/anastasis-webui/src/pages/home/ChallengeOverviewScreen.stories.tsx
@@ -24,8 +24,9 @@ import {
   RecoveryStates,
   ReducerState,
 } from "@gnu-taler/anastasis-core";
-import { createExample, reducerStatesExample } from "../../utils/index.js";
+import { reducerStatesExample } from "../../utils/index.js";
 import { ChallengeOverviewScreen as TestedComponent } from "./ChallengeOverviewScreen.js";
+import { tests } from "@gnu-taler/web-util/lib/index.browser";
 
 export default {
   title: "Challenge overview",
@@ -39,7 +40,7 @@ export default {
   },
 };
 
-export const OneUnsolvedPolicy = createExample(TestedComponent, {
+export const OneUnsolvedPolicy = tests.createExample(TestedComponent, {}, {
   ...reducerStatesExample.challengeSelecting,
   recovery_information: {
     policies: [[{ uuid: "1" }]],
@@ -53,7 +54,7 @@ export const OneUnsolvedPolicy = createExample(TestedComponent, {
   },
 } as ReducerState);
 
-export const SomePoliciesOneSolved = createExample(TestedComponent, {
+export const SomePoliciesOneSolved = tests.createExample(TestedComponent, {}, {
   ...reducerStatesExample.challengeSelecting,
   recovery_information: {
     policies: [[{ uuid: "1" }, { uuid: "2" }], [{ uuid: "uuid-3" }]],
@@ -82,7 +83,7 @@ export const SomePoliciesOneSolved = createExample(TestedComponent, {
   },
 } as ReducerState);
 
-export const OneBadConfiguredPolicy = createExample(TestedComponent, {
+export const OneBadConfiguredPolicy = tests.createExample(TestedComponent, {}, {
   ...reducerStatesExample.challengeSelecting,
   recovery_information: {
     policies: [[{ uuid: "1" }, { uuid: "2" }]],
@@ -96,71 +97,75 @@ export const OneBadConfiguredPolicy = createExample(TestedComponent, {
   },
 } as ReducerState);
 
-export const OnePolicyWithAllTheChallenges = createExample(TestedComponent, {
-  ...reducerStatesExample.challengeSelecting,
-  recovery_information: {
-    policies: [
-      [
-        { uuid: "1" },
-        { uuid: "2" },
-        { uuid: "3" },
-        { uuid: "4" },
-        { uuid: "5" },
-        { uuid: "6" },
-        { uuid: "7" },
-        { uuid: "8" },
-      ],
-    ],
-    challenges: [
-      {
-        instructions: "Does P equals NP?",
-        type: "question",
-        uuid: "1",
-      },
-      {
-        instructions: "SMS to 555-555",
-        type: "sms",
-        uuid: "2",
-      },
-      {
-        instructions: "Email to qwe@asd.com",
-        type: "email",
-        uuid: "3",
-      },
-      {
-        instructions: 'Enter 8 digits code for "Anastasis"',
-        type: "totp",
-        uuid: "4",
-      },
-      {
-        //
-        instructions: "Wire transfer from ASDXCVQWE123123 with holder Florian",
-        type: "iban",
-        uuid: "5",
-      },
-      {
-        instructions: "Join a video call",
-        type: "video", //Enter 8 digits code for "Anastasis"
-        uuid: "7",
-      },
-      {},
-      {
-        instructions: "Letter to address in postal code DE123123",
-        type: "post", //Enter 8 digits code for "Anastasis"
-        uuid: "8",
-      },
-      {
-        instructions: "instruction for an unknown type of challenge",
-        type: "new-type-of-challenge",
-        uuid: "6",
-      },
-    ],
-  },
-} as ReducerState);
-
-export const OnePolicyWithAllTheChallengesInDifferentState = createExample(
+export const OnePolicyWithAllTheChallenges = tests.createExample(
   TestedComponent,
+  {},
   {
+    ...reducerStatesExample.challengeSelecting,
+    recovery_information: {
+      policies: [
+        [
+          { uuid: "1" },
+          { uuid: "2" },
+          { uuid: "3" },
+          { uuid: "4" },
+          { uuid: "5" },
+          { uuid: "6" },
+          { uuid: "7" },
+          { uuid: "8" },
+        ],
+      ],
+      challenges: [
+        {
+          instructions: "Does P equals NP?",
+          type: "question",
+          uuid: "1",
+        },
+        {
+          instructions: "SMS to 555-555",
+          type: "sms",
+          uuid: "2",
+        },
+        {
+          instructions: "Email to qwe@asd.com",
+          type: "email",
+          uuid: "3",
+        },
+        {
+          instructions: 'Enter 8 digits code for "Anastasis"',
+          type: "totp",
+          uuid: "4",
+        },
+        {
+          //
+          instructions:
+            "Wire transfer from ASDXCVQWE123123 with holder Florian",
+          type: "iban",
+          uuid: "5",
+        },
+        {
+          instructions: "Join a video call",
+          type: "video", //Enter 8 digits code for "Anastasis"
+          uuid: "7",
+        },
+        {},
+        {
+          instructions: "Letter to address in postal code DE123123",
+          type: "post", //Enter 8 digits code for "Anastasis"
+          uuid: "8",
+        },
+        {
+          instructions: "instruction for an unknown type of challenge",
+          type: "new-type-of-challenge",
+          uuid: "6",
+        },
+      ],
+    },
+  } as ReducerState,
+);
+
+export const OnePolicyWithAllTheChallengesInDifferentState =
+  tests.createExample(TestedComponent, {}, {
     ...reducerStatesExample.challengeSelecting,
     recovery_state: RecoveryStates.ChallengeSelecting,
     recovery_information: {
@@ -258,9 +263,9 @@ export const OnePolicyWithAllTheChallengesInDifferentState = createExample(
       },
       "uuid-10": { state: ChallengeFeedbackStatus.IncorrectAnswer.toString() },
     },
-  } as ReducerState,
-);
-export const NoPolicies = createExample(
+  } as ReducerState);
+export const NoPolicies = tests.createExample(
   TestedComponent,
+  {},
   reducerStatesExample.challengeSelecting,
 );
-- 
cgit v1.2.3

