Skip to content

Commit 09b5457

Browse files
committed
fix integration test for recipient
1 parent 73580de commit 09b5457

File tree

3 files changed

+35
-16
lines changed

3 files changed

+35
-16
lines changed

cypress/integration/swap.test.ts

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,32 @@ describe('Swap', () => {
4141
cy.get('#confirm-swap-or-send').should('contain', 'Confirm Swap')
4242
})
4343

44-
it('add a recipient', () => {
45-
cy.get('#add-recipient-button').click()
46-
cy.get('#recipient').should('exist')
44+
it('add a recipient does not exist unless in expert mode', () => {
45+
cy.get('#add-recipient-button').should('not.exist')
4746
})
4847

49-
it('remove recipient', () => {
50-
cy.get('#add-recipient-button').click()
51-
cy.get('#remove-recipient-button').click()
52-
cy.get('#recipient').should('not.exist')
48+
describe('expert mode', () => {
49+
beforeEach(() => {
50+
cy.window().then(win => {
51+
cy.stub(win, 'prompt').returns('confirm')
52+
})
53+
cy.get('#open-settings-dialog-button').click()
54+
cy.get('#toggle-expert-mode-button').click()
55+
cy.get('#confirm-expert-mode').click()
56+
})
57+
it('add a recipient is visible', () => {
58+
cy.get('#add-recipient-button').should('be.visible')
59+
})
60+
61+
it('add a recipient', () => {
62+
cy.get('#add-recipient-button').click()
63+
cy.get('#recipient').should('exist')
64+
})
65+
66+
it('remove recipient', () => {
67+
cy.get('#add-recipient-button').click()
68+
cy.get('#remove-recipient-button').click()
69+
cy.get('#recipient').should('not.exist')
70+
})
5371
})
5472
})

src/components/Settings/index.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,15 +188,15 @@ export default function SettingsTab() {
188188
}
189189
}}
190190
>
191-
<Text fontSize={20} fontWeight={500}>
191+
<Text fontSize={20} fontWeight={500} id="confirm-expert-mode">
192192
Turn On Expert Mode
193193
</Text>
194194
</ButtonError>
195195
</AutoColumn>
196196
</AutoColumn>
197197
</ModalContentWrapper>
198198
</Modal>
199-
<StyledMenuButton onClick={toggle}>
199+
<StyledMenuButton onClick={toggle} id="open-settings-dialog-button">
200200
<StyledMenuIcon />
201201
{expertMode && (
202202
<EmojiWrapper>
@@ -229,6 +229,7 @@ export default function SettingsTab() {
229229
<QuestionHelper text="Bypasses confirmation modals and allows high slippage trades. Use at your own risk." />
230230
</RowFixed>
231231
<Toggle
232+
id="toggle-expert-mode-button"
232233
isActive={expertMode}
233234
toggle={
234235
expertMode

src/components/Toggle/index.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,26 +10,26 @@ const ToggleElement = styled.span<{ isActive?: boolean; isOnSwitch?: boolean }>`
1010
font-weight: 400;
1111
`
1212

13-
const StyledToggle = styled.a<{ isActive?: boolean; activeElement?: boolean }>`
13+
const StyledToggle = styled.button<{ isActive?: boolean; activeElement?: boolean }>`
1414
border-radius: 16px;
1515
border: 1px solid ${({ theme, isActive }) => (isActive ? theme.primary5 : theme.text4)};
1616
display: flex;
1717
width: fit-content;
1818
cursor: pointer;
19-
text-decoration: none;
20-
:hover {
21-
text-decoration: none;
22-
}
19+
outline: none;
20+
padding: 0;
21+
background-color: transparent;
2322
`
2423

2524
export interface ToggleProps {
25+
id?: string
2626
isActive: boolean
2727
toggle: () => void
2828
}
2929

30-
export default function Toggle({ isActive, toggle }: ToggleProps) {
30+
export default function Toggle({ id, isActive, toggle }: ToggleProps) {
3131
return (
32-
<StyledToggle isActive={isActive} target="_self" onClick={toggle}>
32+
<StyledToggle id={id} isActive={isActive} onClick={toggle}>
3333
<ToggleElement isActive={isActive} isOnSwitch={true}>
3434
On
3535
</ToggleElement>

0 commit comments

Comments
 (0)