Skip to content

Commit e114dd8

Browse files
committed
refactor(tests): Organize snapshot deletion test and ensure clean state
- Moved the snapshot deletion test into the 'Snapshot Repositories' describe block. - Added a step to check for existing "zoo" repositories and delete them if present, ensuring a clean state before starting the test.
1 parent 2b4ce2a commit e114dd8

File tree

1 file changed

+19
-14
lines changed

1 file changed

+19
-14
lines changed

_playwright-tests/UI/SnapshotRepo.spec.ts

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,25 @@ test.describe('Snapshot Repositories', () => {
102102
await expect(row).not.toBeVisible();
103103
});
104104
});
105-
});
106105

107-
test.describe('Snapshot Deletion with Template creation', () => {
108106
test('Snapshot deletion', async ({ page }) => {
109107
await navigateToRepositories(page);
110108
await closePopupsIfExist(page);
111109
const repoNamePrefix = 'snapshot-deletion';
112110
const randomName = () => `${(Math.random() + 1).toString(36).substring(2, 6)}`;
113111
const repoName = `${repoNamePrefix}-${randomName()}`;
114112
const templateName = `Test-template-for-snapshot-deletion-${randomName()}`;
115-
await test.step('Cleanup repositories using "zoo" URL', async () => {
116-
await deleteAllRepos(page, `&url=zoo`);
113+
114+
await test.step('Cleanup repositories using "zoo" URLs', async () => {
115+
const zooUrls = [
116+
'https://fedorapeople.org/groups/katello/fakerepos/zoo',
117+
'https://fedorapeople.org/groups/katello/fakerepos/zoo2',
118+
'https://fedorapeople.org/groups/katello/fakerepos/zoo3',
119+
'https://fedorapeople.org/groups/katello/fakerepos/zoo4',
120+
];
121+
for (const url of zooUrls) {
122+
await deleteAllRepos(page, `&url=${url}`);
123+
}
117124
});
118125

119126
await test.step('Create a repository', async () => {
@@ -144,19 +151,16 @@ test.describe('Snapshot Deletion with Template creation', () => {
144151
}
145152
});
146153

147-
await test.step('Verify the snapshot count for the repo.', async () => {
154+
await test.step('Create a template', async () => {
148155
const row = await getRowByNameOrUrl(page, repoName);
149156
await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 });
150-
await page.getByRole('button', { name: 'Kebab toggle' }).click();
157+
await row.getByRole('button', { name: 'Kebab toggle' }).click();
151158
await page.getByRole('menuitem', { name: 'View all snapshots' }).click();
152159
// Count the number of rows in the snapshot list table
153-
// const snapshotCount =
154-
// (await page.getByTestId('snapshot_list_table').locator('tr').count()) - 1; // Subtract 1 for the header row
160+
const snapshotCount =
161+
(await page.getByTestId('snapshot_list_table').locator('tr').count()) - 1; // Subtract 1 for the header row
155162
await page.getByLabel('Close', { exact: true }).click();
156-
});
157-
await test.step('Create a template', async () => {
158163
// Create a template which uses the repo and assert that is uses the latest snapshot
159-
const row = await getRowByNameOrUrl(page, repoName);
160164
await navigateToTemplates(page);
161165
await page.getByRole('button', { name: 'Add content template' }).click();
162166
await page.getByRole('button', { name: 'Select architecture' }).click();
@@ -178,10 +182,11 @@ test.describe('Snapshot Deletion with Template creation', () => {
178182
const templateRow = await getRowByNameOrUrl(page, templateName);
179183
await expect(templateRow.getByText('Valid')).toBeVisible({ timeout: 60000 });
180184
// Verify the template is created and uses the latest snapshot
181-
// const snapshotDateElement = await templateRow.getByTitle('Snapshot date');
182-
// expect(await snapshotDateElement.textContent()).toBe('Use latest');
185+
await expect(templateRow.getByText('Use latest')).toBeVisible();
186+
183187
// Assert that the template snapshot count matches the repo snapshot count
184-
// expect(snapshotCount).toBe(4);
188+
// add timeout in below step
189+
expect(snapshotCount).toBe(4);
185190
});
186191

187192
// Test deletion of a single snapshot.

0 commit comments

Comments
 (0)