
> job-tracker-ui@0.1.0 test
> jest --runInBand job-export-lifetime.test.tsx

  console.error
    An update to ToastProvider inside a test was not wrapped in act(...).
    
    When testing, code that causes React state updates should be wrapped into act(...):
    
    act(() => {
      /* fire events that update state */
    });
    /* assert on the output */
    
    This ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act

      41 |   const toast = useCallback(
      42 |     (message: string, severity: Severity = "info", action?: { label: string; onClick: () => void }) => {
    > 43 |       setT({
         |       ^
      44 |         open: true,
      45 |         message,
      46 |         severity,

      at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
      at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
      at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
      at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
      at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
      at setT (src/toast.tsx:43:7)
      at toast (src/components/ImportExportJobs.tsx:313:7)

  console.error
    An update to ToastProvider inside a test was not wrapped in act(...).
    
    When testing, code that causes React state updates should be wrapped into act(...):
    
    act(() => {
      /* fire events that update state */
    });
    /* assert on the output */
    
    This ensures that you're testing the behavior the user would see in the browser. Learn more at https://react.dev/link/wrap-tests-with-act

      41 |   const toast = useCallback(
      42 |     (message: string, severity: Severity = "info", action?: { label: string; onClick: () => void }) => {
    > 43 |       setT({
         |       ^
      44 |         open: true,
      45 |         message,
      46 |         severity,

      at node_modules/react-dom/cjs/react-dom-client.development.js:18758:19
      at runWithFiberInDEV (node_modules/react-dom/cjs/react-dom-client.development.js:874:13)
      at warnIfUpdatesNotWrappedWithActDEV (node_modules/react-dom/cjs/react-dom-client.development.js:18757:9)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom-client.development.js:16409:11)
      at dispatchSetStateInternal (node_modules/react-dom/cjs/react-dom-client.development.js:9170:13)
      at dispatchSetState (node_modules/react-dom/cjs/react-dom-client.development.js:9127:7)
      at setT (src/toast.tsx:43:7)
      at toast (src/components/ImportExportJobs.tsx:385:7)

FAIL src/job-export-lifetime.test.tsx (10.711 s)
  ● json lifetime › a pending completion after unmount cannot download or announce success

    expect(jest.fn()).not.toHaveBeenCalled()

    Expected number of calls: 0
    Received number of calls: 1

    1: called with 0 arguments

      59 |     else act(() => window.dispatchEvent(new Event(SESSION_INVALIDATED_EVENT)));
      60 |     await act(async () => pending.resolve(action === "json" ? { data: new Blob(["[]"]) } : "Job Title,Company\nTeacher,Synthetic school"));
    > 61 |     expect(download).not.toHaveBeenCalled(); expect(URL.createObjectURL).not.toHaveBeenCalled();
         |                          ^
      62 |     expect(screen.queryByText(action === "json" ? translations.en.exportedJobs.replace("{format}", "JSON") : translations.en.convertedRows.replace("{count}", "1"))).not.toBeInTheDocument();
      63 |     expect(client.post).not.toHaveBeenCalled();
      64 |   });

      at toHaveBeenCalled (src/job-export-lifetime.test.tsx:61:26)

  ● json lifetime › a pending completion after context cannot download or announce success

    expect(jest.fn()).not.toHaveBeenCalled()

    Expected number of calls: 0
    Received number of calls: 1

    1: called with 0 arguments

      59 |     else act(() => window.dispatchEvent(new Event(SESSION_INVALIDATED_EVENT)));
      60 |     await act(async () => pending.resolve(action === "json" ? { data: new Blob(["[]"]) } : "Job Title,Company\nTeacher,Synthetic school"));
    > 61 |     expect(download).not.toHaveBeenCalled(); expect(URL.createObjectURL).not.toHaveBeenCalled();
         |                          ^
      62 |     expect(screen.queryByText(action === "json" ? translations.en.exportedJobs.replace("{format}", "JSON") : translations.en.convertedRows.replace("{count}", "1"))).not.toBeInTheDocument();
      63 |     expect(client.post).not.toHaveBeenCalled();
      64 |   });

      at toHaveBeenCalled (src/job-export-lifetime.test.tsx:61:26)

  ● json lifetime › a pending completion after event cannot download or announce success

    expect(jest.fn()).not.toHaveBeenCalled()

    Expected number of calls: 0
    Received number of calls: 1

    1: called with 0 arguments

      59 |     else act(() => window.dispatchEvent(new Event(SESSION_INVALIDATED_EVENT)));
      60 |     await act(async () => pending.resolve(action === "json" ? { data: new Blob(["[]"]) } : "Job Title,Company\nTeacher,Synthetic school"));
    > 61 |     expect(download).not.toHaveBeenCalled(); expect(URL.createObjectURL).not.toHaveBeenCalled();
         |                          ^
      62 |     expect(screen.queryByText(action === "json" ? translations.en.exportedJobs.replace("{format}", "JSON") : translations.en.convertedRows.replace("{count}", "1"))).not.toBeInTheDocument();
      63 |     expect(client.post).not.toHaveBeenCalled();
      64 |   });

      at toHaveBeenCalled (src/job-export-lifetime.test.tsx:61:26)

  ● json lifetime › a stale rejection cannot display feedback in the new session

    expect(element).not.toBeInTheDocument()

    expected document not to contain element, found <div class="MuiAlert-message css-zioonp-MuiAlert-message">Export failed.</div> instead

      72 |     context.mockReturnValue("owner-b-session");
      73 |     await act(async () => pending.reject(new Error("offline")));
    > 74 |     expect(screen.queryByText(action === "json" ? translations.en.exportFailed : translations.en.csvConversionFailed)).not.toBeInTheDocument();
         |                                                                                                                            ^
      75 |     expect(download).not.toHaveBeenCalled();
      76 |   });
      77 | });

      at Object.toBeInTheDocument (src/job-export-lifetime.test.tsx:74:124)

  ● convert lifetime › a pending completion after unmount cannot download or announce success

    expect(jest.fn()).not.toHaveBeenCalled()

    Expected number of calls: 0
    Received number of calls: 1

    1: called with 0 arguments

      59 |     else act(() => window.dispatchEvent(new Event(SESSION_INVALIDATED_EVENT)));
      60 |     await act(async () => pending.resolve(action === "json" ? { data: new Blob(["[]"]) } : "Job Title,Company\nTeacher,Synthetic school"));
    > 61 |     expect(download).not.toHaveBeenCalled(); expect(URL.createObjectURL).not.toHaveBeenCalled();
         |                          ^
      62 |     expect(screen.queryByText(action === "json" ? translations.en.exportedJobs.replace("{format}", "JSON") : translations.en.convertedRows.replace("{count}", "1"))).not.toBeInTheDocument();
      63 |     expect(client.post).not.toHaveBeenCalled();
      64 |   });

      at toHaveBeenCalled (src/job-export-lifetime.test.tsx:61:26)

  ● convert lifetime › a pending completion after context cannot download or announce success

    expect(jest.fn()).not.toHaveBeenCalled()

    Expected number of calls: 0
    Received number of calls: 1

    1: called with 0 arguments

      59 |     else act(() => window.dispatchEvent(new Event(SESSION_INVALIDATED_EVENT)));
      60 |     await act(async () => pending.resolve(action === "json" ? { data: new Blob(["[]"]) } : "Job Title,Company\nTeacher,Synthetic school"));
    > 61 |     expect(download).not.toHaveBeenCalled(); expect(URL.createObjectURL).not.toHaveBeenCalled();
         |                          ^
      62 |     expect(screen.queryByText(action === "json" ? translations.en.exportedJobs.replace("{format}", "JSON") : translations.en.convertedRows.replace("{count}", "1"))).not.toBeInTheDocument();
      63 |     expect(client.post).not.toHaveBeenCalled();
      64 |   });

      at toHaveBeenCalled (src/job-export-lifetime.test.tsx:61:26)

  ● convert lifetime › a pending completion after event cannot download or announce success

    expect(jest.fn()).not.toHaveBeenCalled()

    Expected number of calls: 0
    Received number of calls: 1

    1: called with 0 arguments

      59 |     else act(() => window.dispatchEvent(new Event(SESSION_INVALIDATED_EVENT)));
      60 |     await act(async () => pending.resolve(action === "json" ? { data: new Blob(["[]"]) } : "Job Title,Company\nTeacher,Synthetic school"));
    > 61 |     expect(download).not.toHaveBeenCalled(); expect(URL.createObjectURL).not.toHaveBeenCalled();
         |                          ^
      62 |     expect(screen.queryByText(action === "json" ? translations.en.exportedJobs.replace("{format}", "JSON") : translations.en.convertedRows.replace("{count}", "1"))).not.toBeInTheDocument();
      63 |     expect(client.post).not.toHaveBeenCalled();
      64 |   });

      at toHaveBeenCalled (src/job-export-lifetime.test.tsx:61:26)

  ● convert lifetime › a stale rejection cannot display feedback in the new session

    expect(element).not.toBeInTheDocument()

    expected document not to contain element, found <div class="MuiAlert-message css-zioonp-MuiAlert-message">CSV conversion failed.</div> instead

      72 |     context.mockReturnValue("owner-b-session");
      73 |     await act(async () => pending.reject(new Error("offline")));
    > 74 |     expect(screen.queryByText(action === "json" ? translations.en.exportFailed : translations.en.csvConversionFailed)).not.toBeInTheDocument();
         |                                                                                                                            ^
      75 |     expect(download).not.toHaveBeenCalled();
      76 |   });
      77 | });

      at Object.toBeInTheDocument (src/job-export-lifetime.test.tsx:74:124)

  ● an already invalidated session starts neither an export nor a file read

    expect(jest.fn()).not.toHaveBeenCalled()

    Expected number of calls: 0
    Received number of calls: 1

    1: "/export/jobs?format=json&includeDeleted=false", {"responseType": "blob"}

      82 |   const read = jest.fn(); const file = new File([], "jobs.csv"); Object.defineProperty(file, "text", { value: read });
      83 |   fireEvent.change(document.querySelector('input[accept=".csv,text/csv"]')!, { target: { files: [file] } });
    > 84 |   expect(client.get).not.toHaveBeenCalled(); expect(read).not.toHaveBeenCalled();
         |                          ^
      85 | });
      86 |
      87 | test.each(["json", "convert"] as const)("%s delayed rejection uses the current UI language", async action => {

      at Object.toHaveBeenCalled (src/job-export-lifetime.test.tsx:84:26)

  ● json delayed rejection uses the current UI language

    Unable to find an element with the text: Eksport mislyktes.. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

    Ignored nodes: comments, script, style
    <body>
      <div>
        <section
          aria-labelledby="_r_25_"
          class="MuiBox-root css-s8beop"
        >
          <header
            class="MuiBox-root css-163u82n"
          >
            <div
              class="MuiBox-root css-14m33b5"
            >
              <h3
                class="MuiTypography-root MuiTypography-sectionTitle css-uf4832-MuiTypography-root"
                id="_r_25_"
              >
                Import / eksport
              </h3>
              <p
                class="MuiTypography-root MuiTypography-pageDescription css-1sqgc3a-MuiTypography-root"
              >
                Import forventer JSON eksportert av denne appen (en matrise med jobbobjekter med innebygd selskap).
              </p>
            </div>
          </header>
          <div
            class="MuiBox-root css-31l7gp"
          >
            <div
              aria-busy="false"
              aria-label="Import / eksport"
              class="MuiBox-root css-dtwbgt"
              role="group"
              tabindex="-1"
            >
              <p
                class="MuiTypography-root MuiTypography-body2 css-1qf9eb3-MuiTypography-root"
              >
                Import oppretter nye jobber fra støttede felt. ID-er, eiere, historikk, vedlegg og CV-koblinger gjenopprettes ikke. Hold Innstillinger åpent til importen er ferdig. Hvis du går ut, kan importen bli ufullstendig.
              </p>
              <div
                class="MuiBox-root css-14qhqxr"
              >
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary css-1g6yn02-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Eksporter JSON
                </button>
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary css-1g6yn02-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Eksporter CSV
                </button>
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-83fk99-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Importer JSON
                </button>
                <input
                  accept="application/json"
                  hidden=""
                  type="file"
                />
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary css-1g6yn02-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Konverter CSV til import-JSON
                </button>
                <input
                  accept=".csv,text/csv"
                  hidden=""
                  type="file"
                />
              </div>
            </div>
          </div>
        </section>
      </div>
    </body>

      94 |   await act(async () => window.dispatchEvent(new StorageEvent("storage", { key: "uiLanguage", newValue: "nb" })));
      95 |   await act(async () => pending.reject(new Error("offline")));
    > 96 |   expect(await screen.findByText(action === "json" ? translations.nb.exportFailed : translations.nb.csvConversionFailed)).toBeVisible();
         |                       ^
      97 | });
      98 |

      at waitForWrapper (node_modules/@testing-library/dom/dist/wait-for.js:163:27)
      at node_modules/@testing-library/dom/dist/query-helpers.js:86:33
      at findByText (src/job-export-lifetime.test.tsx:96:23)

  ● convert delayed rejection uses the current UI language

    Unable to find an element with the text: CSV-konvertering mislyktes.. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.

    Ignored nodes: comments, script, style
    <body>
      <div>
        <section
          aria-labelledby="_r_2b_"
          class="MuiBox-root css-s8beop"
        >
          <header
            class="MuiBox-root css-163u82n"
          >
            <div
              class="MuiBox-root css-14m33b5"
            >
              <h3
                class="MuiTypography-root MuiTypography-sectionTitle css-uf4832-MuiTypography-root"
                id="_r_2b_"
              >
                Import / eksport
              </h3>
              <p
                class="MuiTypography-root MuiTypography-pageDescription css-1sqgc3a-MuiTypography-root"
              >
                Import forventer JSON eksportert av denne appen (en matrise med jobbobjekter med innebygd selskap).
              </p>
            </div>
          </header>
          <div
            class="MuiBox-root css-31l7gp"
          >
            <div
              aria-busy="false"
              aria-label="Import / eksport"
              class="MuiBox-root css-dtwbgt"
              role="group"
              tabindex="-1"
            >
              <p
                class="MuiTypography-root MuiTypography-body2 css-1qf9eb3-MuiTypography-root"
              >
                Import oppretter nye jobber fra støttede felt. ID-er, eiere, historikk, vedlegg og CV-koblinger gjenopprettes ikke. Hold Innstillinger åpent til importen er ferdig. Hvis du går ut, kan importen bli ufullstendig.
              </p>
              <div
                class="MuiBox-root css-14qhqxr"
              >
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary css-1g6yn02-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Eksporter JSON
                </button>
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary css-1g6yn02-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Eksporter CSV
                </button>
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-contained MuiButton-containedPrimary MuiButton-sizeMedium MuiButton-containedSizeMedium MuiButton-colorPrimary css-83fk99-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Importer JSON
                </button>
                <input
                  accept="application/json"
                  hidden=""
                  type="file"
                />
                <button
                  class="MuiButtonBase-root MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary MuiButton-root MuiButton-outlined MuiButton-outlinedPrimary MuiButton-sizeMedium MuiButton-outlinedSizeMedium MuiButton-colorPrimary css-1g6yn02-MuiButtonBase-root-MuiButton-root"
                  tabindex="0"
                  type="button"
                >
                  Konverter CSV til import-JSON
                </button>
                <input
                  accept=".csv,text/csv"
                  hidden=""
                  type="file"
                />
              </div>
            </div>
          </div>
        </section>
      </div>
    </body>

      94 |   await act(async () => window.dispatchEvent(new StorageEvent("storage", { key: "uiLanguage", newValue: "nb" })));
      95 |   await act(async () => pending.reject(new Error("offline")));
    > 96 |   expect(await screen.findByText(action === "json" ? translations.nb.exportFailed : translations.nb.csvConversionFailed)).toBeVisible();
         |                       ^
      97 | });
      98 |

      at waitForWrapper (node_modules/@testing-library/dom/dist/wait-for.js:163:27)
      at node_modules/@testing-library/dom/dist/query-helpers.js:86:33
      at findByText (src/job-export-lifetime.test.tsx:96:23)

Test Suites: 1 failed, 1 total
Tests:       11 failed, 3 passed, 14 total
Snapshots:   0 total
Time:        11.629 s
Ran all test suites matching job-export-lifetime.test.tsx.
