2024-08-23 10:17:10 -04:00
|
|
|
/**
|
|
|
|
|
* Copyright (c) HashiCorp, Inc.
|
|
|
|
|
* SPDX-License-Identifier: BUSL-1.1
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { expect } from '@playwright/test';
|
|
|
|
|
|
2024-11-12 11:21:37 -05:00
|
|
|
import { BaseResourcePage } from './base-resource.js';
|
2024-08-23 10:17:10 -04:00
|
|
|
|
|
|
|
|
export class LoginPage extends BaseResourcePage {
|
|
|
|
|
/**
|
|
|
|
|
* Logs in to the Admin UI
|
|
|
|
|
* @param {string} loginName Username to log in with
|
|
|
|
|
* @param {string} password Password to log in with
|
|
|
|
|
*/
|
|
|
|
|
async login(loginName, password) {
|
|
|
|
|
await this.page.getByLabel('Login Name').fill(loginName);
|
|
|
|
|
await this.page.getByLabel('Password', { exact: true }).fill(password);
|
|
|
|
|
await this.page.getByRole('button', { name: 'Sign In' }).click();
|
2024-11-12 18:11:00 -05:00
|
|
|
await expect(
|
2025-04-14 14:27:02 -07:00
|
|
|
this.page.getByRole('navigation', {
|
2025-11-18 17:00:45 -05:00
|
|
|
name: 'Application local navigation',
|
2025-04-14 14:27:02 -07:00
|
|
|
}),
|
2024-11-12 18:11:00 -05:00
|
|
|
).toBeVisible();
|
|
|
|
|
await expect(this.page.getByText(loginName)).toBeEnabled();
|
2024-08-23 10:17:10 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Logs out of the Admin UI
|
|
|
|
|
* @param {string} loginName Username to log out
|
|
|
|
|
*/
|
|
|
|
|
async logout(loginName) {
|
|
|
|
|
await this.page.getByText(loginName).click();
|
|
|
|
|
await this.page.getByRole('button', { name: 'Sign Out' }).click();
|
2024-11-12 18:11:00 -05:00
|
|
|
await expect(
|
|
|
|
|
this.page.getByRole('button', { name: 'Sign In' }),
|
|
|
|
|
).toBeVisible();
|
2024-08-23 10:17:10 -04:00
|
|
|
}
|
|
|
|
|
}
|