Initial attempt for e2e tests
- Add node code for e2e tests. This is a first take to try running these tests via actions. - Relates to #401
This commit is contained in:
69
e2e/spring-shell-e2e-tests/test/builtin.test.ts
Normal file
69
e2e/spring-shell-e2e-tests/test/builtin.test.ts
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'jest-extended';
|
||||
import waitForExpect from 'wait-for-expect';
|
||||
import { Cli } from 'spring-shell-e2e';
|
||||
import { nativeDesc, jarDesc, jarCommand, nativeCommand, jarOptions } from '../src/utils';
|
||||
|
||||
// all buildin commands
|
||||
describe('builtin commands', () => {
|
||||
let cli: Cli;
|
||||
let command: string;
|
||||
let options: string[] = [];
|
||||
|
||||
/**
|
||||
* test for version command returns expected info
|
||||
*/
|
||||
const versionReturnsInfoDesc = 'version returns info';
|
||||
const versionCommand = ['version'];
|
||||
const versionReturnsInfo = async (cli: Cli) => {
|
||||
cli.run();
|
||||
await waitForExpect(async () => {
|
||||
const screen = cli.screen();
|
||||
expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('Build Version')]));
|
||||
});
|
||||
await expect(cli.exitCode()).resolves.toBe(0);
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
waitForExpect.defaults.timeout = 3000;
|
||||
waitForExpect.defaults.interval = 100;
|
||||
}, 300000);
|
||||
|
||||
afterEach(async () => {
|
||||
cli?.dispose();
|
||||
}, 100000);
|
||||
|
||||
/**
|
||||
* native commands
|
||||
*/
|
||||
describe(nativeDesc, () => {
|
||||
beforeAll(() => {
|
||||
command = nativeCommand;
|
||||
});
|
||||
|
||||
it(versionReturnsInfoDesc, async () => {
|
||||
cli = new Cli({
|
||||
command: command,
|
||||
options: [...options, ...versionCommand]
|
||||
});
|
||||
await versionReturnsInfo(cli);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* fatjar commands
|
||||
*/
|
||||
describe(jarDesc, () => {
|
||||
beforeAll(() => {
|
||||
command = jarCommand;
|
||||
options = jarOptions;
|
||||
});
|
||||
|
||||
it(versionReturnsInfoDesc, async () => {
|
||||
cli = new Cli({
|
||||
command: command,
|
||||
options: [...options, ...versionCommand]
|
||||
});
|
||||
await versionReturnsInfo(cli);
|
||||
});
|
||||
});
|
||||
});
|
||||
91
e2e/spring-shell-e2e-tests/test/flow.test.ts
Normal file
91
e2e/spring-shell-e2e-tests/test/flow.test.ts
Normal file
@@ -0,0 +1,91 @@
|
||||
import 'jest-extended';
|
||||
import waitForExpect from 'wait-for-expect';
|
||||
import { Cli } from 'spring-shell-e2e';
|
||||
import { nativeDesc, jarDesc, jarCommand, nativeCommand, jarOptions } from '../src/utils';
|
||||
|
||||
// all flow commands
|
||||
describe('flow commands', () => {
|
||||
let cli: Cli;
|
||||
let command: string;
|
||||
let options: string[] = [];
|
||||
|
||||
/**
|
||||
* test for flow conditional field2 skips field1
|
||||
*/
|
||||
const flowConditionalField2SkipsFields1Desc = 'flow conditional field2 skips field1';
|
||||
const flowConditionalCommand = ['flow', 'conditional'];
|
||||
const flowConditionalField2SkipsFields1 = async (cli: Cli) => {
|
||||
cli.run();
|
||||
|
||||
await waitForExpect(async () => {
|
||||
const screen = cli.screen();
|
||||
expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('Single1')]));
|
||||
});
|
||||
|
||||
await cli.keyDown();
|
||||
await waitForExpect(async () => {
|
||||
const screen = cli.screen();
|
||||
expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('> Field2')]));
|
||||
});
|
||||
|
||||
await cli.keyEnter();
|
||||
await waitForExpect(async () => {
|
||||
const screen = cli.screen();
|
||||
expect(screen).toEqual(
|
||||
expect.arrayContaining([expect.stringContaining('? Field2 [Default defaultField2Value]')])
|
||||
);
|
||||
});
|
||||
|
||||
await cli.keyEnter();
|
||||
await waitForExpect(async () => {
|
||||
const screen = cli.screen();
|
||||
expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('Field2 defaultField2Value')]));
|
||||
});
|
||||
|
||||
await expect(cli.exitCode()).resolves.toBe(0);
|
||||
};
|
||||
|
||||
beforeEach(async () => {
|
||||
waitForExpect.defaults.timeout = 3000;
|
||||
waitForExpect.defaults.interval = 100;
|
||||
}, 300000);
|
||||
|
||||
afterEach(async () => {
|
||||
cli?.dispose();
|
||||
}, 100000);
|
||||
|
||||
/**
|
||||
* native commands
|
||||
*/
|
||||
describe(nativeDesc, () => {
|
||||
beforeAll(() => {
|
||||
command = nativeCommand;
|
||||
});
|
||||
|
||||
it(flowConditionalField2SkipsFields1Desc, async () => {
|
||||
cli = new Cli({
|
||||
command: command,
|
||||
options: [...options, ...flowConditionalCommand]
|
||||
});
|
||||
await flowConditionalField2SkipsFields1(cli);
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* fatjar commands
|
||||
*/
|
||||
describe(jarDesc, () => {
|
||||
beforeAll(() => {
|
||||
command = jarCommand;
|
||||
options = jarOptions;
|
||||
});
|
||||
|
||||
it(flowConditionalField2SkipsFields1Desc, async () => {
|
||||
cli = new Cli({
|
||||
command: command,
|
||||
options: [...options, ...flowConditionalCommand]
|
||||
});
|
||||
await flowConditionalField2SkipsFields1(cli);
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user