Skip to content

Commit

Permalink
fix integration test for recipient
Browse files Browse the repository at this point in the history
  • Loading branch information
moodysalem committed Aug 24, 2020
1 parent 73580de commit 09b5457
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 16 deletions.
32 changes: 25 additions & 7 deletions cypress/integration/swap.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,32 @@ describe('Swap', () => {
cy.get('#confirm-swap-or-send').should('contain', 'Confirm Swap')
})

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

it('remove recipient', () => {
cy.get('#add-recipient-button').click()
cy.get('#remove-recipient-button').click()
cy.get('#recipient').should('not.exist')
describe('expert mode', () => {
beforeEach(() => {
cy.window().then(win => {
cy.stub(win, 'prompt').returns('confirm')
})
cy.get('#open-settings-dialog-button').click()
cy.get('#toggle-expert-mode-button').click()
cy.get('#confirm-expert-mode').click()
})
it('add a recipient is visible', () => {
cy.get('#add-recipient-button').should('be.visible')
})

it('add a recipient', () => {
cy.get('#add-recipient-button').click()
cy.get('#recipient').should('exist')
})

it('remove recipient', () => {
cy.get('#add-recipient-button').click()
cy.get('#remove-recipient-button').click()
cy.get('#recipient').should('not.exist')
})
})
})
5 changes: 3 additions & 2 deletions src/components/Settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -188,15 +188,15 @@ export default function SettingsTab() {
}
}}
>
<Text fontSize={20} fontWeight={500}>
<Text fontSize={20} fontWeight={500} id="confirm-expert-mode">
Turn On Expert Mode
</Text>
</ButtonError>
</AutoColumn>
</AutoColumn>
</ModalContentWrapper>
</Modal>
<StyledMenuButton onClick={toggle}>
<StyledMenuButton onClick={toggle} id="open-settings-dialog-button">
<StyledMenuIcon />
{expertMode && (
<EmojiWrapper>
Expand Down Expand Up @@ -229,6 +229,7 @@ export default function SettingsTab() {
<QuestionHelper text="Bypasses confirmation modals and allows high slippage trades. Use at your own risk." />
</RowFixed>
<Toggle
id="toggle-expert-mode-button"
isActive={expertMode}
toggle={
expertMode
Expand Down
14 changes: 7 additions & 7 deletions src/components/Toggle/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ const ToggleElement = styled.span<{ isActive?: boolean; isOnSwitch?: boolean }>`
font-weight: 400;
`

const StyledToggle = styled.a<{ isActive?: boolean; activeElement?: boolean }>`
const StyledToggle = styled.button<{ isActive?: boolean; activeElement?: boolean }>`
border-radius: 16px;
border: 1px solid ${({ theme, isActive }) => (isActive ? theme.primary5 : theme.text4)};
display: flex;
width: fit-content;
cursor: pointer;
text-decoration: none;
:hover {
text-decoration: none;
}
outline: none;
padding: 0;
background-color: transparent;
`

export interface ToggleProps {
id?: string
isActive: boolean
toggle: () => void
}

export default function Toggle({ isActive, toggle }: ToggleProps) {
export default function Toggle({ id, isActive, toggle }: ToggleProps) {
return (
<StyledToggle isActive={isActive} target="_self" onClick={toggle}>
<StyledToggle id={id} isActive={isActive} onClick={toggle}>
<ToggleElement isActive={isActive} isOnSwitch={true}>
On
</ToggleElement>
Expand Down

1 comment on commit 09b5457

@vercel
Copy link

@vercel vercel bot commented on 09b5457 Aug 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.