From 499b0fde313929d12c54281491460e6e7ec47189 Mon Sep 17 00:00:00 2001 From: Michael Li Date: Fri, 22 Mar 2024 16:22:34 -0400 Subject: [PATCH] refact(e2e): Convert to match "create" helper convention (#2200) --- ui/admin/tests/e2e/helpers/boundary-ui.js | 10 +++++++--- ui/admin/tests/e2e/tests/auth-method-password.spec.js | 9 ++------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/ui/admin/tests/e2e/helpers/boundary-ui.js b/ui/admin/tests/e2e/helpers/boundary-ui.js index bd69f9566..77071a923 100644 --- a/ui/admin/tests/e2e/helpers/boundary-ui.js +++ b/ui/admin/tests/e2e/helpers/boundary-ui.js @@ -713,14 +713,16 @@ exports.makeAuthMethodPrimary = async (page) => { }; /** - * Uses the UI to create new Account. Assumes you have selected the desired Auth Method + * Uses the UI to create new password Account. Assumes you have selected the desired Auth Method * which the account will be created for. * @param {Page} page Playwright page object - * @param {string} accountName Name of new account * @param {string} login Login of new account * @param {string} password Password of new account + * @returns Name of the account */ -exports.addAccountToAuthMethod = async (page, accountName, login, password) => { +exports.createPasswordAccount = async (page, login, password) => { + const accountName = 'Account ' + nanoid(); + await page.getByRole('link', { name: 'Accounts' }).click(); await page .getByRole('article') @@ -739,6 +741,8 @@ exports.addAccountToAuthMethod = async (page, accountName, login, password) => { .getByRole('navigation', { name: 'breadcrumbs' }) .getByText(accountName), ).toBeVisible(); + + return accountName; }; /** diff --git a/ui/admin/tests/e2e/tests/auth-method-password.spec.js b/ui/admin/tests/e2e/tests/auth-method-password.spec.js index 01dd61bc7..27099828d 100644 --- a/ui/admin/tests/e2e/tests/auth-method-password.spec.js +++ b/ui/admin/tests/e2e/tests/auth-method-password.spec.js @@ -15,7 +15,7 @@ const { const { createOrg, createPasswordAuthMethod, - addAccountToAuthMethod, + createPasswordAccount, setPasswordToAccount, createUser, addAccountToUser, @@ -44,12 +44,7 @@ test('Verify new auth-method can be created and assigned to users @ce @ent @aws const orgs = JSON.parse(execSync('boundary scopes list -format json')); org = orgs.items.filter((obj) => obj.name == orgName)[0]; await createPasswordAuthMethod(page); - await addAccountToAuthMethod( - page, - 'UI Test Account', - 'test-user', - 'password', - ); + await createPasswordAccount(page, 'test-user', 'password'); await setPasswordToAccount(page, 'password2'); await makeAuthMethodPrimary(page); await createUser(page);