Skip to content

Commit 9ae7c79

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

File tree

1 file changed

+87
-0
lines changed

1 file changed

+87
-0
lines changed
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
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+
const edited_repo_snapshotpackagesColumn = await page
70+
.getByTestId('snapshot_package_count_button')
71+
.first()
72+
.textContent();
73+
expect(edited_repo_packageCountValue).toBe(edited_repo_snapshotpackagesColumn);
74+
await page.getByText('Close').click();
75+
});
76+
77+
// Search the random predefined package in the package list on snapshot details page modal
78+
await test.step('Search for a predefined package in the package list', async () => {
79+
const edited_row = await getRowByNameOrUrl(page, edited_repo);
80+
await edited_row.getByTestId('package_count_button').click();
81+
await expect(page.getByRole('dialog', { name: 'Package List' })).toBeVisible();
82+
await page.getByRole('textbox', { name: 'Filter by name' }).fill('bear');
83+
await expect(page.getByText('bear')).toBeVisible();
84+
await page.getByText('Close').click();
85+
});
86+
});
87+
});

0 commit comments

Comments
 (0)