Skip to content

Commit 4dc9007

Browse files
committed
fix: liveness demo handling
1 parent 7811d85 commit 4dc9007

File tree

4 files changed

+46
-40
lines changed

4 files changed

+46
-40
lines changed

examples/next/pages/ui/components/in-app-messaging/demo/index.page.tsx

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,10 @@ import React, { useState } from 'react';
22
import { Amplify } from 'aws-amplify';
33
import { initializeInAppMessaging } from 'aws-amplify/in-app-messaging';
44
import {
5-
Button,
6-
CheckboxField,
75
ColorMode,
86
defaultDarkModeOverride,
97
Divider,
108
Heading,
11-
Radio,
12-
RadioGroupField,
139
ThemeProvider,
1410
useTheme,
1511
View,
@@ -27,15 +23,18 @@ initializeInAppMessaging();
2723

2824
function DemoCheckbox({ label, onChange, ...rest }) {
2925
return (
30-
<CheckboxField
31-
{...rest}
32-
label={label}
33-
name={label}
34-
onChange={() => {
35-
onChange((prev) => !prev);
36-
}}
37-
value=""
38-
/>
26+
<label>
27+
<input
28+
disabled={rest.isDisabled}
29+
name={label}
30+
type="checkbox"
31+
checked={rest.checked}
32+
onChange={() => {
33+
onChange((prev) => !prev);
34+
}}
35+
/>
36+
{label}
37+
</label>
3938
);
4039
}
4140

@@ -47,20 +46,24 @@ function DemoDivider() {
4746

4847
function DemoRadioGroup({ data, legend, onChange, ...rest }) {
4948
return (
50-
<RadioGroupField
51-
{...rest}
52-
legend={legend}
53-
name={legend}
54-
onChange={(e) => {
55-
onChange(e.target.value);
56-
}}
57-
>
49+
<fieldset>
50+
<legend>{legend}</legend>
5851
{data.map((item) => (
59-
<Radio key={`${legend}:${item}`} value={item}>
52+
<label key={`${legend}:${item}`} style={{ display: 'block' }}>
53+
<input
54+
onChange={(e) => {
55+
onChange(e.target.value);
56+
}}
57+
disabled={rest.isDisabled}
58+
checked={rest.value === item}
59+
type="radio"
60+
name={legend}
61+
value={item}
62+
/>{' '}
6063
{item}
61-
</Radio>
64+
</label>
6265
))}
63-
</RadioGroupField>
66+
</fieldset>
6467
);
6568
}
6669

@@ -186,16 +189,14 @@ function Content({ colorMode, setColorMode }) {
186189
<DemoDivider />
187190
</View>
188191
</div>
189-
<Button margin="medium" onClick={displayDemoMessage}>
190-
Display Demo Message
191-
</Button>
192+
<button onClick={displayDemoMessage}>Display Demo Message</button>
192193
</div>
193194
</View>
194195
);
195196
}
196197

197198
export default function App() {
198-
const [colorMode, setColorMode] = useState<ColorMode>('dark');
199+
const [colorMode, setColorMode] = useState<ColorMode>('light');
199200
return (
200201
<ThemeProvider
201202
colorMode={colorMode}

examples/next/pages/ui/components/in-app-messaging/demo/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useState, useEffect } from 'react';
1+
import { useEffect, useState } from 'react';
22
import * as Analytics from '@aws-amplify/analytics';
33
import { syncMessages } from 'aws-amplify/in-app-messaging';
44
import {

packages/e2e/cypress/integration/common/in-app-messaging.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ Then('I do not see the banner', () => {
99
});
1010

1111
Then('the banner has {int} buttons', (buttonCount: number) => {
12+
const context = cy.findAllByRole('dialog');
1213
if (buttonCount > 0) {
13-
cy.findByRole('group').children().should('have.length', buttonCount);
14+
context.findByRole('group').children().should('have.length', buttonCount);
1415
} else {
15-
cy.findByRole('group').should('not.exist');
16+
context.findByRole('group').should('not.exist');
1617
}
1718
});

packages/e2e/cypress/integration/ui/components/in-app-messaging/demo/demo.steps.ts

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,30 @@
11
import { Given, Then, When } from '@badeball/cypress-cucumber-preprocessor';
22

33
Given('{string} checkbox is checked', (checkboxName: string) => {
4-
cy.findByText(checkboxName)
5-
.next()
6-
.should('have.attr', 'data-checked', 'true');
4+
cy.findByRole('checkbox', { name: checkboxName }).should(
5+
'have.prop',
6+
'checked',
7+
true
8+
);
79
});
810
Given('{string} checkbox is unchecked', (checkboxName: string) => {
9-
cy.findByText(checkboxName)
10-
.next()
11-
.should('have.attr', 'data-checked', 'false');
11+
cy.findByRole('checkbox', { name: checkboxName }).should(
12+
'have.prop',
13+
'checked',
14+
false
15+
);
1216
});
1317

1418
Given('{string} layout radio option is selected', (radioOption: string) => {
15-
cy.findByText(radioOption).next().should('have.attr', 'checked');
19+
cy.findByRole('radio', { name: radioOption }).should('have.attr', 'checked');
1620
});
1721

1822
When('I click the {string} layout radio option', (radioOption: string) => {
19-
cy.findByText(radioOption, { timeout: 5000 }).click();
23+
cy.findByRole('radio', { name: radioOption, timeout: 5000 }).click();
2024
});
2125

2226
When('I toggle {string} checkbox', (checkboxName: string) => {
23-
cy.findByText(checkboxName, { timeout: 5000 }).click();
27+
cy.findByRole('checkbox', { name: checkboxName, timeout: 5000 }).click();
2428
});
2529

2630
When('I wait for pinpoint messages to sync', () => {

0 commit comments

Comments
 (0)