In the US, you would have one year from a public disclosure to file a patent application. However, most countries don’t give as much time.
In most countries outside of the US, most notably at the European Patent Office, patents are evaluated from an “absolute novelty” standard, meaning that any sales or other public disclosure of an invention can eliminate the ability to get a patent for that invention. The one-year clock in the US is colloquially called a “grace period,” and very few other countries grant them. Canada provides a 1-year grace period, and Japan provides a 6-month grace period, but the details of how they are implemented varies, so it’s critical to consult with a patent professional in those countries before relying on grace periods.
The most common strategy pursued by those looking to market-test a product is to file a US provisional patent application before testing the market. The provisional application acts as a place-holder for a filing date. You then have exactly one year from the provisional application filing date to file a non-provisional patent application which will be treated as-if it was filed on the provisional filing date, but only with respect to the subject matter that was adequately described in the provisional. So, it’s worth being as thorough as possible in writing the provisional, but it can be done at a relatively low cost as compared with a non-provisional.
Based on my Quora answer to the question: