Skip to content

Commit

Permalink
integ test in ci
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel committed Mar 21, 2024
1 parent fdd5491 commit 3563b81
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/frontend-build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,11 @@ jobs:
run: |
cd app && npm ci && npm run build
cp -r build ../build
steps:
- uses: actions/checkout@v2
- name: npm test
run: |
cargo run
cd app && npm run test
3 changes: 2 additions & 1 deletion app/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const FUEL_GREEN = '#00f58c';

export const LOCAL_SERVER_URI = 'http://0.0.0.0:8080';
export const SERVER_URI = process.env.REACT_APP_LOCAL_SERVER
? 'http://0.0.0.0:8080'
? LOCAL_SERVER_URI
: 'https://api.sway-playground.org';
65 changes: 65 additions & 0 deletions app/src/features/editor/examples/examples.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { EXAMPLE_CONTRACTS } from '.';
import { LOCAL_SERVER_URI } from '../../../constants';
import { ExampleMenuItem } from '../components/ExampleDropdown';

describe(`test examples`, () => {
beforeAll(() => {
// Start server
// require('../../../server');
});

describe(`transpile solidity examples`, () => {
const uri = `${LOCAL_SERVER_URI}/transpile`;

it.each(
EXAMPLE_CONTRACTS['solidity'].map(({ label, code }: ExampleMenuItem) => [
label,
code,
])
)('%s', async (_label, code) => {
// Call server
const request = new Request(uri, {
method: 'POST',
body: JSON.stringify({
contract: code,
lanaguage: 'solidity',
}),
});

const response = await fetch(request);
const {error, swayContract} = await response.json();

expect(error).toBeUndefined();
expect(swayContract).toContain('contract;');
});
});

describe(`compile sway examples`, () => {
const uri = `${LOCAL_SERVER_URI}/compile`;

it.each(
EXAMPLE_CONTRACTS['sway'].map(({ label, code }: ExampleMenuItem) => [
label,
code,
])
)('%s', async (_label, code) => {
// Call server
const request = new Request(uri, {
method: 'POST',
body: JSON.stringify({
contract: code,
toolchain: 'latest'
}),
});

const response = await fetch(request);
const { error, abi, bytecode, storageSlots, forcVersion } = await response.json();

expect(error).toBeUndefined();
expect(abi).toBeDefined();
expect(bytecode).toBeDefined();
expect(storageSlots).toBeDefined();
expect(forcVersion).toBeDefined();
}, 10000);
});
});

0 comments on commit 3563b81

Please sign in to comment.