Files
spring-shell/e2e/spring-shell-e2e-tests/test/flow.test.ts
Janne Valkealahti b555148ce9 Fix assert in flow e2e test
- Fix assert by checking plain ">" if env CI variable is not set.
- Fixes #576
2022-11-30 17:27:48 +00:00

112 lines
2.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'jest-extended';
import waitForExpect from 'wait-for-expect';
import { Cli } from 'spring-shell-e2e';
import {
nativeDesc,
jarDesc,
jarCommand,
nativeCommand,
jarOptions,
waitForExpectDefaultTimeout,
waitForExpectDefaultInterval,
testTimeout
} 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();
// windows on gh actions may take quite a bit of time to start
// so use long timeout
await waitForExpect(async () => {
const screen = cli.screen();
expect(screen).toEqual(expect.arrayContaining([expect.stringContaining('Single1')]));
}, 60000);
await cli.keyDown();
await waitForExpect(async () => {
const screen = cli.screen();
expect(screen).toEqual(expect.arrayContaining([expect.stringMatching(/[>] 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 = waitForExpectDefaultTimeout;
waitForExpect.defaults.interval = waitForExpectDefaultInterval;
}, testTimeout);
afterEach(async () => {
cli?.dispose();
}, testTimeout);
/**
* fatjar commands
*/
describe(jarDesc, () => {
beforeAll(() => {
command = jarCommand;
options = jarOptions;
});
it(
flowConditionalField2SkipsFields1Desc,
async () => {
cli = new Cli({
command: command,
options: [...options, ...flowConditionalCommand]
});
await flowConditionalField2SkipsFields1(cli);
},
testTimeout
);
});
/**
* native commands
*/
describe(nativeDesc, () => {
beforeAll(() => {
command = nativeCommand;
options = [];
});
it(
flowConditionalField2SkipsFields1Desc,
async () => {
cli = new Cli({
command: command,
options: [...options, ...flowConditionalCommand]
});
await flowConditionalField2SkipsFields1(cli);
},
testTimeout
);
});
});