Files
spring-shell/e2e/spring-shell-e2e-tests/test/flow.test.ts
Janne Valkealahti 3743a7f32d 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
2022-05-07 17:51:51 +01:00

92 lines
2.4 KiB
TypeScript

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);
});
});
});