function question(
  type,
  {
    name = "test question",
    native,
    query,
    database = 1,
    display = "table",
    visualization_settings = {},
    collection_id,
    collection_position,
  } = {},
  { loadMetadata = false, visitQuestion = false } = {},
) {
  cy.request("POST", "/api/card", {
    name,
    dataset_query: {
      type,
      [type]: type === "native" ? native : query,
      database,
    },
    display,
    visualization_settings,
    collection_id,
    collection_position,
  }).then(({ body }) => {
    if (loadMetadata || visitQuestion) {
      cy.intercept("POST", `/api/card/${body.id}/query`).as("cardQuery");
      cy.visit(`/question/${body.id}`);

      // Wait for `result_metadata` to load
      cy.wait("@cardQuery");
    }
  });
}
/**
 *
 * @param {("query"|"native")} type
 *
 * @param {object} questionDetails
 * @param {string} [questionDetails.name="test question"]
 * @param {object} questionDetails.native
 * @param {object} questionDetails.query
 * @param {number} [questionDetails.database=1]
 * @param {string} [questionDetails.display="table"]
 * @param {object} [questionDetails.visualization_settings={}]
 * @param {number} [questionDetails.collection_id] - Parent collection in which to store this question.
 * @param {number} [questionDetails.collection_position] - used on the frontend to determine whether the question is pinned or not.
 *
 * @param {object} customOptions
 * @param {boolean} customOptions.loadMetadata - Whether to visit the question in order to load its metadata.
 * @param {boolean} customOptions.visitQuestion - Whether to visit the question after the creation or not.
 */


@param {object} customOptions
@param {boolean} customOptions.loadMetadata - Whether to visit the question in order to load its metadata.
@param {boolean} customOptions.visitQuestion - Whether to visit the question after the creation or not.
@param { object } customOptions @param { boolean } customOptions . loadMetadata - Whether to visit the question in order to load its metadata . @param { boolean } customOptions . visitQuestion - Whether to visit the question after the creation or not .
function question(
  type,
  {
    name = "test question",
    native,
    query,
    database = 1,
    display = "table",
    visualization_settings = {},
    collection_id,
    collection_position,
  } = {},
  { loadMetadata = false, visitQuestion = false } = {},
) {
  cy.request("POST", "/api/card", {
    name,
    dataset_query: {
      type,
      [type]: type === "native" ? native : query,
      database,
    },
    display,
    visualization_settings,
    collection_id,
    collection_position,
  }).then(({ body }) => {
    if (loadMetadata || visitQuestion) {
      cy.intercept("POST", `/api/card/${body.id}/query`).as("cardQuery");
      cy.visit(`/question/${body.id}`);
      cy.wait("@cardQuery");
    }
  });
}
function question ( type , { name = "test question" , native , query , database = 1 , display = "table" , visualization_settings = { } , collection_id , collection_position , } = { } , { loadMetadata = false , visitQuestion = false } = { } , ) { cy . request ( "POST" , "/api/card" , { name , dataset_query : { type , [ type ] : type === "native" ? native : query , database , } , display , visualization_settings , collection_id , collection_position , } ) . then ( ( { body } ) => { if ( loadMetadata || visitQuestion ) { cy . intercept ( "POST" , ` ${ body . id } ` ) . as ( "cardQuery" ) ; cy . visit ( ` ${ body . id } ` ) ; cy . wait ( "@cardQuery" ) ; } } ) ; }
@param {("query"|"native")} type
 @param {object} questionDetails
 @param {string} [questionDetails.name="test question"]
 @param {object} questionDetails.native
 @param {object} questionDetails.query
 @param {number} [questionDetails.database=1]
 @param {string} [questionDetails.display="table"]
 @param {object} [questionDetails.visualization_settings={}]
 @param {number} [questionDetails.collection_id] - Parent collection in which to store this question.
@param { ( " query " | " native " ) } type @param { object } questionDetails @param { string } [ questionDetails . name = " test question " ] @param { object } questionDetails . native @param { object } questionDetails . query @param { number } [ questionDetails . database = 1 ] @param { string } [ questionDetails . display = " table " ] @param { object } [ questionDetails . visualization_settings = {} ] @param { number } [ questionDetails . collection_id ] - Parent collection in which to store this question .
// Wait for `result_metadata` to load