Skip to content

Commit 07d3562

Browse files
committed
test(select): add checks for cancel text prop
1 parent e30f907 commit 07d3562

1 file changed

Lines changed: 86 additions & 0 deletions

File tree

core/src/components/select/test/custom/select.e2e.ts

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,5 +72,91 @@ configs({ directions: ['ltr'] }).forEach(({ title, screenshot, config }) => {
7272
const wrapper = page.locator('.wrapper');
7373
await expect(wrapper).toHaveScreenshot(screenshot(`select-custom-parts-diff`));
7474
});
75+
76+
test('should render custom cancel text when prop is provided with alert interface', async ({ page }) => {
77+
await page.setContent(
78+
`
79+
<ion-select label="Fruit" interface="alert" value="bananas" cancel-text="Close me">
80+
<ion-select-option value="apples">Apples</ion-select-option>
81+
<ion-select-option value="bananas">Bananas</ion-select-option>
82+
<ion-select-option value="oranges">Oranges</ion-select-option>
83+
</ion-select>
84+
`,
85+
config
86+
);
87+
88+
const select = page.locator('ion-select');
89+
const ionAlertDidPresent = await page.spyOnEvent('ionAlertDidPresent');
90+
91+
await select.click();
92+
await ionAlertDidPresent.next();
93+
94+
await page.waitForChanges();
95+
96+
const alert = page.locator('ion-alert');
97+
const cancelButton = alert.locator('.alert-button-role-cancel');
98+
99+
// Verify the cancel button text
100+
await expect(cancelButton).toHaveText('Close me');
101+
});
102+
103+
test('should render custom cancel text when prop is provided with action sheet interface', async ({ page }) => {
104+
await page.setContent(
105+
`
106+
<ion-select label="Fruit" interface="action-sheet" value="bananas" cancel-text="Close me">
107+
<ion-select-option value="apples">Apples</ion-select-option>
108+
<ion-select-option value="bananas">Bananas</ion-select-option>
109+
<ion-select-option value="oranges">Oranges</ion-select-option>
110+
</ion-select>
111+
`,
112+
config
113+
);
114+
115+
const select = page.locator('ion-select');
116+
const ionActionSheetDidPresent = await page.spyOnEvent('ionActionSheetDidPresent');
117+
118+
await select.click();
119+
await ionActionSheetDidPresent.next();
120+
121+
await page.waitForChanges();
122+
123+
const actionSheet = page.locator('ion-action-sheet');
124+
const cancelButton = actionSheet.locator('.action-sheet-cancel');
125+
126+
// Verify the cancel button text
127+
await expect(cancelButton).toHaveText('Close me');
128+
});
129+
130+
test('should render custom cancel text when prop is provided with modal interface', async ({ page }, testInfo) => {
131+
testInfo.annotations.push({
132+
type: 'issue',
133+
description: 'https://github.com/ionic-team/ionic-framework/issues/30295',
134+
});
135+
136+
await page.setContent(
137+
`
138+
<ion-select label="Fruit" interface="modal" value="bananas" cancel-text="Close me">
139+
<ion-select-option value="apples">Apples</ion-select-option>
140+
<ion-select-option value="bananas">Bananas</ion-select-option>
141+
<ion-select-option value="oranges">Oranges</ion-select-option>
142+
</ion-select>
143+
`,
144+
config
145+
);
146+
147+
const select = page.locator('ion-select');
148+
const ionModalDidPresent = await page.spyOnEvent('ionModalDidPresent');
149+
150+
await select.click();
151+
await ionModalDidPresent.next();
152+
153+
await page.waitForChanges();
154+
155+
const modal = page.locator('ion-modal');
156+
const cancelButton = modal.locator('ion-button');
157+
158+
// Verify the cancel button text
159+
await expect(cancelButton).toHaveText('Close me');
160+
});
75161
});
76162
});

0 commit comments

Comments
 (0)