@bigbinary/neeto-playwright-commons 3.0.4 → 3.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -414,6 +414,7 @@ class RailsEmailApiClient {
414
414
  clearEmails = () => this.fetchJson(this.emailsEndpoint, {
415
415
  method: "DELETE",
416
416
  });
417
+ clearStaleEmails = (receivedBefore) => this.fetchJson(`${this.emailsEndpoint}?received_before=${encodeURIComponent(receivedBefore)}`, { method: "DELETE" });
417
418
  }
418
419
 
419
420
  class RoleApis {
@@ -60474,7 +60475,14 @@ class RailsEmailUtils {
60474
60475
  };
60475
60476
  };
60476
60477
  clearEmails = () => this.railsEmailClient.clearEmails();
60477
- getLatestEmail = (searchParams) => this.railsEmailClient.getLatestEmail(searchParams);
60478
+ clearStaleEmails = () => {
60479
+ const tenMinutesAgo = new Date(Date.now() - 10 * 60 * 1000);
60480
+ return this.railsEmailClient.clearStaleEmails(tenMinutesAgo.toISOString());
60481
+ };
60482
+ getLatestEmail = async (searchParams) => {
60483
+ await this.clearStaleEmails();
60484
+ await this.railsEmailClient.getLatestEmail(searchParams);
60485
+ };
60478
60486
  listEmails = (searchParams) => this.railsEmailClient.listEmails(searchParams);
60479
60487
  listMessages = async (messageSearchCriteria = {}, { receivedAfter = new Date(new Date().valueOf() - 60 * 60 * 1000), } = {}) => {
60480
60488
  const emails = await this.railsEmailClient.listEmails({
@@ -107404,6 +107412,7 @@ const commands = {
107404
107412
  const mailerUtils = new MailerUtils(neetoPlaywrightUtilities);
107405
107413
  await mailerUtils.fastmailApi.authorizeAndSetAccountId();
107406
107414
  await use(mailerUtils);
107415
+ IS_DEV_ENV && (await mailerUtils.railsEmailUtils.clearStaleEmails());
107407
107416
  },
107408
107417
  colorPicker: async ({ page }, use) => {
107409
107418
  const colorPicker = new ColorPickerUtils(page);