Files
threshold-ui/e2e-tests/admin/tests/login.spec.js
T
Michael Li 1cbf3b227e test(e2e): Add additional assertions to UI tests (#2634)
* test(e2e): Address deprecation

* test(e2e): Add additional connection assertions on tests

* CR: Fix flake when waiting for sessions

If no sessions are available and the page needs to reload, we should wait to ensure that the page has loaded before checking what the state of the sessions are

* CR: Address flake in connect methods

Noticed an issue where a session recording was not playable. The theory is that the session didn't last long enough before it was cancelled. This adds a 2 second wait after establishing a connection before continuing.

* CR: Use authenticated state by default

* CR: Update dynamic host catalog assertion

* CR: Simplify host set checks

- Use .all() when looping
- Add check to see if we need to reload the page or not

* CR: Be more specific with locator

Ran into a conflict with the Static/Dynamic host catalog type and the Static/Dynamic credential type.

* CR: Update connection methods to be more resilient

Rather than using a hardcoded sleep, we will now run a command on the target and wait for a specific string to return before continuing.

* CR
2025-01-06 11:40:32 -05:00

79 lines
2.5 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { test } from '../../global-setup.js';
import { expect } from '@playwright/test';
import { LoginPage } from '../pages/login.js';
// Reset storage state for this file to avoid being authenticated
test.use({ storageState: { cookies: [], origins: [] } });
test('Log in, log out, and then log back in @ce @ent @aws @docker', async ({
page,
adminLoginName,
adminPassword,
}) => {
await page.goto('/');
// Log in
const loginPage = new LoginPage(page);
await loginPage.login(adminLoginName, adminPassword);
await expect(
page.getByRole('navigation', { name: 'breadcrumbs' }).getByText('Orgs'),
).toBeVisible();
// Log out
await loginPage.logout(adminLoginName);
await page.reload();
// Log back in
await loginPage.login(adminLoginName, adminPassword);
await expect(
page.getByRole('navigation', { name: 'breadcrumbs' }).getByText('Orgs'),
).toBeVisible();
});
test.describe('Failure Cases', async () => {
test.beforeEach(async ({ page }) => {
await page.goto('/');
});
test('Log in with invalid password @ce @ent @aws @docker', async ({
page,
adminLoginName,
}) => {
await page.getByLabel('Login Name').fill(adminLoginName);
await page.getByLabel('Password', { exact: true }).fill('badpassword');
await page.getByRole('button', { name: 'Sign In' }).click();
await expect(page.getByRole('alert').getByText('Error')).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign In' })).toBeVisible();
await expect(page.getByText(adminLoginName)).toBeHidden();
});
test('Log in with only username @ce @ent @aws @docker', async ({
page,
adminLoginName,
}) => {
await page.getByLabel('Login Name').fill('testuser');
await page.getByRole('button', { name: 'Sign In' }).click();
await expect(page.getByRole('alert').getByText('Error')).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign In' })).toBeVisible();
await expect(page.getByText(adminLoginName)).toBeHidden();
});
test('Log in with only password @ce @ent @aws @docker', async ({
page,
adminLoginName,
adminPassword,
}) => {
await page.getByLabel('Password', { exact: true }).fill(adminPassword);
await page.getByRole('button', { name: 'Sign In' }).click();
await expect(page.getByRole('alert').getByText('Error')).toBeVisible();
await expect(page.getByRole('button', { name: 'Sign In' })).toBeVisible();
await expect(page.getByText(adminLoginName)).toBeHidden();
});
});