Skip to content

HMS-6006: QE-migrate iqe test_snapshot_package_count_and_list #514

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
92 changes: 92 additions & 0 deletions _playwright-tests/UI/RepositoryPackages.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
import { test, expect } from '@playwright/test';
import { navigateToRepositories } from './helpers/navHelpers';
import { deleteAllRepos } from './helpers/deleteRepositories';
import { closePopupsIfExist, getRowByNameOrUrl } from './helpers/helpers';
const repoNamePrefix = 'snapshot-package-list-test';
const randomName = () => `${(Math.random() + 1).toString(36).substring(2, 6)}`;
const repoName = `${repoNamePrefix}-${randomName()}`;
const editedRepo = `${repoName}-Edited`;

test.describe('Snapshot Package Count and List', async () => {
test('Verify package count and search functionality in snapshot details', async ({ page }) => {
await navigateToRepositories(page);
await closePopupsIfExist(page);
await deleteAllRepos(page, `&search=${repoNamePrefix}`);

await test.step('Create a repository', async () => {
await page.getByRole('button', { name: 'Add repositories' }).first().click();
await expect(page.getByRole('dialog', { name: 'Add custom repositories' })).toBeVisible();
await page.getByLabel('Name').fill(`${repoName}`);
await page.getByLabel('Snapshotting').click();
await page.getByLabel('URL').fill('https://jlsherrill.fedorapeople.org/fake-repos/signed/');
await page.getByRole('button', { name: 'Save', exact: true }).click();
});

await test.step('Wait for status to be "Valid"', async () => {
const row = await getRowByNameOrUrl(page, repoName);
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
});

await test.step('Verify the package count matches the snapshot', async () => {
const row = await getRowByNameOrUrl(page, repoName);
const packageCountValue = await row.getByTestId('package_count_button').textContent();
await page.getByRole('button', { name: 'Kebab toggle' }).click();
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
// click on the first row to view the snapshot details
const snapshotPackagesColumn = await page
.getByTestId('snapshot_package_count_button')
.textContent();
// assert the package count matches the after snapshot packages count
expect(packageCountValue).toBe(snapshotPackagesColumn);
await page.getByText('Close').click();
});

// Edit the repository to change number of packages
await test.step('Update the repository', async () => {
const row = await getRowByNameOrUrl(page, repoName);
await row.getByLabel('Kebab toggle').click();
await row.getByRole('menuitem', { name: 'Edit' }).click();
await page.getByPlaceholder('Enter name', { exact: true }).fill(editedRepo);
await page
.getByLabel('URL')
.fill('http://jlsherrill.fedorapeople.org/fake-repos/needed-errata/');
await page.getByRole('button', { name: 'Save changes', exact: true }).click();
const editedRow = await getRowByNameOrUrl(page, editedRepo);
await expect(editedRow.getByText('Valid')).toBeVisible({ timeout: 60000 });
});

await test.step('Verify the package count matches the edited snapshot', async () => {
const editedRow = await getRowByNameOrUrl(page, editedRepo);
const editedRepoPackageCountValue = await editedRow
.getByTestId('package_count_button')
.textContent();
await editedRow.getByRole('button', { name: 'Kebab toggle' }).click();
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
const editedRepoSnapshotPackagesColumn = await page
.getByTestId('snapshot_package_count_button')
.first()
.textContent();
expect(editedRepoPackageCountValue).toBe(editedRepoSnapshotPackagesColumn);
await page.getByText('Close').click();
});

// Search the random predefined package in the package list on snapshot details page modal
await test.step('Search for a predefined package in the package list', async () => {
const editedRow = await getRowByNameOrUrl(page, editedRepo);
await editedRow.getByTestId('package_count_button').click();
await expect(page.getByRole('dialog', { name: 'Packages' })).toBeVisible();
await page.getByRole('textbox', { name: 'Filter by name' }).fill('bear');
await expect(page.getByText('bear')).toBeVisible();
// check that non exixiting package is not visible in the list
await page.getByRole('textbox', { name: 'Filter by name' }).fill('non-existing-package');
await expect(page.getByText('non-existing-package')).not.toBeVisible();
await expect(
page.getByRole('heading', { name: 'No packages match the filter criteria' }),
).toBeVisible();
await page.getByText('Close').click();
});
await test.step('Post test cleanup', async () => {
await deleteAllRepos(page, `&search=${repoNamePrefix}`);
});
});
});
70 changes: 69 additions & 1 deletion _playwright-tests/UI/SnapshotRepo.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test, expect } from '@playwright/test';
import { navigateToRepositories } from './helpers/navHelpers';
import { navigateToRepositories, navigateToTemplates } from './helpers/navHelpers';
import { deleteAllRepos } from './helpers/deleteRepositories';
import {
closePopupsIfExist,
Expand Down Expand Up @@ -103,3 +103,71 @@
});
});
});

