Skip to content

Commit d1f3dc3

Browse files
committed
Add test for verifying snapshot package count and package search functionality
1 parent 8292b24 commit d1f3dc3

File tree

1 file changed

+94
-0
lines changed

1 file changed

+94
-0
lines changed
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import { test, expect } from '@playwright/test';
2+
import { navigateToRepositories } from './helpers/navHelpers';
3+
import { deleteAllRepos } from './helpers/deleteRepositories';
4+
import { closePopupsIfExist, getRowByNameOrUrl } from './helpers/helpers';
5+
const repoNamePrefix = 'snapshot-package-list-test';
6+
const randomName = () => `${(Math.random() + 1).toString(36).substring(2, 6)}`;
7+
const repoName = `${repoNamePrefix}-${randomName()}`;
8+
const editedRepo = `${repoName}-Edited`;
9+
10+
test.describe('Snapshot Package Count and List', async () => {
11+
test('Verify package count and search functionality in snapshot details', async ({ page }) => {
12+
await navigateToRepositories(page);
13+
await closePopupsIfExist(page);
14+
await deleteAllRepos(page, `&search=${repoNamePrefix}`);
15+
16+
await test.step('Create a repository', async () => {
17+
await page.getByRole('button', { name: 'Add repositories' }).first().click();
18+
await expect(page.getByRole('dialog', { name: 'Add custom repositories' })).toBeVisible();
19+
await page.getByLabel('Name').fill(`${repoName}`);
20+
await page.getByLabel('Snapshotting').click();
21+
await page.getByLabel('URL').fill('https://jlsherrill.fedorapeople.org/fake-repos/signed/');
22+
await page.getByRole('button', { name: 'Save', exact: true }).click();
23+
});
24+
25+
await test.step('Wait for status to be "Valid"', async () => {
26+
const row = await getRowByNameOrUrl(page, repoName);
27+
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
28+
});
29+
30+
await test.step('Verify the package count matches the snapshot', async () => {
31+
const row = await getRowByNameOrUrl(page, repoName);
32+
const packageCountValue = await row.getByTestId('package_count_button').textContent();
33+
await page.getByRole('button', { name: 'Kebab toggle' }).click();
34+
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
35+
// click on the first row to view the snapshot details
36+
const snapshotPackagesColumn = await page
37+
.getByTestId('snapshot_package_count_button')
38+
.textContent();
39+
// assert the package count matches the after snapshot packages count
40+
expect(packageCountValue).toBe(snapshotPackagesColumn);
41+
await page.getByText('Close').click();
42+
});
43+
44+
// Edit the repository to change number of packages
45+
await test.step('Update the repository', async () => {
46+
const row = await getRowByNameOrUrl(page, repoName);
47+
await row.getByLabel('Kebab toggle').click();
48+
await row.getByRole('menuitem', { name: 'Edit' }).click();
49+
await page.getByPlaceholder('Enter name', { exact: true }).fill(editedRepo);
50+
await page
51+
.getByLabel('URL')
52+
.fill('http://jlsherrill.fedorapeople.org/fake-repos/needed-errata/');
53+
await page.getByRole('button', { name: 'Save changes', exact: true }).click();
54+
const editedRow = await getRowByNameOrUrl(page, editedRepo);
55+
await expect(editedRow.getByText('Valid')).toBeVisible({ timeout: 60000 });
56+
});
57+
58+
await test.step('Verify the package count matches the edited snapshot', async () => {
59+
const editedRow = await getRowByNameOrUrl(page, editedRepo);
60+
const editedRepoPackageCountValue = await editedRow
61+
.getByTestId('package_count_button')
62+
.textContent();
63+
await page.getByRole('button', { name: 'Kebab toggle' }).click();
64+
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
65+
// refresh page to get the updated snapshot
66+
await page.reload();
67+
const editedRepoSnapshotPackagesColumn = await page
68+
.getByTestId('snapshot_package_count_button')
69+
.first()
70+
.textContent();
71+
expect(editedRepoPackageCountValue).toBe(editedRepoSnapshotPackagesColumn);
72+
await page.getByText('Close').click();
73+
});
74+
75+
// Search the random predefined package in the package list on snapshot details page modal
76+
await test.step('Search for a predefined package in the package list', async () => {
77+
const editedRow = await getRowByNameOrUrl(page, editedRepo);
78+
await editedRow.getByTestId('package_count_button').click();
79+
await expect(page.getByRole('dialog', { name: 'Packages' })).toBeVisible();
80+
await page.getByRole('textbox', { name: 'Filter by name' }).fill('bear');
81+
await expect(page.getByText('bear')).toBeVisible();
82+
// check that non exixiting package is not visible in the list
83+
await page.getByRole('textbox', { name: 'Filter by name' }).fill('non-existing-package');
84+
await expect(page.getByText('non-existing-package')).not.toBeVisible();
85+
await expect(
86+
page.getByRole('heading', { name: 'No packages match the filter criteria' }),
87+
).toBeVisible();
88+
await page.getByText('Close').click();
89+
});
90+
await test.step('Post test cleanup', async () => {
91+
await deleteAllRepos(page, `&search=${repoNamePrefix}`);
92+
});
93+
});
94+
});

0 commit comments

Comments
 (0)