Files
threshold-ui/e2e-tests/admin/tests/worker.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

82 lines
2.7 KiB
JavaScript

/**
* Copyright (c) HashiCorp, Inc.
* SPDX-License-Identifier: BUSL-1.1
*/
import { test } from '../../global-setup.js';
import { expect } from '@playwright/test';
test('Create a worker @ce @docker @aws', async ({ page, browserName }) => {
test.skip(browserName === 'webkit', 'Bug in worker form on Safari');
await page.goto('/');
await page
.getByRole('navigation', { name: 'General' })
.getByRole('link', { name: 'Workers' })
.click();
await page.getByRole('link', { name: 'New', exact: true }).click();
// Populate config fields
await page.getByLabel('Worker public address').fill('worker1.example.com');
await page.getByLabel('Config file path').fill('/home/ubuntu/boundary');
await page.getByLabel('Initial upstreams').fill('10.0.0.1, 10.0.0.2');
await page
.getByRole('group', { name: 'Worker Tags' })
.getByLabel('Key')
.fill('type');
await page
.getByRole('group', { name: 'Worker Tags' })
.getByLabel('Value')
.fill('downstream, pki');
await page
.getByRole('group', { name: 'Worker Tags' })
.getByRole('button', { name: 'Add' })
.click();
await page
.getByRole('group', { name: 'Worker Tags' })
.getByLabel('Key')
.last()
.fill('test');
await page
.getByRole('group', { name: 'Worker Tags' })
.getByLabel('Value')
.last()
.fill('example');
await page
.getByRole('group', { name: 'Worker Tags' })
.getByRole('button', { name: 'Add' })
.click();
// Check auto-populated configs
const dirLocator = '[data-test-worker-directory]';
await expect(page.locator(dirLocator)).toContainText(
'mkdir /home/ubuntu/boundary/ ;',
);
await expect(page.locator(dirLocator)).toContainText(
'touch /home/ubuntu/boundary/pki-worker.hcl',
);
const configLocator = '[data-test-worker-config]';
await expect(page.locator(configLocator)).toContainText(
'public_addr = "worker1.example.com"',
);
await expect(page.locator(configLocator)).toContainText(
'auth_storage_path = "/home/ubuntu/boundary/worker1"',
);
await expect(page.locator(configLocator)).toContainText(
'initial_upstreams = ["10.0.0.1", "10.0.0.2"]',
);
await expect(page.locator(configLocator)).toContainText(
'type = ["downstream", "pki"]',
);
await expect(page.locator(configLocator)).toContainText('test = ["example"]');
// Try using an invalid worker token. Expect an error
await page.getByLabel('Worker Auth Registration Request').fill('test');
await page.getByRole('button', { name: 'Register' }).click();
await expect(
page.getByRole('alert').getByText('Error', { exact: true }),
).toBeVisible();
await page.getByRole('button', { name: 'Dismiss' }).click();
});