From 014b3b88259a28d8884e7ea22c2c41766ff0ff55 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Mon, 15 Aug 2022 17:42:02 +0000 Subject: [PATCH 1/4] test(select): add failing test --- .../select/test/compare-with/select.e2e.ts | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/core/src/components/select/test/compare-with/select.e2e.ts b/core/src/components/select/test/compare-with/select.e2e.ts index 09534ca8d15..0a2918b0977 100644 --- a/core/src/components/select/test/compare-with/select.e2e.ts +++ b/core/src/components/select/test/compare-with/select.e2e.ts @@ -21,4 +21,52 @@ test.describe('select: compare-with', () => { value: '1', }); }); + + test('should pass compareWith params in the correct order', async ({ page }, testInfo) => { + test.skip(testInfo.project.metadata.rtl === true, 'This does not check LTR vs RTL layouts'); + test.skip(testInfo.project.metadata.mode === 'md', 'This logic is the same across modes'); + test.info().annotations.push({ + type: 'issue', + description: 'https://github.com/ionic-team/ionic-framework/issues/25759', + }); + + await page.setContent(` + + + + `); + const ionAlertDidPresent = await page.spyOnEvent('ionAlertDidPresent'); + + const select = page.locator('ion-select'); + const selectLabel = select.locator('[part="text"]'); + + await expect(selectLabel).toHaveText('Option #3'); + + await select.click(); + await ionAlertDidPresent.next(); + + const selectRadios = page.locator('ion-alert button.alert-radio'); + await expect(selectRadios.nth(0)).toHaveAttribute('aria-checked', 'false'); + await expect(selectRadios.nth(1)).toHaveAttribute('aria-checked', 'false'); + await expect(selectRadios.nth(2)).toHaveAttribute('aria-checked', 'true'); + }); }); From 4e6a9937969338845e59d8602b9d9e3cdab85646 Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 16 Aug 2022 15:51:45 +0000 Subject: [PATCH 2/4] fix(select): compareWith passes params in correct order --- core/src/components/select/select.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/select/select.tsx b/core/src/components/select/select.tsx index 54906739099..f727994a9ba 100644 --- a/core/src/components/select/select.tsx +++ b/core/src/components/select/select.tsx @@ -686,7 +686,7 @@ const textForValue = ( compareWith?: string | SelectCompareFn | null ): string | null => { const selectOpt = opts.find((opt) => { - return compareOptions(getOptionValue(opt), value, compareWith); + return compareOptions(value, getOptionValue(opt), compareWith); }); return selectOpt ? selectOpt.textContent : null; }; From 418713e312cd5e2267768da021618dcf3feb019a Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 16 Aug 2022 19:52:20 +0000 Subject: [PATCH 3/4] chore(): fix test case --- core/src/components/select/test/compare-with/select.e2e.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/components/select/test/compare-with/select.e2e.ts b/core/src/components/select/test/compare-with/select.e2e.ts index 0a2918b0977..db44953fbaa 100644 --- a/core/src/components/select/test/compare-with/select.e2e.ts +++ b/core/src/components/select/test/compare-with/select.e2e.ts @@ -41,8 +41,8 @@ test.describe('select: compare-with', () => { ] const select = document.querySelector('ion-select'); select.compareWith = (val1, val2) => { - // convert val2 to a number - return val1 === +val2; + // convert val1 to a number + return +val1 === val2; } data.forEach((d) => { From caa25275fafbdd507a081e87616a577423fa1a5d Mon Sep 17 00:00:00 2001 From: Liam DeBeasi Date: Tue, 16 Aug 2022 16:22:12 -0400 Subject: [PATCH 4/4] Update select.e2e.ts --- core/src/components/select/test/compare-with/select.e2e.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/components/select/test/compare-with/select.e2e.ts b/core/src/components/select/test/compare-with/select.e2e.ts index 740e678200c..f18f0dad746 100644 --- a/core/src/components/select/test/compare-with/select.e2e.ts +++ b/core/src/components/select/test/compare-with/select.e2e.ts @@ -22,7 +22,7 @@ test.describe('select: compare-with', () => { }); }); - test('should pass compareWith params in the correct order', async ({ page }, testInfo) => { + test('should work with different parameter types', async ({ page }, testInfo) => { test.skip(testInfo.project.metadata.rtl === true, 'This does not check LTR vs RTL layouts'); test.skip(testInfo.project.metadata.mode === 'md', 'This logic is the same across modes'); test.info().annotations.push({