mirror of
https://github.com/dani-garcia/vaultwarden.git
synced 2025-09-08 18:52:43 +00:00
Playwright upgrade maildev to use MailBuffer.expect
This commit is contained in:
parent
9d0338d740
commit
cbe2dc9f76
8 changed files with 28 additions and 27 deletions
|
@ -50,7 +50,7 @@ test('Login', async ({ context, page }) => {
|
|||
|
||||
await utils.checkNotification(page, 'Check your email inbox for a verification link');
|
||||
|
||||
const verify = await mailBuffer.next((m) => m.subject === "Verify Your Email");
|
||||
const verify = await mailBuffer.expect((m) => m.subject === "Verify Your Email");
|
||||
expect(verify.from[0]?.address).toBe(process.env.PW_SMTP_FROM);
|
||||
|
||||
const page2 = await context.newPage();
|
||||
|
|
|
@ -48,7 +48,7 @@ test('Invite users', async ({ page }) => {
|
|||
});
|
||||
|
||||
test('invited with new account', async ({ page }) => {
|
||||
const invited = await mail2Buffer.next((mail) => mail.subject === 'Join Test');
|
||||
const invited = await mail2Buffer.expect((mail) => mail.subject === 'Join Test');
|
||||
|
||||
await test.step('Create account', async () => {
|
||||
await page.setContent(invited.html);
|
||||
|
@ -69,14 +69,14 @@ test('invited with new account', async ({ page }) => {
|
|||
});
|
||||
|
||||
await test.step('Check mails', async () => {
|
||||
await expect(mail2Buffer.next((m) => m.subject === 'Welcome')).resolves.toBeDefined();
|
||||
await expect(mail2Buffer.next((m) => m.subject === 'New Device Logged In From Firefox')).resolves.toBeDefined();
|
||||
await expect(mail1Buffer.next((m) => m.subject.includes('Invitation to Test accepted'))).resolves.toBeDefined();
|
||||
await mail2Buffer.expect((m) => m.subject === 'Welcome');
|
||||
await mail2Buffer.expect((m) => m.subject === 'New Device Logged In From Firefox');
|
||||
await mail1Buffer.expect((m) => m.subject.includes('Invitation to Test accepted'));
|
||||
});
|
||||
});
|
||||
|
||||
test('invited with existing account', async ({ page }) => {
|
||||
const invited = await mail3Buffer.next((mail) => mail.subject === 'Join Test');
|
||||
const invited = await mail3Buffer.expect((mail) => mail.subject === 'Join Test');
|
||||
|
||||
await page.setContent(invited.html);
|
||||
const link = await page.getByTestId('invite').getAttribute('href');
|
||||
|
@ -95,8 +95,8 @@ test('invited with existing account', async ({ page }) => {
|
|||
await expect(page).toHaveTitle(/Vaultwarden Web/);
|
||||
await utils.checkNotification(page, 'Invitation accepted');
|
||||
|
||||
await expect(mail3Buffer.next((m) => m.subject === 'New Device Logged In From Firefox')).resolves.toBeDefined();
|
||||
await expect(mail1Buffer.next((m) => m.subject.includes('Invitation to Test accepted'))).resolves.toBeDefined();
|
||||
await mail3Buffer.expect((m) => m.subject === 'New Device Logged In From Firefox');
|
||||
await mail1Buffer.expect((m) => m.subject.includes('Invitation to Test accepted'));
|
||||
});
|
||||
|
||||
test('Confirm invited user', async ({ page }) => {
|
||||
|
@ -105,7 +105,7 @@ test('Confirm invited user', async ({ page }) => {
|
|||
await orgs.members(test, page, 'Test');
|
||||
await orgs.confirm(test, page, 'Test', users.user2.email);
|
||||
|
||||
await expect(mail2Buffer.next((m) => m.subject.includes('Invitation to Test confirmed'))).resolves.toBeDefined();
|
||||
await mail2Buffer.expect((m) => m.subject.includes('Invitation to Test confirmed'));
|
||||
});
|
||||
|
||||
test('Organization is visible', async ({ page }) => {
|
||||
|
|
|
@ -65,7 +65,7 @@ export async function activateEmail(test: Test, page: Page, user: { name: string
|
|||
|
||||
export async function retrieveEmailCode(test: Test, page: Page, mailBuffer: MailBuffer): string {
|
||||
return await test.step('retrieve code', async () => {
|
||||
const codeMail = await mailBuffer.next((mail) => mail.subject.includes("Login Verification Code"));
|
||||
const codeMail = await mailBuffer.expect((mail) => mail.subject.includes("Login Verification Code"));
|
||||
const page2 = await page.context().newPage();
|
||||
await page2.setContent(codeMail.html);
|
||||
const code = await page2.getByTestId("2fa").innerText();
|
||||
|
|
|
@ -53,8 +53,8 @@ export async function logNewUser(
|
|||
if( options.mailBuffer ){
|
||||
let mailBuffer = options.mailBuffer;
|
||||
await test.step('Check emails', async () => {
|
||||
await expect(mailBuffer.next((m) => m.subject === "Welcome")).resolves.toBeDefined();
|
||||
await expect(mailBuffer.next((m) => m.subject.includes("New Device Logged"))).resolves.toBeDefined();
|
||||
await mailBuffer.expect((m) => m.subject === "Welcome");
|
||||
await mailBuffer.expect((m) => m.subject.includes("New Device Logged"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -131,7 +131,7 @@ export async function logUser(
|
|||
|
||||
if( mailBuffer ){
|
||||
await test.step('Check email', async () => {
|
||||
await expect(mailBuffer.next((m) => m.subject.includes("New Device Logged"))).resolves.toBeDefined();
|
||||
await mailBuffer.expect((m) => m.subject.includes("New Device Logged"));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
|
@ -28,8 +28,8 @@ export async function createAccount(test, page: Page, user: { email: string, nam
|
|||
await utils.checkNotification(page, 'You have been logged in!');
|
||||
|
||||
if( mailBuffer ){
|
||||
await expect(mailBuffer.next((m) => m.subject === "Welcome")).resolves.toBeDefined();
|
||||
await expect(mailBuffer.next((m) => m.subject === "New Device Logged In From Firefox")).resolves.toBeDefined();
|
||||
await mailBuffer.expect((m) => m.subject === "Welcome");
|
||||
await mailBuffer.expect((m) => m.subject === "New Device Logged In From Firefox");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -49,7 +49,7 @@ export async function logUser(test, page: Page, user: { email: string, password:
|
|||
await expect(page).toHaveTitle(/Vaultwarden Web/);
|
||||
|
||||
if( mailBuffer ){
|
||||
await expect(mailBuffer.next((m) => m.subject === "New Device Logged In From Firefox")).resolves.toBeDefined();
|
||||
await mailBuffer.expect((m) => m.subject === "New Device Logged In From Firefox");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
@ -49,7 +49,7 @@ test('Invite users', async ({ page }) => {
|
|||
|
||||
test('invited with new account', async ({ page }) => {
|
||||
const link = await test.step('Extract email link', async () => {
|
||||
const invited = await mail2Buffer.next((m) => m.subject === "Join /Test");
|
||||
const invited = await mail2Buffer.expect((m) => m.subject === "Join /Test");
|
||||
await page.setContent(invited.html);
|
||||
return await page.getByTestId("invite").getAttribute("href");
|
||||
});
|
||||
|
@ -80,14 +80,14 @@ test('invited with new account', async ({ page }) => {
|
|||
});
|
||||
|
||||
await test.step('Check mails', async () => {
|
||||
await expect(mail2Buffer.next((m) => m.subject.includes("New Device Logged"))).resolves.toBeDefined();
|
||||
await expect(mail1Buffer.next((m) => m.subject === "Invitation to /Test accepted")).resolves.toBeDefined();
|
||||
await mail2Buffer.expect((m) => m.subject.includes("New Device Logged"));
|
||||
await mail1Buffer.expect((m) => m.subject === "Invitation to /Test accepted");
|
||||
});
|
||||
});
|
||||
|
||||
test('invited with existing account', async ({ page }) => {
|
||||
const link = await test.step('Extract email link', async () => {
|
||||
const invited = await mail3Buffer.next((m) => m.subject === "Join /Test");
|
||||
const invited = await mail3Buffer.expect((m) => m.subject === "Join /Test");
|
||||
await page.setContent(invited.html);
|
||||
return await page.getByTestId("invite").getAttribute("href");
|
||||
});
|
||||
|
@ -115,7 +115,7 @@ test('invited with existing account', async ({ page }) => {
|
|||
});
|
||||
|
||||
await test.step('Check mails', async () => {
|
||||
await expect(mail3Buffer.next((m) => m.subject.includes("New Device Logged"))).resolves.toBeDefined();
|
||||
await expect(mail1Buffer.next((m) => m.subject === "Invitation to /Test accepted")).resolves.toBeDefined();
|
||||
await mail3Buffer.expect((m) => m.subject.includes("New Device Logged"));
|
||||
await mail1Buffer.expect((m) => m.subject === "Invitation to /Test accepted");
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue