Skip to content

Commit

Permalink
sign script updated
Browse files Browse the repository at this point in the history
  • Loading branch information
tudorgabriel committed Nov 3, 2023
1 parent ec3cf5b commit 38f49f7
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 19 deletions.
5 changes: 0 additions & 5 deletions .github/workflows/cypress-e2e-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
# - name: Run install
# uses: borales/actions-yarn@v4
# with:
# cmd: install --ignore-optional # will run `yarn install` command
# - run: yarn start
- name: Cypress run
uses: cypress-io/github-action@v6
with:
Expand Down
4 changes: 2 additions & 2 deletions cypress/e2e/Converters/Converters.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ describe('Converters', () => {
it('should be display the required error message', () => {
cy.get('input').then((selectors) => {
selectors.each((index) => {
cy.get('button[type="submit"]').eq(index).click();
cy.get('button[type="submit"]').eq(index-1).click();
cy.get('[data-cy="error"]')
.eq(index)
.eq(index-1)
.should(AssertionEnum.contain, 'required');
});
});
Expand Down
4 changes: 4 additions & 0 deletions cypress/e2e/NativeAuth/NativeAuth.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,8 @@ describe('Native Auth', () => {
cy.login(walletIDEnum.unguardedWallet1);
cy.contains('Token Valid');
});
afterEach(()=>{
cy.getSelector('navigation-page-unlock').click();
cy.contains('Login')
})
});
5 changes: 3 additions & 2 deletions cypress/e2e/SignMessage/SignMessage.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ describe('Sign Message', () => {
cy.visit('/');
cy.get('a[href="/sign-message"]').click();
});
it.only('should validate the signature', () => {
it('should validate the signature', () => {
signHandler();
cy.get('.styles_code__HFHh6')
cy.getSelector('signaturePayload')
.then((txt) => {
payload = txt.text();
})
Expand All @@ -23,6 +23,7 @@ describe('Sign Message', () => {

it('should return Invalid signature payload', () => {
cy.get('textarea[name="signedMessage"]').type('Invalid#');
cy.contains('button', 'Verify').click();
cy.contains('Invalid signature payload');
});

Expand Down
1 change: 1 addition & 0 deletions cypress/e2e/SignMessage/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const signHandler = () => {
cy.get('button[type="submit"]').eq(0).click();
cy.get('button[type="submit"]').eq(0).click();
cy.getSelector('keystoreBtn').click();

cy.get('input[type=file]').selectFile('./cypress/assets/testKeystore.json', {
force: true
});
Expand Down
7 changes: 4 additions & 3 deletions src/pages/Converters/components/Converter/Converter.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { useCallback, useState } from 'react';
import { ErrorMessage, Field, Form, Formik } from 'formik';
import { CopyButton } from '@multiversx/sdk-dapp/UI/CopyButton';
import { object, string } from 'yup';
import classNames from 'classnames';
import { ErrorMessage, Field, Form, Formik } from 'formik';
import { object, string } from 'yup';

import styles from './styles.module.scss';
import type { ConverterType, SubmitType } from './types';

import styles from './styles.module.scss';

/*
* Handle the component declaration.
Expand Down Expand Up @@ -76,6 +76,7 @@ export const Converter = (props: ConverterType) => {

<ErrorMessage
data-testid={`${identifier}-error`}
data-cy='error'
name='converter'
className={styles.error}
component='div'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { ChangeEvent, useEffect } from 'react';
import { ErrorMessage, Field, Form, useFormikContext } from 'formik';
import { CopyButton } from '@multiversx/sdk-dapp/UI/CopyButton';
import classNames from 'classnames';
import { ErrorMessage, Field, Form, useFormikContext } from 'formik';
import { useSearchParams } from 'react-router-dom';
import { useSignMessageForm } from '../hooks/useSignMessageForm';
import { SignMessageFormValues } from '../types';
import { useSignMessageSectionContext } from 'pages/SignMessage/context';
import styles from 'pages/SignMessage/styles.module.scss';
import { useSignMessageForm } from '../hooks/useSignMessageForm';
import { SignMessageFormValues } from '../types';

export const SignMessageForm = () => {
const { setFieldValue } = useFormikContext<SignMessageFormValues>();
Expand Down Expand Up @@ -44,7 +44,7 @@ export const SignMessageForm = () => {
<strong>Signature payload:</strong>

<div className={styles.code}>
<pre className={styles.value}>{signedMessagePayload}</pre>
<pre data-testid='signaturePayload' className={styles.value}>{signedMessagePayload}</pre>
<CopyButton text={signedMessagePayload} className={styles.copy} />
</div>
</div>
Expand Down
7 changes: 4 additions & 3 deletions src/pages/SignMessage/components/VerifySignatureForm.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { ChangeEvent, useState } from 'react';
import { verifyMessage } from '@multiversx/sdk-dapp/hooks/signMessage/verifyMessage';
import { addressIsValid } from '@multiversx/sdk-dapp/utils/account/addressIsValid';
import classNames from 'classnames';
import { ErrorMessage, Field, Form, Formik } from 'formik';
import { number, object, string } from 'yup';
import classNames from 'classnames';
import styles from 'pages/SignMessage/styles.module.scss';
import { addressIsValid } from '@multiversx/sdk-dapp/utils/account/addressIsValid';
import { verifyMessage } from '@multiversx/sdk-dapp/hooks/signMessage/verifyMessage';

export const VerifySignatureForm = () => {
const [verifiedMessage, setVerifiedMessage] = useState<string>();
Expand Down Expand Up @@ -73,6 +73,7 @@ export const VerifySignatureForm = () => {
<label className={styles.label}>Verify signature</label>

<Field
data-testid='verifySignature'
component='textarea'
rows={10}
name='signedMessage'
Expand Down

0 comments on commit 38f49f7

Please sign in to comment.