|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { navigateToRepositories, navigateToTemplates } from './helpers/navHelpers'; |
| 3 | +import { closePopupsIfExist, getRowByNameOrUrl } from './helpers/helpers'; |
| 4 | +import { deleteAllTemplates } from './helpers/deleteTemplates'; |
| 5 | +import { deleteAllRepos } from './helpers/deleteRepositories'; |
| 6 | +import { createCustomRepo } from './helpers/createRepositories'; |
| 7 | + |
| 8 | +import { randomName } from './helpers/repoHelpers'; |
| 9 | + |
| 10 | +const templateNamePrefix = 'template_CRUD'; |
| 11 | +const repoNamePrefix = 'custom_repo-template'; |
| 12 | + |
| 13 | +const repoName = `${repoNamePrefix}-${randomName()}`; |
| 14 | +const templateName = `${templateNamePrefix}-${randomName()}`; |
| 15 | + |
| 16 | +const smallRHRepo = 'Red Hat CodeReady Linux Builder for RHEL 9 ARM 64 (RPMs)'; |
| 17 | + |
| 18 | +test.describe('Templates CRUD', () => { |
| 19 | + test('Add, Read, update, delete a template', async ({ page }) => { |
| 20 | + await test.step('Delete any templates and template test repos that exist', async () => { |
| 21 | + await deleteAllRepos(page, `&search=${repoNamePrefix}`); |
| 22 | + await deleteAllTemplates(page, `&search=${templateNamePrefix}`); |
| 23 | + await navigateToRepositories(page); |
| 24 | + await closePopupsIfExist(page); |
| 25 | + }); |
| 26 | + await test.step('Create a repository', async () => { |
| 27 | + await createCustomRepo(page, repoName); |
| 28 | + const row = await getRowByNameOrUrl(page, repoName); |
| 29 | + await expect(row.getByText('Valid')).toBeVisible(); |
| 30 | + }); |
| 31 | + await test.step('Navigate to templates, ensure the Add content template button can be clicked', async () => { |
| 32 | + await navigateToTemplates(page); |
| 33 | + await expect(page.getByRole('button', { name: 'Add content template' })).toBeVisible(); |
| 34 | + }); |
| 35 | + await test.step('Create a template', async () => { |
| 36 | + await page.getByRole('button', { name: 'Add content template' }).click(); |
| 37 | + await page.getByRole('button', { name: 'Select architecture' }).click(); |
| 38 | + await page.getByRole('option', { name: 'aarch64' }).click(); |
| 39 | + await page.getByRole('button', { name: 'Select version' }).click(); |
| 40 | + await page.getByRole('option', { name: 'el9' }).click(); |
| 41 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 42 | + const modalPage = page.getByTestId('add_template_modal'); |
| 43 | + const rowRHELRepo = await getRowByNameOrUrl(modalPage, smallRHRepo); |
| 44 | + await rowRHELRepo.getByLabel('Select row 0', { exact: true }).click(); |
| 45 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 46 | + await modalPage.getByRole('textbox', { name: 'Filter by name/url' }).fill(repoName); |
| 47 | + const rowRepo = await getRowByNameOrUrl(modalPage, repoName); |
| 48 | + await rowRepo.getByLabel('Select row 0', { exact: true }).click(); |
| 49 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 50 | + await page.getByText('Use latest content', { exact: true }).click(); |
| 51 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 52 | + await page.getByText('add template modal', { exact: true }); |
| 53 | + await page.getByPlaceholder('Enter name').fill(`${templateName}`); |
| 54 | + await page.getByPlaceholder('Description').fill('Template test'); |
| 55 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 56 | + await page.getByRole('button', { name: 'Create other options' }).click(); |
| 57 | + await page.getByText('Create template only', { exact: true }).click(); |
| 58 | + }); |
| 59 | + await test.step('Read and update values in the template', async () => { |
| 60 | + const rowTemplate = await getRowByNameOrUrl(page, templateName); |
| 61 | + await rowTemplate.getByRole('button', { name: templateName }).click(); |
| 62 | + await expect(page.getByLabel('Breadcrumb').first()).toHaveText('RHELContentTemplates'); |
| 63 | + await expect(page.getByRole('heading', { level: 1 })).toHaveText(templateName); |
| 64 | + await expect(page.getByText('Description:Template test')).toBeVisible(); |
| 65 | + await page.getByRole('button', { name: 'Actions' }).click(); |
| 66 | + await page.getByRole('menuitem', { name: 'Edit' }).click(); |
| 67 | + await expect( |
| 68 | + page.getByRole('heading', { name: 'Define template content', exact: true }), |
| 69 | + ).toBeVisible(); |
| 70 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 71 | + await expect( |
| 72 | + page.getByRole('heading', { name: 'Additional Red Hat repositories', exact: true }), |
| 73 | + ).toBeVisible(); |
| 74 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 75 | + await expect( |
| 76 | + page.getByRole('heading', { name: 'Custom repositories', exact: true }), |
| 77 | + ).toBeVisible(); |
| 78 | + await expect(page.getByText(`${repoName}`)).toBeVisible(); |
| 79 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 80 | + await expect(page.getByRole('heading', { name: 'Set up date', exact: true })).toBeVisible(); |
| 81 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 82 | + await expect(page.getByText('Enter template details')).toBeVisible(); |
| 83 | + await expect(page.getByPlaceholder('Enter name')).toHaveValue(`${templateName}`); |
| 84 | + await expect(page.getByPlaceholder('Description')).toHaveValue('Template test'); |
| 85 | + await page.getByPlaceholder('Enter name').fill(`${templateName}-edited`); |
| 86 | + await page.getByPlaceholder('Description').fill('Template test edited'); |
| 87 | + await page.getByRole('button', { name: 'Next', exact: true }).click(); |
| 88 | + await page.getByRole('button', { name: 'Confirm changes', exact: true }).click(); |
| 89 | + }); |
| 90 | + await test.step('Delete the template', async () => { |
| 91 | + const rowTemplate = await getRowByNameOrUrl(page, `${templateName}-edited`); |
| 92 | + await expect(rowTemplate.getByText('Valid')).toBeVisible({ timeout: 60000 }); |
| 93 | + await rowTemplate.getByLabel('Kebab toggle').click(); |
| 94 | + await rowTemplate.getByRole('menuitem', { name: 'Delete' }).click(); |
| 95 | + await expect(page.getByText('Remove template?')).toBeVisible(); |
| 96 | + await page.getByRole('button', { name: 'Remove' }).click(); |
| 97 | + await expect(rowTemplate.getByText('Valid')).not.toBeVisible(); |
| 98 | + await deleteAllTemplates(page, `&search=${templateNamePrefix}`); |
| 99 | + }); |
| 100 | + }); |
| 101 | +}); |
0 commit comments