|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { configs, test } from '@utils/test/playwright'; |
| 3 | + |
| 4 | +configs({ directions: ['ltr'], modes: ['ionic-md'] }).forEach(({ config, screenshot, title }) => { |
| 5 | + test.describe(title('accordion: states'), () => { |
| 6 | + test('should render disabled state', async ({ page }) => { |
| 7 | + await page.setContent( |
| 8 | + ` |
| 9 | + <ion-accordion-group value="first"> |
| 10 | + <ion-accordion value="first" disabled="true"> |
| 11 | + <ion-item slot="header"> |
| 12 | + <ion-label>Accordion title</ion-label> |
| 13 | + </ion-item> |
| 14 | + <div slot="content">This is the body of the accordion.</div> |
| 15 | + </ion-accordion> |
| 16 | + <ion-accordion value="second"> |
| 17 | + <ion-item slot="header"> |
| 18 | + <ion-label>Accordion title</ion-label> |
| 19 | + </ion-item> |
| 20 | + <div slot="content">This is the body of the accordion.</div> |
| 21 | + </ion-accordion> |
| 22 | + <ion-accordion value="third"> |
| 23 | + <ion-item slot="header"> |
| 24 | + <ion-label>Accordion title</ion-label> |
| 25 | + </ion-item> |
| 26 | + <div slot="content">This is the body of the accordion.</div> |
| 27 | + </ion-accordion> |
| 28 | + </ion-accordion-group> |
| 29 | + `, |
| 30 | + config |
| 31 | + ); |
| 32 | + |
| 33 | + const accordion = page.locator('ion-accordion-group'); |
| 34 | + |
| 35 | + await expect(accordion).toHaveScreenshot(screenshot('accordion-states-disabled')); |
| 36 | + }); |
| 37 | + |
| 38 | + test('should render activated state', async ({ page }) => { |
| 39 | + await page.setContent( |
| 40 | + ` |
| 41 | + <ion-accordion-group value="first"> |
| 42 | + <ion-accordion value="first"> |
| 43 | + <ion-item slot="header" class="ion-activated"> |
| 44 | + <ion-label>Accordion title</ion-label> |
| 45 | + </ion-item> |
| 46 | + <div slot="content">This is the body of the accordion.</div> |
| 47 | + </ion-accordion> |
| 48 | + <ion-accordion value="second"> |
| 49 | + <ion-item slot="header"> |
| 50 | + <ion-label>Accordion title</ion-label> |
| 51 | + </ion-item> |
| 52 | + <div slot="content">This is the body of the accordion.</div> |
| 53 | + </ion-accordion> |
| 54 | + <ion-accordion value="third"> |
| 55 | + <ion-item slot="header"> |
| 56 | + <ion-label>Accordion title</ion-label> |
| 57 | + </ion-item> |
| 58 | + <div slot="content">This is the body of the accordion.</div> |
| 59 | + </ion-accordion> |
| 60 | + </ion-accordion-group> |
| 61 | + `, |
| 62 | + config |
| 63 | + ); |
| 64 | + |
| 65 | + const accordion = page.locator('ion-accordion-group'); |
| 66 | + |
| 67 | + await expect(accordion).toHaveScreenshot(screenshot('accordion-states-activated')); |
| 68 | + }); |
| 69 | + |
| 70 | + test('should render focused state', async ({ page }) => { |
| 71 | + await page.setContent( |
| 72 | + ` |
| 73 | + <ion-accordion-group value="first"> |
| 74 | + <ion-accordion value="first"> |
| 75 | + <ion-item slot="header" class="ion-focused"> |
| 76 | + <ion-label>Accordion title</ion-label> |
| 77 | + </ion-item> |
| 78 | + <div slot="content">This is the body of the accordion.</div> |
| 79 | + </ion-accordion> |
| 80 | + <ion-accordion value="second"> |
| 81 | + <ion-item slot="header"> |
| 82 | + <ion-label>Accordion title</ion-label> |
| 83 | + </ion-item> |
| 84 | + <div slot="content">This is the body of the accordion.</div> |
| 85 | + </ion-accordion> |
| 86 | + <ion-accordion value="third"> |
| 87 | + <ion-item slot="header"> |
| 88 | + <ion-label>Accordion title</ion-label> |
| 89 | + </ion-item> |
| 90 | + <div slot="content">This is the body of the accordion.</div> |
| 91 | + </ion-accordion> |
| 92 | + </ion-accordion-group> |
| 93 | + `, |
| 94 | + config |
| 95 | + ); |
| 96 | + |
| 97 | + const accordion = page.locator('ion-accordion-group'); |
| 98 | + |
| 99 | + await expect(accordion).toHaveScreenshot(screenshot('accordion-states-focused')); |
| 100 | + }); |
| 101 | + }); |
| 102 | +}); |
0 commit comments