|
1 | 1 | import { test, expect } from '@playwright/test';
|
2 |
| -import { navigateToRepositories } from './helpers/navHelpers'; |
| 2 | +import { navigateToRepositories, navigateToTemplates } from './helpers/navHelpers'; |
3 | 3 | import { deleteAllRepos } from './helpers/deleteRepositories';
|
4 | 4 | import {
|
5 | 5 | closePopupsIfExist,
|
@@ -98,8 +98,68 @@ test.describe('Snapshot Repositories', () => {
|
98 | 98 | ),
|
99 | 99 | page.getByRole('button', { name: 'Remove' }).click(),
|
100 | 100 | ]);
|
101 |
| - |
102 | 101 | await expect(row).not.toBeVisible();
|
| 102 | + }); |
| 103 | + |
| 104 | + |
| 105 | + |
| 106 | +test('Snapshot deletion', async ({ page }) => { |
| 107 | + await navigateToRepositories(page); |
| 108 | + await closePopupsIfExist(page); |
| 109 | + |
| 110 | + const repoNamePrefix = 'snapshot-deletion'; |
| 111 | + const randomName = () => `${(Math.random() + 1).toString(36).substring(2, 6)}`; |
| 112 | + const repoName = `${repoNamePrefix}-${randomName()}`; |
| 113 | + const templateName = `Test-template-${randomName()}`; |
| 114 | + |
| 115 | + await test.step('Create a repository', async () => { |
| 116 | + await page.getByRole('button', { name: 'Add repositories' }).first().click(); |
| 117 | + await expect(page.getByRole('dialog', { name: 'Add custom repositories' })).toBeVisible(); |
| 118 | + await page.getByLabel('Name').fill(`${repoName}`); |
| 119 | + await page.getByLabel('Snapshotting').click(); |
| 120 | + await page.getByLabel('URL').fill('https://fedorapeople.org/groups/katello/fakerepos/zoo/'); |
| 121 | + await page.getByRole('button', { name: 'Save', exact: true }).click(); |
| 122 | + await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 }); |
103 | 123 | });
|
| 124 | + |
| 125 | + // Edit the repository and create snapshots |
| 126 | + const row = await getRowByNameOrUrl(page, repoName); |
| 127 | + await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 }); |
| 128 | + for (let i = 2; i <= 4; i++) { |
| 129 | + await test.step(`Edit repository and create snapshot ${i}`, async () => { |
| 130 | + // Open the edit modal |
| 131 | + await row.getByLabel('Kebab toggle').click(); |
| 132 | + await row.getByRole('menuitem', { name: 'Edit' }).click(); |
| 133 | + await page |
| 134 | + .getByLabel('URL') |
| 135 | + .fill(`https://fedorapeople.org/groups/katello/fakerepos/zoo/${i}/`); |
| 136 | + await page.getByRole('button', { name: 'Save changes', exact: true }).click(); |
| 137 | + await expect(row.getByText('Valid')).toBeVisible({ timeout: 60000 }); |
| 138 | + |
| 139 | + // Verify the snapshot count for the repo. |
| 140 | + const snapshotCount = await row |
| 141 | + .getByTestId('snapshot_list_table') |
| 142 | + .textContent(); |
| 143 | + // Create a template which uses the repo and assert that is uses the latest snapshot |
| 144 | + await navigateToTemplates(page); |
| 145 | + await page.getByRole('button', { name: 'Add templates' }).first().click(); |
| 146 | + await expect(page.getByRole('dialog', { name: 'Add custom templates' })).toBeVisible(); |
| 147 | + await page.getByLabel('Name').fill(templateName); |
| 148 | + await page.getByLabel('Repository').click(); |
| 149 | + await page |
| 150 | + .getByRole('option', { name: repoName }) |
| 151 | + .locator('label') |
| 152 | + .click(); |
| 153 | + await page.getByRole('button', { name: 'Save', exact: true }).click(); |
| 154 | + await expect(page.getByText('Valid')).toBeVisible({ timeout: 60000 }); |
| 155 | + // Verify the template is created and uses the latest snapshot |
| 156 | + const templateRow = await getRowByNameOrUrl(page, templateName); |
| 157 | + await expect(templateRow.getByText('Valid')).toBeVisible({ timeout: 60000 }); |
| 158 | + const templateSnapshotCount = await templateRow |
| 159 | + .getByTestId('snapshot_list_table') |
| 160 | + .textContent(); |
| 161 | + // Assert that the template snapshot count matches the repo snapshot count |
| 162 | + // Test deletion of a single snapshot. |
| 163 | + // Test bulk deletion of multiple snapshots. |
104 | 164 | });
|
105 | 165 | });
|
0 commit comments