Files
threshold-ui/ui/desktop/tests/e2e/targets.spec.js
T
2024-08-02 13:28:50 -04:00

38 lines
1.1 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
const { test } = require('./fixtures/baseTest');
const { expect } = require('@playwright/test');
test.describe('Targets test', async () => {
test('Connects to a target and ends session', async ({ authedPage }) => {
await authedPage
.getByRole('link', { name: 'Generated target with a direct address' })
.click();
await authedPage.getByRole('button', { name: 'Connect' }).click();
await expect(authedPage).toHaveURL(
/.*\/scopes\/global\/projects\/sessions/,
);
await authedPage.getByRole('button', { name: 'End Session' }).click();
await expect(authedPage.getByText('Canceled successfully.')).toBeVisible();
await expect(authedPage).toHaveURL(
/.*\/scopes\/global\/projects\/targets$/,
);
});
test('Searches targets correctly', async ({ authedPage }) => {
await authedPage.getByLabel('Search').fill('hashicorp');
// One row is the header
await expect(authedPage.getByRole('row')).toHaveCount(2);
await expect(
authedPage.getByRole('link', { name: 'www.hashicorp.com' }),
).toBeVisible();
});
});