Skip to content
Prev Previous commit
Next Next commit
Add tests for release and deploy
  • Loading branch information
nachoiacovino committed Sep 2, 2022
commit d736d65b0e0d47f79baa3d6ea08eee307cfc8fab
2 changes: 1 addition & 1 deletion packages/cli/constants/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ export const CREATE_MESSAGES = {
framework: "What framework do you want to use?",
language: "What language do you want to use?",
contract: "What contract do you want to start from?",
};
} as const;
4 changes: 0 additions & 4 deletions packages/cli/e2e/create.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ describe("npx thirdweb create", () => {
it("should create app (CRA) successfully", async () => {
const { spawn, cleanup, exists } = await prepareEnvironment();
const {
// wait,
waitForText,
waitForFinish,
// getStdout,
// getStderr,
getExitCode,
// debug,
pressKey,
} = await spawn("node", "./dist/cli/index.js create");

Expand Down
37 changes: 37 additions & 0 deletions packages/cli/e2e/deploy.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
import { copyFile } from "fs/promises";
import { resolve } from "path";

// this creates an app, can take some time that's fine
jest.setTimeout(120_000);

describe("npx thirdweb deploy", () => {
it("should return deploy page url", async () => {
const { spawn, cleanup, exists, path } = await prepareEnvironment();

await copyFile(resolve("./e2e/files/BasicContract.sol"), `${path}/BasicContract.sol`);

const {
waitForText,
waitForFinish,
getExitCode,
writeText,
getStdout,
} = await spawn("node", "./dist/cli/index.js deploy");

expect(await exists("BasicContract.sol")).toEqual(true);

await waitForText("Failed to find a supported project configuration");
await writeText("y")

// wait for program to finish
await waitForFinish();

expect(getStdout().at(-1)).toEqual("https://thirdweb.com/contracts/deploy/QmTzUx1eZ1RAeEwsL85umbJFYMTwwu1UsAM3f3tWHSrHKF");

// the process should exit with code 0
expect(getExitCode()).toEqual(0);

await cleanup(); // cleanup after test
});
});
6 changes: 6 additions & 0 deletions packages/cli/e2e/files/BasicContract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract BasicContract {
constructor() {}
}
37 changes: 37 additions & 0 deletions packages/cli/e2e/release.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { prepareEnvironment } from "@gmrchk/cli-testing-library";
import { copyFile } from "fs/promises";
import { resolve } from "path";

// this creates an app, can take some time that's fine
jest.setTimeout(120_000);

describe("npx thirdweb release", () => {
it("should return release page url", async () => {
const { spawn, cleanup, exists, path } = await prepareEnvironment();

await copyFile(resolve("./e2e/files/BasicContract.sol"), `${path}/BasicContract.sol`);

const {
waitForText,
waitForFinish,
getExitCode,
writeText,
getStdout,
} = await spawn("node", "./dist/cli/index.js release");

expect(await exists("BasicContract.sol")).toEqual(true);

await waitForText("Failed to find a supported project configuration");
await writeText("y")

// wait for program to finish
await waitForFinish();

expect(getStdout().at(-1)).toEqual("https://thirdweb.com/contracts/release/QmXENbPLE5wkAhyUr7y2YShsUHLTtgaG1CvQffUaek6pNN");

// the process should exit with code 0
expect(getExitCode()).toEqual(0);

await cleanup(); // cleanup after test
});
});