feat: 🎸 add search capability for host sources (#2861)
* feat: 🎸 add search capability for host sources ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094 * refactor: 💡 use Rose::Pagination component ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094 * refactor: 💡 move target detail body to index route to fix whole page reload issue ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094 * Add missing copyright headers * refactor: 💡 PR feedback ✅ Closes: https://hashicorp.atlassian.net/browse/ICU-17094 --------- Co-authored-by: cameronperera <29386339+cameronperera@users.noreply.github.com>
This commit is contained in:
1 parent
738fa1f15f
commit
57e614e8db
9 files changed
+394
-173
No files matched your search
@@ -55,9 +55,8 @@ test.afterEach(async ({ request }) => {
|
||||
}
|
||||
});
|
||||
|
||||
test.describe('Target with many hosts', () => {
|
||||
// TODO: Add tests for searching host sources
|
||||
test('should display all hosts in the target', async ({ authedPage }) => {
|
||||
test.describe('Search and Pagination', () => {
|
||||
test('target details', async ({ authedPage }) => {
|
||||
await authedPage
|
||||
.getByRole('link', { name: targetWithManyHosts.name })
|
||||
.click();
|
||||
@@ -76,7 +75,7 @@ test.describe('Target with many hosts', () => {
|
||||
// Navigate to the second page. The last host should now be visible.
|
||||
await authedPage
|
||||
.getByRole('navigation', { name: 'pagination' })
|
||||
.getByRole('button', { name: 'page 2' })
|
||||
.getByRole('link', { name: 'page 2' })
|
||||
.click();
|
||||
await expect(
|
||||
authedPage.getByRole('cell', { name: hosts[0].name, exact: true }),
|
||||
@@ -91,7 +90,7 @@ test.describe('Target with many hosts', () => {
|
||||
// Use the "previous page" button to navigate back to the first page.
|
||||
await authedPage
|
||||
.getByRole('navigation', { name: 'pagination' })
|
||||
.getByRole('button', { name: 'Previous page' })
|
||||
.getByRole('link', { name: 'Previous page' })
|
||||
.click();
|
||||
await expect(
|
||||
authedPage.getByRole('cell', { name: hosts[0].name, exact: true }),
|
||||
@@ -106,7 +105,7 @@ test.describe('Target with many hosts', () => {
|
||||
// Use the "next page" button to navigate to the second page again.
|
||||
await authedPage
|
||||
.getByRole('navigation', { name: 'pagination' })
|
||||
.getByRole('button', { name: 'Next page' })
|
||||
.getByRole('link', { name: 'Next page' })
|
||||
.click();
|
||||
await expect(
|
||||
authedPage.getByRole('cell', { name: hosts[0].name, exact: true }),
|
||||
@@ -137,6 +136,52 @@ test.describe('Target with many hosts', () => {
|
||||
.getByRole('row')
|
||||
.filter({ hasNot: authedPage.getByRole('columnheader') }),
|
||||
).toHaveCount(10);
|
||||
|
||||
// Search for a specific host
|
||||
const host = hosts[12];
|
||||
await authedPage.getByRole('searchbox', { name: 'Search' }).fill(host.name);
|
||||
|
||||
await expect(
|
||||
authedPage
|
||||
.getByRole('row')
|
||||
.filter({ hasNot: authedPage.getByRole('columnheader') }),
|
||||
).toHaveCount(1);
|
||||
|
||||
// Clear the search box
|
||||
await authedPage.getByRole('searchbox', { name: 'Search' }).fill('');
|
||||
|
||||
await expect(
|
||||
authedPage
|
||||
.getByRole('row')
|
||||
.filter({ hasNot: authedPage.getByRole('columnheader') }),
|
||||
).toHaveCount(10);
|
||||
await expect(authedPage.getByText('1–10 of 15')).toBeVisible();
|
||||
|
||||
// Search with query that matches multiple hosts
|
||||
await authedPage.getByRole('searchbox', { name: 'Search' }).fill('Host 1');
|
||||
await expect(
|
||||
authedPage.getByRole('cell', {
|
||||
name: hosts[0].name,
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
authedPage.getByRole('cell', {
|
||||
name: hosts[10].name,
|
||||
exact: true,
|
||||
}),
|
||||
).toBeVisible();
|
||||
await expect(
|
||||
authedPage
|
||||
.getByRole('row')
|
||||
.filter({ hasNot: authedPage.getByRole('columnheader') }),
|
||||
).toHaveCount(7);
|
||||
|
||||
// Search for a host that does not exist
|
||||
await authedPage
|
||||
.getByRole('searchbox', { name: 'Search' })
|
||||
.fill('Nonexistent Host');
|
||||
await expect(authedPage.getByRole('table')).toBeHidden();
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in new issue
Block a user