Skip to content

Commit fef0a29

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

File tree

1 file changed

+95
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)