Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: snapshot tests for storage_types contract dryrun results #470

Merged
merged 5 commits into from
May 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 58 additions & 0 deletions cypress/e2e/contracts/storage_types.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// Copyright 2022 @paritytech/contracts-ui authors & contributors
// SPDX-License-Identifier: GPL-3.0-only

import {
beforeAllContracts,
assertUpload,
assertMoveToStep2,
assertMoveToStep3,
assertContractRedirect,
assertInstantiate,
selectMessage,
} from '../../support/util';

describe('Storage Types Contract', () => {
before(() => {
beforeAllContracts();
});

it('contract file uploads', () => {
assertUpload('storage_types.contract');
});

it('moves to step 2', () => {
assertMoveToStep2();
});

it('moves to step 3', () => {
assertMoveToStep3();
});

it('submits instantiate transaction', () => {
assertInstantiate();
});

it('redirects to contract page after instantiation', () => {
assertContractRedirect();
});

[
'getUnsignedIntegers',
'getSignedIntegers',
'getInkPreludeTypes',
'getSubstrateTypes',
'getPrimitiveTypes',
'getOptionSome',
'getOptionNone',
'getResultOk',
'getResultError',
'getPanic',
].forEach((message, index) => {
it(`DryRun ${message}`, () => {
cy.get('.form-field.caller').click().find('.dropdown__option').eq(2).click();
selectMessage(message, index);

cy.get('[data-cy="output"]').find('code').snapshot();
});
});
});
1 change: 1 addition & 0 deletions cypress/fixtures/storage_types.contract

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
/// <reference types="cypress" />
import 'cypress-file-upload';
require('@cypress/snapshot').register();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
},
"devDependencies": {
"@cypress/code-coverage": "^3.10.0",
"@cypress/snapshot": "^2.1.7",
"@esbuild-plugins/node-globals-polyfill": "^0.2.3",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@nabla/vite-plugin-eslint": "^1.5.0",
Expand Down
38 changes: 38 additions & 0 deletions snapshots.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
module.exports = {
__version: '12.8.1',
'Storage Types Contract': {
UnsignedIntegers: {
1: "<code>{\n i128ValueMax: '170,141,183,460,469,231,731,687,303,715,884,105,727',\n i128ValueMin: '-170,141,183,460,469,231,731,687,303,715,884,105,728',\n i16ValueMax: '-32,769',\n i16ValueMin: '-32,768',\n i32ValueMax: '2,147,483,647',\n i32ValueMin: '-2,147,483,648',\n i64ValueMax: '9,223,372,036,854,775,807',\n i64ValueMin: '-9,223,372,036,854,775,808',\n i8ValueMax: '-129',\n i8ValueMin: '-128',\n }</code>",
},
'DryRun getUnsignedIntegers': {
1: "<code>{\n u128ValueMax: '340,282,366,920,938,463,463,374,607,431,768,211,455',\n u128ValueMin: '0',\n u16ValueMax: '65,535',\n u16ValueMin: '0',\n u32ValueMax: '4,294,967,295',\n u32ValueMin: '0',\n u64ValueMax: '18,446,744,073,709,551,615',\n u64ValueMin: '0',\n u8ValueMax: '255',\n u8ValueMin: '0',\n }</code>",
},
'DryRun getSignedIntegers': {
1: "<code>{\n i128ValueMax: '170,141,183,460,469,231,731,687,303,715,884,105,727',\n i128ValueMin: '-170,141,183,460,469,231,731,687,303,715,884,105,728',\n i16ValueMax: '-32,769',\n i16ValueMin: '-32,768',\n i32ValueMax: '2,147,483,647',\n i32ValueMin: '-2,147,483,648',\n i64ValueMax: '9,223,372,036,854,775,807',\n i64ValueMin: '-9,223,372,036,854,775,808',\n i8ValueMax: '-129',\n i8ValueMin: '-128',\n }</code>",
},
'DryRun getInkPreludeTypes': {
1: "<code>{\n stringValue: 'This is a string',\n vecStringValue: [\n 'This is a String',\n 'This is another String',\n ],\n vecVecStringValue: [\n [\n 'This is a String',\n 'This is another String',\n ],\n ],\n }</code>",
},
'DryRun getSubstrateTypes': {
1: "<code>{\n accountIdValue: '5C4hrfjw9DjXZTzV3MwzrrAr9P1MJhSrvWGWqi1eSuyUpnhM',\n balanceValueMax: '340,282,366,920,938,463,463,374,607,431,768,211,455',\n balanceValueMin: '0',\n hashValue:\n '0x0000000000000000000000000000000000000000000000000000000000000000',\n }</code>",
},
'DryRun getPrimitiveTypes': {
1: "<code>{\n boolValue: true,\n enumWithoutValues: 'A',\n enumWithValues: {\n ThreeValues: [\n '1',\n '2',\n '3',\n ],\n },\n arrayValue: [\n '3',\n '2',\n '1',\n ],\n tupleValue: [\n '7',\n '8',\n ],\n }</code>",
},
'DryRun getOptionNone': {
1: '<code>null</code>',
},
'DryRun getResultError': {
1: "<code>{\n ErrorWithMessage: 'This is the Error Message.',\n }</code>",
},
'DryRun getPanic': {
1: '<code>ContractTrapped</code>',
},
'DryRun getOptionSome': {
1: '<code>true</code>',
},
'DryRun getResultOk': {
1: '<code>{\n Ok: true,\n }</code>',
},
},
};