Browse Source

Fix playwright tests

pull/3899/head
Timshel 4 weeks ago
parent
commit
ffff75add5
  1. 1
      playwright/tests/collection.spec.ts
  2. 10
      playwright/tests/login.spec.ts
  3. 23
      playwright/tests/organization.smtp.spec.ts
  4. 1
      playwright/tests/organization.spec.ts
  5. 20
      playwright/tests/setups/sso.ts
  6. 11
      playwright/tests/setups/user.ts
  7. 3
      playwright/tests/sso_login.spec.ts
  8. 12
      playwright/tests/sso_organization.smtp.spec.ts

1
playwright/tests/collection.spec.ts

@ -15,7 +15,6 @@ test.afterAll('Teardown', async ({}) => {
test('Create', async ({ page }) => {
await createAccount(test, page, users.user1);
await logUser(test, page, users.user1);
await test.step('Create Org', async () => {
await page.getByRole('link', { name: 'New organisation' }).click();

10
playwright/tests/login.spec.ts

@ -16,17 +16,7 @@ test.afterAll('Teardown', async ({}, testInfo: TestInfo) => {
});
test('Account creation', async ({ page }) => {
// Landing page
await createAccount(test, page, users.user1);
await page.getByRole('button', { name: 'Continue' }).click();
// Unlock page
await page.getByLabel('Master password').fill(users.user1.password);
await page.getByRole('button', { name: 'Log in with master password' }).click();
// We are now in the default vault page
await expect(page).toHaveTitle(/Vaultwarden Web/);
});
test('Master password login', async ({ page }) => {

23
playwright/tests/organization.smtp.spec.ts

@ -38,7 +38,6 @@ test('Create user3', async ({ page }) => {
test('Invite users', async ({ page }) => {
await createAccount(test, page, users.user1, mail1Buffer);
await logUser(test, page, users.user1, mail1Buffer);
await orgs.create(test, page, 'Test');
await orgs.members(test, page, 'Test');
@ -57,25 +56,15 @@ test('invited with new account', async ({ page }) => {
await page.goto(link);
await expect(page).toHaveTitle(/Create account | Vaultwarden Web/);
await page.getByLabel('Name').fill(users.user2.name);
await page.getByLabel('Master password\n (required)', { exact: true }).fill(users.user2.password);
await page.getByLabel('Re-type master password').fill(users.user2.password);
//await page.getByLabel('Name').fill(users.user2.name);
await page.getByLabel('Master password (required)', { exact: true }).fill(users.user2.password);
await page.getByLabel('Confirm master password (').fill(users.user2.password);
await page.getByRole('button', { name: 'Create account' }).click();
// Back to the login page
await utils.checkNotification(page, 'Your new account has been created');
});
await test.step('Login', async () => {
await page.getByLabel(/Email address/).fill(users.user2.email);
await page.getByRole('button', { name: 'Continue' }).click();
// Unlock page
await page.getByLabel('Master password').fill(users.user2.password);
await page.getByRole('button', { name: 'Log in with master password' }).click();
// We are now in the default vault page
await expect(page).toHaveTitle(/Vaultwarden Web/);
// Redirected to the vault
await expect(page).toHaveTitle('Vaults | Vaultwarden Web');
await utils.checkNotification(page, 'You have been logged in!');
await utils.checkNotification(page, 'Invitation accepted');
});

1
playwright/tests/organization.spec.ts

@ -20,7 +20,6 @@ test('Create user3', async ({ page }) => {
test('Invite users', async ({ page }) => {
await createAccount(test, page, users.user1);
await logUser(test, page, users.user1);
await test.step('Create Org', async () => {
await page.getByRole('link', { name: 'New organisation' }).click();

20
playwright/tests/setups/sso.ts

@ -18,11 +18,7 @@ export async function logNewUser(
await test.step('Landing page', async () => {
await page.goto('/');
await page.getByLabel(/Email address/).fill(user.email);
await page.getByRole('button', 'Continue').click();
});
await test.step('SSo start page', async () => {
await page.getByRole('link', { name: /Enterprise single sign-on/ }).click();
await page.getByRole('button', { name: /Use single sign-on/ }).click();
});
await test.step('Keycloak login', async () => {
@ -33,10 +29,10 @@ export async function logNewUser(
});
await test.step('Create Vault account', async () => {
await expect(page.getByText('Set master password')).toBeVisible();
await page.getByLabel('Master password', { exact: true }).fill(user.password);
await page.getByLabel('Re-type master password').fill(user.password);
await page.getByRole('button', { name: 'Submit' }).click();
await expect(page.getByRole('heading', { name: 'Join organisation' })).toBeVisible();
await page.getByLabel('Master password (required)', { exact: true }).fill(user.password);
await page.getByLabel('Confirm master password (').fill(user.password);
await page.getByRole('button', { name: 'Create account' }).click();
});
await test.step('Default vault page', async () => {
@ -73,11 +69,7 @@ export async function logUser(
await test.step('Landing page', async () => {
await page.goto('/');
await page.getByLabel(/Email address/).fill(user.email);
await page.getByRole('button', 'Continue').click();
});
await test.step('SSo start page', async () => {
await page.getByRole('link', { name: /Enterprise single sign-on/ }).click();
await page.getByRole('button', { name: /Use single sign-on/ }).click();
});
await test.step('Keycloak login', async () => {

11
playwright/tests/setups/user.ts

@ -13,12 +13,15 @@ export async function createAccount(test, page: Page, user: { email: string, nam
await expect(page).toHaveTitle(/Create account | Vaultwarden Web/);
await page.getByLabel(/Email address/).fill(user.email);
await page.getByLabel('Name').fill(user.name);
await page.getByLabel('Master password\n (required)', { exact: true }).fill(user.password);
await page.getByLabel('Re-type master password').fill(user.password);
await page.getByRole('button', { name: 'Continue' }).click();
// Vault finish Creation
await page.getByLabel('Master password (required)', { exact: true }).fill(user.password);
await page.getByLabel('Confirm master password (').fill(user.password);
await page.getByRole('button', { name: 'Create account' }).click();
// Back to the login page
await expect(page).toHaveTitle('Vaultwarden Web');
// We are now in the default vault page
await expect(page).toHaveTitle('Vaults | Vaultwarden Web');
await utils.checkNotification(page, 'Your new account has been created');
if( mailBuffer ){

3
playwright/tests/sso_login.spec.ts

@ -55,9 +55,6 @@ test('Non SSO login impossible', async ({ page, browser }, testInfo: TestInfo) =
// An error should appear
await page.getByLabel('SSO sign-in is required')
// Check the selector for the next test
await expect(page.getByRole('link', { name: /Enterprise single sign-on/ })).toHaveCount(1);
});

12
playwright/tests/sso_organization.smtp.spec.ts

@ -89,15 +89,17 @@ test('invited with new account', async ({ page }) => {
});
await test.step('Create Vault account', async () => {
await expect(page.getByText('Set master password')).toBeVisible();
await page.getByLabel('Master password', { exact: true }).fill(users.user2.password);
await page.getByLabel('Re-type master password').fill(users.user2.password);
await page.getByRole('button', { name: 'Submit' }).click();
await expect(page.getByRole('heading', { name: 'Join organisation' })).toBeVisible();
await page.getByLabel('Master password (required)', { exact: true }).fill(users.user2.password);
await page.getByLabel('Confirm master password (').fill(users.user2.password);
await page.getByRole('button', { name: 'Create account' }).click();
});
await test.step('Default vault page', async () => {
await expect(page).toHaveTitle(/Vaultwarden Web/);
// await utils.checkNotification(page, 'Invitation accepted');
await utils.checkNotification(page, 'Account successfully created!');
await utils.checkNotification(page, 'Invitation accepted');
});
await test.step('Check mails', async () => {

Loading…
Cancel
Save