|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { addComponentsToCanvas } from '../helpers'; |
| 3 | + |
| 4 | +test('should delete one of the created thumb pages and just 2 thumb pages should remain', async ({ |
| 5 | + page, |
| 6 | +}) => { |
| 7 | + await page.goto(''); |
| 8 | + |
| 9 | + // Add a browser component to first page |
| 10 | + await page.getByText('Devices').click(); |
| 11 | + |
| 12 | + await addComponentsToCanvas(page, ['Browser']); |
| 13 | + |
| 14 | + // Add a second page |
| 15 | + await page.getByText('Pages').click(); |
| 16 | + const addButton = page.getByRole('button', { name: 'add new page' }); |
| 17 | + await addButton.click(); |
| 18 | + |
| 19 | + // Add mobile phone component to second page |
| 20 | + |
| 21 | + await page.getByText('Devices').click(); |
| 22 | + |
| 23 | + await addComponentsToCanvas(page, ['Mobile Phone']); |
| 24 | + |
| 25 | + // Add a third page |
| 26 | + |
| 27 | + await page.getByText('Pages').click(); |
| 28 | + |
| 29 | + await addButton.click(); |
| 30 | + |
| 31 | + // Add a tablet component to third page |
| 32 | + |
| 33 | + await page.getByText('Devices').click(); |
| 34 | + |
| 35 | + await addComponentsToCanvas(page, ['Tablet']); |
| 36 | + |
| 37 | + // Delete page 2 |
| 38 | + await page.getByText('Pages').click(); |
| 39 | + |
| 40 | + const pageTwo = page.getByText('Page 2', { exact: true }); |
| 41 | + const thumbTwoDiv = pageTwo.locator('..'); |
| 42 | + await thumbTwoDiv.click({ button: 'right' }); |
| 43 | + |
| 44 | + const deleteButton = page.locator('div').filter({ hasText: /^Delete$/ }); |
| 45 | + |
| 46 | + await deleteButton.click(); |
| 47 | + |
| 48 | + // Verify page 2 does not exist |
| 49 | + |
| 50 | + expect(pageTwo).not.toBeVisible(); |
| 51 | + |
| 52 | + // Verify page 1 and 3 exist |
| 53 | + |
| 54 | + const pageOne = page.getByText('Page 1', { exact: true }); |
| 55 | + |
| 56 | + const pageThree = page.getByText('Page 3', { exact: true }); |
| 57 | + |
| 58 | + await expect(pageOne).toBeVisible(); |
| 59 | + await expect(pageThree).toBeVisible(); |
| 60 | + |
| 61 | + // Verify total pages |
| 62 | + |
| 63 | + const allPages = page.getByText(/^Page \d+$/); |
| 64 | + await expect(allPages).toHaveCount(2); |
| 65 | +}); |
0 commit comments