|
1 | 1 | import { expect } from '@playwright/test';
|
2 | 2 | import { configs, test } from '@utils/test/playwright';
|
3 | 3 |
|
| 4 | +/** |
| 5 | + * This behavior does not vary across modes/directions |
| 6 | + */ |
4 | 7 | configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) => {
|
5 | 8 | test.describe(title('item-sliding: async'), () => {
|
6 | 9 | test.beforeEach(async ({ page }) => {
|
@@ -35,5 +38,83 @@ configs({ modes: ['ios'], directions: ['ltr'] }).forEach(({ title, config }) =>
|
35 | 38 |
|
36 | 39 | await expect(itemSlidingEl).toHaveClass(/item-sliding-active-slide/);
|
37 | 40 | });
|
| 41 | + |
| 42 | + test('should not throw errors when adding multiple items with side="end" using the Ionic CDN', async ({ page }, testInfo) => { |
| 43 | + testInfo.annotations.push({ |
| 44 | + type: 'issue', |
| 45 | + description: 'https://github.com/ionic-team/ionic-framework/issues/29499', |
| 46 | + }); |
| 47 | + |
| 48 | + const errors: string[] = []; |
| 49 | + page.on('console', msg => { |
| 50 | + if (msg.type() === 'error') { |
| 51 | + errors.push(msg.text()); |
| 52 | + } |
| 53 | + }); |
| 54 | + page.on('pageerror', error => { |
| 55 | + errors.push(error.message); |
| 56 | + }); |
| 57 | + |
| 58 | + // This issue only happens when using a CDN version of Ionic |
| 59 | + // so we need to use the CDN by passing the `importIonicFromCDN` option |
| 60 | + // to setContent. |
| 61 | + await page.setContent(` |
| 62 | + <ion-header> |
| 63 | + <ion-toolbar> |
| 64 | + <ion-title>Item Sliding</ion-title> |
| 65 | + <ion-buttons slot="end"> |
| 66 | + <ion-button id="addItem" onclick="addItem()">ADD ITEM</ion-button> |
| 67 | + </ion-buttons> |
| 68 | + </ion-toolbar> |
| 69 | + </ion-header> |
| 70 | + <ion-content> |
| 71 | + <ion-list id="list"></ion-list> |
| 72 | + </ion-content> |
| 73 | +
|
| 74 | + <script> |
| 75 | + let itemList = []; |
| 76 | + function generateItem() { |
| 77 | + const currentItem = itemList.length + 1; |
| 78 | + const item = \` |
| 79 | + <ion-item-sliding id="item-\${currentItem}"> |
| 80 | + <ion-item> |
| 81 | + <ion-label>Sliding Item \${currentItem}</ion-label> |
| 82 | + </ion-item> |
| 83 | + <ion-item-options side="end"> |
| 84 | + <ion-item-option color="danger" id="delete-item-\${currentItem}">Delete</ion-item-option> |
| 85 | + </ion-item-options> |
| 86 | + </ion-item-sliding> |
| 87 | + \`; |
| 88 | + itemList.push(item); |
| 89 | + return item; |
| 90 | + } |
| 91 | + function addItem() { |
| 92 | + const list = document.getElementById('list'); |
| 93 | + list.innerHTML += generateItem(); |
| 94 | + const currentItem = itemList.length; |
| 95 | + const deleteId = \`#delete-item-\${currentItem}\`; |
| 96 | + const itemId = \`#item-\${currentItem}\`; |
| 97 | + document.querySelector(deleteId).addEventListener('click', (ev) => { |
| 98 | + document.querySelector(itemId).remove(); |
| 99 | + }); |
| 100 | + } |
| 101 | + </script> |
| 102 | + `, { ...config, importIonicFromCDN: true }); |
| 103 | + |
| 104 | + // Click the button enough times to reproduce the issue |
| 105 | + const addButton = page.locator('#addItem'); |
| 106 | + await addButton.click(); |
| 107 | + await addButton.click(); |
| 108 | + await addButton.click(); |
| 109 | + |
| 110 | + await page.waitForChanges(); |
| 111 | + |
| 112 | + // Check that the items have been added |
| 113 | + const items = page.locator('ion-item-sliding'); |
| 114 | + expect(await items.count()).toBe(3); |
| 115 | + |
| 116 | + // Check that no errors have been logged |
| 117 | + expect(errors.length).toBe(0); |
| 118 | + }); |
38 | 119 | });
|
39 | 120 | });
|
0 commit comments