|
| 1 | +import { expect } from '@playwright/test'; |
| 2 | +import { test } from '@utils/test/playwright'; |
| 3 | + |
| 4 | +test.describe('input: color', () => { |
| 5 | + test.beforeEach(({ skip }) => { |
| 6 | + skip.rtl(); |
| 7 | + skip.mode( |
| 8 | + 'ios', |
| 9 | + 'iOS does not have any color theming besides the caret which cannot be captured in a stable manner in screenshots.' |
| 10 | + ); |
| 11 | + }); |
| 12 | + |
| 13 | + /** |
| 14 | + * Manually setting the .has-focus class |
| 15 | + * lets us quickly test the rendering of a |
| 16 | + * focused input without need to wait for |
| 17 | + * focus events. |
| 18 | + */ |
| 19 | + test.describe('input: fill none', () => { |
| 20 | + test('should set label and highlight color on focus with start label placement', async ({ page }) => { |
| 21 | + await page.setContent(` |
| 22 | + <ion-input class="has-focus" color="danger" label="Email" label-placement="start" value="[email protected]"></ion-input> |
| 23 | + `); |
| 24 | + |
| 25 | + const input = page.locator('ion-input'); |
| 26 | + expect(await input.screenshot()).toMatchSnapshot(`input-no-fill-color-start-${page.getSnapshotSettings()}.png`); |
| 27 | + }); |
| 28 | + test('should set label and highlight color on focus with end label placement', async ({ page }) => { |
| 29 | + await page.setContent(` |
| 30 | + <ion-input class="has-focus" color="danger" label="Email" label-placement="end" value="[email protected]"></ion-input> |
| 31 | + `); |
| 32 | + |
| 33 | + const input = page.locator('ion-input'); |
| 34 | + expect(await input.screenshot()).toMatchSnapshot(`input-no-fill-color-end-${page.getSnapshotSettings()}.png`); |
| 35 | + }); |
| 36 | + test('should set label and highlight color on focus with fixed label placement', async ({ page }) => { |
| 37 | + await page.setContent(` |
| 38 | + <ion-input class="has-focus" color="danger" label="Email" label-placement="fixed" value="[email protected]"></ion-input> |
| 39 | + `); |
| 40 | + |
| 41 | + const input = page.locator('ion-input'); |
| 42 | + expect(await input.screenshot()).toMatchSnapshot(`input-no-fill-color-fixed-${page.getSnapshotSettings()}.png`); |
| 43 | + }); |
| 44 | + test('should set label and highlight color on focus with floating label placement', async ({ page }) => { |
| 45 | + await page.setContent(` |
| 46 | + <ion-input class="has-focus" color="danger" label="Email" label-placement="floating" value="[email protected]"></ion-input> |
| 47 | + `); |
| 48 | + |
| 49 | + const input = page.locator('ion-input'); |
| 50 | + expect(await input.screenshot()).toMatchSnapshot( |
| 51 | + `input-no-fill-color-floating-${page.getSnapshotSettings()}.png` |
| 52 | + ); |
| 53 | + }); |
| 54 | + test('should set label and highlight color on focus with stacked label placement', async ({ page }) => { |
| 55 | + await page.setContent(` |
| 56 | + <ion-input class="has-focus" color="danger" label="Email" label-placement="stacked" value="[email protected]"></ion-input> |
| 57 | + `); |
| 58 | + |
| 59 | + const input = page.locator('ion-input'); |
| 60 | + expect(await input.screenshot()).toMatchSnapshot(`input-no-fill-color-stacked-${page.getSnapshotSettings()}.png`); |
| 61 | + }); |
| 62 | + }); |
| 63 | + test.describe('input: fill solid', () => { |
| 64 | + test('should set label and highlight color on focus with start label placement', async ({ page }) => { |
| 65 | + await page.setContent(` |
| 66 | + <ion-input fill="solid" class="has-focus" color="danger" label="Email" label-placement="start" value="[email protected]"></ion-input> |
| 67 | + `); |
| 68 | + |
| 69 | + const input = page.locator('ion-input'); |
| 70 | + expect(await input.screenshot()).toMatchSnapshot(`input-solid-color-start-${page.getSnapshotSettings()}.png`); |
| 71 | + }); |
| 72 | + test('should set label and highlight color on focus with end label placement', async ({ page }) => { |
| 73 | + await page.setContent(` |
| 74 | + <ion-input fill="solid" class="has-focus" color="danger" label="Email" label-placement="end" value="[email protected]"></ion-input> |
| 75 | + `); |
| 76 | + |
| 77 | + const input = page.locator('ion-input'); |
| 78 | + expect(await input.screenshot()).toMatchSnapshot(`input-solid-color-end-${page.getSnapshotSettings()}.png`); |
| 79 | + }); |
| 80 | + test('should set label and highlight color on focus with fixed label placement', async ({ page }) => { |
| 81 | + await page.setContent(` |
| 82 | + <ion-input fill="solid" class="has-focus" color="danger" label="Email" label-placement="fixed" value="[email protected]"></ion-input> |
| 83 | + `); |
| 84 | + |
| 85 | + const input = page.locator('ion-input'); |
| 86 | + expect(await input.screenshot()).toMatchSnapshot(`input-solid-color-fixed-${page.getSnapshotSettings()}.png`); |
| 87 | + }); |
| 88 | + test('should set label and highlight color on focus with floating label placement', async ({ page }) => { |
| 89 | + await page.setContent(` |
| 90 | + <ion-input fill="solid" class="has-focus" color="danger" label="Email" label-placement="floating" value="[email protected]"></ion-input> |
| 91 | + `); |
| 92 | + |
| 93 | + const input = page.locator('ion-input'); |
| 94 | + expect(await input.screenshot()).toMatchSnapshot(`input-solid-color-floating-${page.getSnapshotSettings()}.png`); |
| 95 | + }); |
| 96 | + test('should set label and highlight color on focus with stacked label placement', async ({ page }) => { |
| 97 | + await page.setContent(` |
| 98 | + <ion-input fill="solid" class="has-focus" color="danger" label="Email" label-placement="stacked" value="[email protected]"></ion-input> |
| 99 | + `); |
| 100 | + |
| 101 | + const input = page.locator('ion-input'); |
| 102 | + expect(await input.screenshot()).toMatchSnapshot(`input-solid-color-stacked-${page.getSnapshotSettings()}.png`); |
| 103 | + }); |
| 104 | + }); |
| 105 | + test.describe('input: fill outline', () => { |
| 106 | + test('should set label and highlight color on focus with start label placement', async ({ page }) => { |
| 107 | + await page.setContent(` |
| 108 | + <ion-input fill="outline" class="has-focus" color="danger" label="Email" label-placement="start" value="[email protected]"></ion-input> |
| 109 | + `); |
| 110 | + |
| 111 | + const input = page.locator('ion-input'); |
| 112 | + expect(await input.screenshot()).toMatchSnapshot(`input-outline-color-start-${page.getSnapshotSettings()}.png`); |
| 113 | + }); |
| 114 | + test('should set label and highlight color on focus with end label placement', async ({ page }) => { |
| 115 | + await page.setContent(` |
| 116 | + <ion-input fill="outline" class="has-focus" color="danger" label="Email" label-placement="end" value="[email protected]"></ion-input> |
| 117 | + `); |
| 118 | + |
| 119 | + const input = page.locator('ion-input'); |
| 120 | + expect(await input.screenshot()).toMatchSnapshot(`input-outline-color-end-${page.getSnapshotSettings()}.png`); |
| 121 | + }); |
| 122 | + test('should set label and highlight color on focus with fixed label placement', async ({ page }) => { |
| 123 | + await page.setContent(` |
| 124 | + <ion-input fill="outline" class="has-focus" color="danger" label="Email" label-placement="fixed" value="[email protected]"></ion-input> |
| 125 | + `); |
| 126 | + |
| 127 | + const input = page.locator('ion-input'); |
| 128 | + expect(await input.screenshot()).toMatchSnapshot(`input-outline-color-fixed-${page.getSnapshotSettings()}.png`); |
| 129 | + }); |
| 130 | + test('should set label and highlight color on focus with floating label placement', async ({ page }) => { |
| 131 | + await page.setContent(` |
| 132 | + <ion-input fill="outline" class="has-focus" color="danger" label="Email" label-placement="floating" value="[email protected]"></ion-input> |
| 133 | + `); |
| 134 | + |
| 135 | + const input = page.locator('ion-input'); |
| 136 | + expect(await input.screenshot()).toMatchSnapshot( |
| 137 | + `input-outline-color-floating-${page.getSnapshotSettings()}.png` |
| 138 | + ); |
| 139 | + }); |
| 140 | + test('should set label and highlight color on focus with stacked label placement', async ({ page }) => { |
| 141 | + await page.setContent(` |
| 142 | + <ion-input fill="outline" class="has-focus" color="danger" label="Email" label-placement="stacked" value="[email protected]"></ion-input> |
| 143 | + `); |
| 144 | + |
| 145 | + const input = page.locator('ion-input'); |
| 146 | + expect(await input.screenshot()).toMatchSnapshot(`input-outline-color-stacked-${page.getSnapshotSettings()}.png`); |
| 147 | + }); |
| 148 | + }); |
| 149 | +}); |
0 commit comments