test('Snapshot deletion', async ({ page }) => {
await navigateToRepositories(page);
await closePopupsIfExist(page);

const repoNamePrefix = 'snapshot-deletion';
const randomName = () => `${(Math.random() + 1).toString(36).substring(2, 6)}`;
const repoName = `${repoNamePrefix}-${randomName()}`;
const templateName = `Test-template-${randomName()}`;

await test.step('Create a repository', async () => {
await page.getByRole('button', { name: 'Add repositories' }).first().click();
await expect(page.getByRole('dialog', { name: 'Add custom repositories' })).toBeVisible();
await page.getByLabel('Name').fill(`${repoName}`);
await page.getByLabel('Snapshotting').click();
await page.getByLabel('URL').fill('https://fedorapeople.org/groups/katello/fakerepos/zoo/');
await page.getByRole('button', { name: 'Save', exact: true }).click();
const row = await getRowByNameOrUrl(page, repoName);
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
});

// Edit the repository and create snapshots
await test.step('Create a repository', async () => {
const row = await getRowByNameOrUrl(page, repoName);
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
for (let i = 2; i <= 4; i++) {
await test.step(`Edit repository and create snapshot ${i}`, async () => {
// Open the edit modal
await row.getByLabel('Kebab toggle').click();
await row.getByRole('menuitem', { name: 'Edit' }).click();
await page
.getByLabel('URL')
.fill(`https://fedorapeople.org/groups/katello/fakerepos/zoo/${i}/`);
await page.getByRole('button', { name: 'Save changes', exact: true }).click();
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
});
}
// Verify the snapshot count for the repo.
await row.getByTestId('snapshot_list_table').textContent();
// Create a template which uses the repo and assert that is uses the latest snapshot
await navigateToTemplates(page);
await page.getByRole('button', { name: 'Add content template' }).click();
await page.getByRole('button', { name: 'Select architecture' }).click();
await page.getByRole('option', { name: 'aarch64' }).click();
await page.getByRole('button', { name: 'Select version' }).click();
await page.getByRole('option', { name: 'el9' }).click();
await page.getByRole('button', { name: 'Next', exact: true }).click();
// search for row in the add content template modal
await page.getByRole('textbox', { name: 'Filter by name/url' }).fill(repoName);
await page.getByRole('gridcell', { name: 'Select row' }).locator('label').click();
await page.getByRole('button', { name: 'Next', exact: true }).click();
await page.getByRole('radio', { name: 'Use latest content' }).check();
await page.getByRole('button', { name: 'Next' }).click();
await page.getByPlaceholder('Enter name').fill(``);
await page.getByPlaceholder('Description').fill('Template test');
await expect(page.getByText('Valid')).toBeVisible({ timeout: 60000 });
// Verify the template is created and uses the latest snapshot
const templateRow = await getRowByNameOrUrl(page, templateName);
await expect(templateRow.getByText('Valid')).toBeVisible({ timeout: 60000 });
const templateSnapshotCount = await templateRow

Check warning on line 165 in _playwright-tests/UI/SnapshotRepo.spec.ts

View workflow job for this annotation

GitHub Actions / lint

'templateSnapshotCount' is assigned a value but never used

Check failure on line 165 in _playwright-tests/UI/SnapshotRepo.spec.ts

View workflow job for this annotation

GitHub Actions / lint

'templateSnapshotCount' is assigned a value but never used
.getByTestId('snapshot_list_table')
.textContent();
});

// Assert that the template snapshot count matches the repo snapshot count
// Test deletion of a single snapshot.
// Test bulk deletion of multiple snapshots.
});
Loading