Skip to content

Commit fa67adf

Browse files
authored
HMS-6006: QE-migrate iqe test_snapshot_package_count_and_list (#514)
* Add test for verifying snapshot package count and package search functionality * Add test for verifying snapshot package count and package search functionality * Updated locators to target the specific repository row to prevent failures when multiple repositories are present. This ensures the test interacts with the correct row. * Removed page reload step for snapshot list table There is no need to refresh the page now that the bug(PR-526) is fixed! * Remove: Accidently pushed another file
1 parent db5eadc commit fa67adf

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
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 editedRow.getByRole('button', { name: 'Kebab toggle' }).click();
64+
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
65+
const editedRepoSnapshotPackagesColumn = await page
66+
.getByTestId('snapshot_package_count_button')
67+
.first()
68+
.textContent();
69+
expect(editedRepoPackageCountValue).toBe(editedRepoSnapshotPackagesColumn);
70+
await page.getByText('Close').click();
71+
});
72+
73+
// Search the random predefined package in the package list on snapshot details page modal
74+
await test.step('Search for a predefined package in the package list', async () => {
75+
const editedRow = await getRowByNameOrUrl(page, editedRepo);
76+
await editedRow.getByTestId('package_count_button').click();
77+
await expect(page.getByRole('dialog', { name: 'Packages' })).toBeVisible();
78+
await page.getByRole('textbox', { name: 'Filter by name' }).fill('bear');
79+
await expect(page.getByText('bear')).toBeVisible();
80+
// check that non exixiting package is not visible in the list
81+
await page.getByRole('textbox', { name: 'Filter by name' }).fill('non-existing-package');
82+
await expect(page.getByText('non-existing-package')).not.toBeVisible();
83+
await expect(
84+
page.getByRole('heading', { name: 'No packages match the filter criteria' }),
85+
).toBeVisible();
86+
await page.getByText('Close').click();
87+
});
88+
await test.step('Post test cleanup', async () => {
89+
await deleteAllRepos(page, `&search=${repoNamePrefix}`);
90+
});
91+
});
92+
});

0 commit comments

Comments
 (0)