|
| 1 | +import { test, expect } from '@playwright/test' |
| 2 | +import { randomUUID } from 'crypto' |
| 3 | +import { login } from '../helper/auth' |
| 4 | +import { navigateTo } from '../helper/menu' |
| 5 | +import { Dropdown } from '../helper/dropdown' |
| 6 | + |
| 7 | +test('Boosts', async ({ page }) => { |
| 8 | + await login(page) |
| 9 | + await navigateTo(page, 'Boosts', '/fr/admin/merchandize/boost/grid') |
| 10 | + |
| 11 | + const createButton = await page.getByTestId('createButtonResourceGrid') |
| 12 | + |
| 13 | + /* |
| 14 | + Grid Boost |
| 15 | + */ |
| 16 | + // TO DO |
| 17 | + |
| 18 | + /* |
| 19 | + Create Boost |
| 20 | + */ |
| 21 | + await createButton.click() |
| 22 | + await expect(page).toHaveURL('/fr/admin/merchandize/boost/create') |
| 23 | + |
| 24 | + // isActive Switch |
| 25 | + const isActiveInput = await page.getByTestId('isActive') |
| 26 | + const isActiveCheckbox = await isActiveInput.locator("input[type='checkbox']") |
| 27 | + |
| 28 | + await expect(isActiveCheckbox).toBeChecked() |
| 29 | + await isActiveInput.click() |
| 30 | + await expect(isActiveCheckbox).not.toBeChecked() |
| 31 | + await isActiveInput.click() |
| 32 | + await expect(isActiveCheckbox).toBeChecked() |
| 33 | + |
| 34 | + // Boost Preview |
| 35 | + const previewFieldSet = await page.getByTestId('previewFieldSet') |
| 36 | + await expect( |
| 37 | + await previewFieldSet.getByTestId('previewRequiredMessage') |
| 38 | + ).toBeVisible() |
| 39 | + |
| 40 | + // name InputText |
| 41 | + const nameInput = await page.getByTestId('name') |
| 42 | + const newName = randomUUID() |
| 43 | + |
| 44 | + await expect(nameInput).toBeEmpty() |
| 45 | + await nameInput.fill(newName) |
| 46 | + await expect(nameInput).toHaveValue(newName) |
| 47 | + |
| 48 | + // // Localized Catalogs Multiple Dropdown |
| 49 | + const localizedCatalogs = new Dropdown(page, 'localizedCatalogs', true) |
| 50 | + await localizedCatalogs.selectValue([ |
| 51 | + 'COM French Catalog', |
| 52 | + 'COM English Catalog', |
| 53 | + 'FR French Catalog', |
| 54 | + 'EN French Catalog', |
| 55 | + ]) |
| 56 | + |
| 57 | + // Request types Multiple Dropdown |
| 58 | + const requestTypesDropdown = new Dropdown(page, 'requestTypesDropdown', true) |
| 59 | + await requestTypesDropdown.selectValue(['Category listing', 'Search result']) |
| 60 | + |
| 61 | + // Model Dropdown |
| 62 | + const modelDropdown = new Dropdown(page, 'model') |
| 63 | + await modelDropdown.selectValue('Constante') |
| 64 | + |
| 65 | + // Preview Boost Required Message |
| 66 | + await expect( |
| 67 | + await previewFieldSet.getByTestId('previewRequiredMessage') |
| 68 | + ).not.toBeVisible() |
| 69 | + |
| 70 | + // Create the Boost and verify his existence |
| 71 | + const saveButton = await page.getByTestId('submitButtonResourceForm') |
| 72 | + await saveButton.click() |
| 73 | + await expect(page).toHaveURL('/fr/admin/merchandize/boost/grid') |
| 74 | + await expect(await page.getByText(newName)).toBeDefined() // TO DO : Manipulate the grid instead of research in the page. |
| 75 | + |
| 76 | + /* |
| 77 | + Edit Boost |
| 78 | + */ |
| 79 | + // TO DO |
| 80 | + |
| 81 | + /* |
| 82 | + Delete Boost |
| 83 | + */ |
| 84 | + // TO DO |
| 85 | +}) |
0 commit comments