|
| 1 | +import { expect, test } from '@playwright/test'; |
| 2 | + |
| 3 | +import { createApplication, deleteApplication, generateSalt } from './helpers'; |
| 4 | + |
| 5 | +test.describe('Application Item Style', () => { |
| 6 | + let appName: string; |
| 7 | + let appId: string; |
| 8 | + |
| 9 | + test.beforeEach(async ({ page }, testInfo): Promise<void> => { |
| 10 | + const appNameSalt = generateSalt(testInfo.title); |
| 11 | + appName = 'Sty'; |
| 12 | + appId = 'io.test.style.app.' + appNameSalt; |
| 13 | + |
| 14 | + await page.goto('/'); |
| 15 | + }); |
| 16 | + |
| 17 | + test.afterEach(async ({ page }) => { |
| 18 | + await deleteApplication(page, appName); |
| 19 | + |
| 20 | + await expect(page.getByRole('list')).not.toContainText(appName); |
| 21 | + await expect(page.getByRole('list')).not.toContainText(appId); |
| 22 | + }); |
| 23 | + |
| 24 | + test('should display application item with correct width styling', async ({ page }) => { |
| 25 | + await createApplication(page, appName, appId); |
| 26 | + |
| 27 | + await expect(page.getByRole('list')).toContainText(appName); |
| 28 | + await expect(page.getByRole('list')).toContainText(appId); |
| 29 | + |
| 30 | + const appItem = page.locator('li').filter({ hasText: appName }); |
| 31 | + |
| 32 | + await appItem.scrollIntoViewIfNeeded(); |
| 33 | + |
| 34 | + await page.evaluate(() => { |
| 35 | + const items = Array.from(document.querySelectorAll('li')); |
| 36 | + const targetItem = items.find(li => li.textContent?.includes('Test style app')); |
| 37 | + |
| 38 | + if (targetItem) { |
| 39 | + const rect = targetItem.getBoundingClientRect(); |
| 40 | + const scrollTop = window.pageYOffset + rect.top - 100; |
| 41 | + window.scrollTo(0, scrollTop); |
| 42 | + } |
| 43 | + }); |
| 44 | + |
| 45 | + await page.waitForTimeout(500); |
| 46 | + |
| 47 | + await expect(appItem).toHaveScreenshot('application-item-style.png', { |
| 48 | + clip: { |
| 49 | + x: 0, |
| 50 | + y: -10, |
| 51 | + width: await appItem.boundingBox().then(box => box?.width || 800), |
| 52 | + height: await appItem.boundingBox().then(box => (box?.height || 200) + 20), |
| 53 | + }, |
| 54 | + }); |
| 55 | + }); |
| 56 | +}); |
0 commit comments