-
Notifications
You must be signed in to change notification settings - Fork 961
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: email handling & e2e CI bug #1896
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 2 Ignored Deployments
|
Thank you for following the naming conventions for pull request titles! 🙏 |
apps/web/playwright/team.spec.tsThere is a lot of repetition in the test code, especially when it comes to the dropdownTrigger and dropdownContentWrapper locators. It would be more maintainable and readable to create a helper function that handles the dropdown menu interaction. async function interactWithDropdown(page: Page) {
const dropdownTrigger = page.locator("#userDropdownTrigger");
await expect(dropdownTrigger).toBeVisible();
await dropdownTrigger.click();
const dropdownContentWrapper = page.locator("#userDropdownContentWrapper");
await expect(dropdownContentWrapper).toBeVisible();
}
packages/lib/emails/emails.tsThe transporter object is created every time the sendEmail function is called. This could be a performance issue if the function is called frequently. It would be more efficient to create the transporter object once and reuse it. let transporter: nodemailer.Transporter | null = null;
if (IS_SMTP_CONFIGURED) {
transporter = nodemailer.createTransport({
host: SMTP_HOST,
port: SMTP_PORT,
secure: SMTP_SECURE_ENABLED,
auth: {
user: SMTP_USER,
pass: SMTP_PASSWORD,
},
});
}
export const sendEmail = async (emailData: sendEmailData) => {
if (!transporter) {
console.log(`Could not Email :: SMTP not configured :: ${emailData.subject}`);
return;
}
const emailDefaults = {
from: `Formbricks <${MAIL_FROM || "noreply@formbricks.com"}>`,
};
await transporter.sendMail({ ...emailDefaults, ...emailData });
};
playwright.config.tsSetting the retries to 0 in the test configuration might lead to flaky tests, especially if the tests are run in a CI/CD environment where network conditions might vary. It would be more reliable to allow for a few retries. retries: 2,
|
@@ -14,7 +14,7 @@ export default defineConfig({ | |||
/* Run tests in files in parallel */ | |||
fullyParallel: true, | |||
/* Retry on CI only */ | |||
retries: 2, | |||
retries: 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Setting the retries to 2 in the test configuration to improve the reliability of the test suite, especially in a CI/CD environment where network conditions might vary.
retries: 0, | |
retries: 2, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShubhamPalriwala thank your for this improvement :-) Just two small things I think we should change:
packages/lib/emails/emails.ts
Outdated
}; | ||
await transporter.sendMail({ ...emailDefaults, ...emailData }); | ||
} else { | ||
console.log(`Could not Email :: SMTP not configured :: ${emailData.subject}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please change to console.error
packages/lib/emails/emails.ts
Outdated
user: SMTP_USER, | ||
pass: SMTP_PASSWORD, | ||
}, | ||
// logger: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now that you touched this file I would either remove the logging completely or uncomment them.
Or can we maybe couple them with the env variable DEBUG
?
logger: process.env.DEBUG === "1",
pass: process.env.DEBUG === "1"
(it would be good to add the debug variable to the constant file in that case to make this easier readable)
I would prefer this option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, please take a look 🤞🏼
…bricks/formbricks into shubham/debug-playwright-ci
What does this PR do?
Fixes # (issue)
Checklist
Required
pnpm build
console.logs
git pull origin main
Appreciated