From 903edec8b172590bc809149d6f58f59d56797755 Mon Sep 17 00:00:00 2001 From: Hallie Swan <26949006+hallieswan@users.noreply.github.com> Date: Fri, 8 Sep 2023 09:30:50 -0700 Subject: [PATCH] SWC-6536: confirm that inputs have been entered to before submitting form, confirm login was correct before waiting for redirect --- e2e/helpers/testUser.ts | 20 ++++++++++++++++++-- e2e/projects.loggedin.spec.ts | 6 +++++- e2e/teams.loggedin.spec.ts | 5 ++++- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/e2e/helpers/testUser.ts b/e2e/helpers/testUser.ts index feee00a4df..f561e924e5 100644 --- a/e2e/helpers/testUser.ts +++ b/e2e/helpers/testUser.ts @@ -71,10 +71,26 @@ export async function loginTestUser( await page.getByRole('link', { name: 'Log in to Synapse' }).first().click() await page.getByRole('button', { name: 'Sign in with your email' }).click() - await page.getByLabel('Username or Email Address').fill(testUserName) - await page.getByLabel('Password').fill(testUserPassword) + + const usernameInput = page.getByLabel('Username or Email Address') + await usernameInput.fill(testUserName) + await expect(usernameInput).toHaveValue(testUserName) + + const passwordInput = page.getByLabel('Password') + await expect(passwordInput).toBeEmpty() + await passwordInput.fill(testUserPassword) + await expect(passwordInput).not.toBeEmpty() + await page.getByRole('button', { name: 'Sign in' }).click() + // Ensure that correct username/password were received + const loadingButton = page.getByRole('button', { name: 'Logging you in' }) + await expect(loadingButton).toBeVisible() + await expect(loadingButton).not.toBeVisible() + await expect( + page.getByText('The provided username/password combination is incorrect'), + ).not.toBeVisible() + // Wait for redirect await expect(async () => { expect(page.url()).not.toContain('LoginPlace') diff --git a/e2e/projects.loggedin.spec.ts b/e2e/projects.loggedin.spec.ts index 62b0625eb9..df875e9714 100644 --- a/e2e/projects.loggedin.spec.ts +++ b/e2e/projects.loggedin.spec.ts @@ -8,7 +8,11 @@ const PROJECT_NAME = 'swc-e2e-project-' + uuidv4() async function createProject(page: Page, projectName: string) { await page.getByLabel('Projects', { exact: true }).click() await page.getByLabel('Create a New Project').click() - await page.getByLabel('Project Name').type(projectName) + + const projectNameInput = page.getByLabel('Project Name') + await projectNameInput.fill(projectName) + await expect(projectNameInput).toHaveValue(projectName) + await page.getByRole('button', { name: 'Save' }).click() } diff --git a/e2e/teams.loggedin.spec.ts b/e2e/teams.loggedin.spec.ts index 1349c6a212..facc9fbe5c 100644 --- a/e2e/teams.loggedin.spec.ts +++ b/e2e/teams.loggedin.spec.ts @@ -65,7 +65,10 @@ test.describe('Teams', () => { ).toBeVisible() await userPage.getByRole('button', { name: 'Create a New Team' }).click() - await userPage.getByRole('textbox').nth(1).fill(TEAM_NAME) + const teamNameInput = userPage.getByRole('textbox').nth(1) + await teamNameInput.fill(TEAM_NAME) + await expect(teamNameInput).toHaveValue(TEAM_NAME) + await userPage.getByRole('button', { name: 'OK' }).click() await expect( userPage.getByText(`Team Created: ${TEAM_NAME}`),