Skip to content

HMS-6036: QE - migrate iqe test_snapshot_deletion #524

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 12 commits into from
May 30, 2025
Merged
Changes from all 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
130 changes: 129 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 @@ -101,4 +101,132 @@ test.describe('Snapshot Repositories', () => {
await expect(row).not.toBeVisible();
});
});

test('Snapshot deletion', async ({ page }) => {
const smallRHRepo = 'Red Hat CodeReady Linux Builder for RHEL 9 ARM 64 (RPMs)';

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-for-snapshot-deletion-${randomName()}`;

await test.step('Cleanup repositories using "zoo" URLs', async () => {
await deleteAllRepos(page, `&search=https://fedorapeople.org/groups/katello/fakerepos/zoo`);
});

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: 70000 });
});

await test.step('Edit the repository', async () => {
for (let i = 2; i <= 4; i++) {
const row = await getRowByNameOrUrl(page, repoName);
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
await test.step(`Edit repository and create snapshot ${i}`, async () => {
// Open the edit modal
await row.getByLabel('Kebab toggle').click();
await page.getByRole('menuitem', { name: 'Edit' }).click({ timeout: 60000 });
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: 70000 });
});
}
});

await test.step('Create a template', async () => {
const row = await getRowByNameOrUrl(page, repoName);
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
await row.getByRole('button', { name: 'Kebab toggle' }).click();
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
await expect(page.getByRole('button', { name: '1 - 4 of 4' }).first()).toBeVisible({
timeout: 60000,
});
await navigateToTemplates(page);
await page.getByRole('button', { name: 'Add content template' }).click();
await page.getByRole('button', { name: 'filter arch' }).click();
await page.getByRole('menuitem', { name: 'aarch64' }).click();
await page.getByRole('button', { name: 'filter version' }).click();
await page.getByRole('menuitem', { name: 'el9' }).click();
await page.getByRole('button', { name: 'Next', exact: true }).click();
const modalPage = page.getByTestId('add_template_modal');
const rowRHELRepo = await getRowByNameOrUrl(modalPage, smallRHRepo);
await rowRHELRepo.getByLabel('Select row').click();
// wait till next button is enabled
await page.getByRole('button', { name: 'Next', exact: true }).isEnabled();
await page.getByRole('button', { name: 'Next', exact: true }).click();
await expect(page.getByTestId('custom_repositories_step')).toBeVisible();
await row.click();
await page.getByRole('button', { name: 'Next', exact: true }).click();
await expect(page.getByTestId('set_up_date')).toBeVisible();
await page.getByTestId('use-latest-snapshot-radio').click();
await page.getByRole('radio', { name: 'Use latest content' }).check();
await page.getByRole('button', { name: 'Next' }).click();
await page.getByPlaceholder('Enter name').fill(`${templateName}`);
await page.getByPlaceholder('Description').fill('Template test');
await page.getByRole('button', { name: 'Next', exact: true }).click();
await page.getByRole('button', { name: 'Create other options' }).click();
await page.getByText('Create template only', { exact: true }).click();
const templateRow = await getRowByNameOrUrl(page, templateName);
await expect(templateRow.getByText('Valid')).toBeVisible({ timeout: 60000 });
// Verify the template is created and uses the latest snapshot
await expect(templateRow.getByText('Use latest')).toBeVisible();
});

// Test deletion of a single snapshot.
await test.step('Delete a single snapshot', async () => {
await navigateToRepositories(page);
const row = await getRowByNameOrUrl(page, repoName);
await row.getByLabel('Kebab toggle').click();
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
await expect(page.getByLabel('SnapshotsView list of').locator('tbody')).toBeVisible();
await page
.getByTestId('snapshot_list_table')
.locator('tbody tr')
.first()
.getByLabel('Kebab toggle')
.click();
await page.getByRole('menuitem', { name: 'Delete' }).click();
await expect(page.getByText('Remove snapshots?')).toBeVisible();
await page.getByText('Remove', { exact: true }).click();
await expect(page.getByRole('button', { name: '1 - 3 of 3' }).first()).toBeVisible({
timeout: 60000,
});
await page.getByText('Close').click();
});

await test.step('Bulk delete snapshot', async () => {
// Test bulk deletion of multiple snapshots.
// Before bulk delete we need to wait for previous deletion to finish or it will fail.
await page.waitForTimeout(6000);
const row = await getRowByNameOrUrl(page, repoName);
await row.getByLabel('Kebab toggle').click();
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
await expect(page.getByLabel('SnapshotsView list of').locator('tbody')).toBeVisible();
await page.getByRole('row', { name: 'select-snapshot-checkbox' }).locator('label').click();
// Verify that you can't delete all snapshots
// Bulk delete button is disabled
await expect(page.getByTestId('remove_snapshots_bulk')).toBeDisabled();
// Therefore uncheck the first snapshot
await page.getByRole('checkbox', { name: 'Select row 0' }).uncheck();
await page.getByTestId('remove_snapshots_bulk').click();
await expect(page.getByText('Remove snapshots?')).toBeVisible();
await page.getByText('Remove', { exact: true }).click();
await expect(page.getByRole('button', { name: '1 - 1 of 1' }).first()).toBeVisible({
timeout: 60000,
});
await page.getByText('Close').click();
});
await deleteAllRepos(page, `&search=${repoNamePrefix}`);
});
});
Loading