"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __async = (__this, __arguments, generator) => {
  return new Promise((resolve, reject) => {
    var fulfilled = (value) => {
      try {
        step(generator.next(value));
      } catch (e) {
        reject(e);
      }
    };
    var rejected = (value) => {
      try {
        step(generator.throw(value));
      } catch (e) {
        reject(e);
      }
    };
    var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
    step((generator = generator.apply(__this, __arguments)).next());
  });
};
var import_vitest = require("vitest");
var import_context = require("@vitest/browser/context");
var import_react = require("@storybook/react");
var stories = __toESM(require("./FeedbackContainer.stories"), 1);
var React = __toESM(require("react"), 1);
var import_react_test_utils = require("@nova/react-test-utils");
var import_vitest_browser_react = require("vitest-browser-react");
const { Primary, Liked, LikeFailure } = (0, import_react.composeStories)(stories);
(0, import_vitest.describe)("FeedbackContainer", () => {
  (0, import_vitest.it)("should correctly propagate parameters even when multiple stories with same resolvers are rendered", () => __async(void 0, null, function* () {
    (0, import_vitest_browser_react.render)(/* @__PURE__ */ React.createElement(Primary, null));
    (0, import_vitest_browser_react.render)(/* @__PURE__ */ React.createElement(Liked, null));
    (0, import_vitest_browser_react.render)(/* @__PURE__ */ React.createElement(Primary, null));
    const texts = import_context.page.getByText("Feedback: Feedback title");
    (0, import_vitest.expect)(texts.elements()).toHaveLength(3);
  }));
  (0, import_vitest.it)("should show an error if the like button fails", () => __async(void 0, null, function* () {
    var _a;
    const { container } = (0, import_vitest_browser_react.render)(/* @__PURE__ */ React.createElement(LikeFailure, null));
    yield (_a = LikeFailure.play) == null ? void 0 : _a.call(LikeFailure, (0, import_react_test_utils.prepareStoryContextForTest)(LikeFailure, container));
    const error = import_context.page.getByText("Something went wrong");
    yield import_vitest.expect.element(error).toBeInTheDocument();
  }));
});
