Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions tests/legacy-cli/e2e/tests/commands/cache/cache-info.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,62 @@
import { execAndWaitForOutputToMatch } from '../../../utils/process';
import { updateJsonFile } from '../../../utils/project';

const ENV_NO_COLOR = {
'NO_COLOR': '1',
};

export default async function () {
const originalCIValue = process.env['CI'];

try {
// Should be enabled by default for local builds.
await configureTest('0' /** envCI */);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});

// Should be disabled by default for CI builds.
await configureTest('1' /** envCI */, { enabled: true });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/, {
...process.env,
...ENV_NO_COLOR,
});

// Should be enabled by when environment is local and env is not CI.
await configureTest('0' /** envCI */, { environment: 'local' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});

// Should be disabled by when environment is local and env is CI.
await configureTest('1' /** envCI */, { environment: 'local' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/, {
...process.env,
...ENV_NO_COLOR,
});

// Effective status should be enabled when 'environment' is set to 'all' or 'ci'.
await configureTest('1' /** envCI */, { environment: 'all' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});

// Effective status should be enabled when 'environment' is set to 'ci' and run is in ci
await configureTest('1' /** envCI */, { environment: 'ci' });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Enabled/, {
...process.env,
...ENV_NO_COLOR,
});

// Effective status should be disabled when 'enabled' is set to false
await configureTest('1' /** envCI */, { environment: 'all', enabled: false });
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/);
await execAndWaitForOutputToMatch('ng', ['cache', 'info'], /Effective Status\s*: Disabled/, {
...process.env,
...ENV_NO_COLOR,
});
} finally {
process.env['CI'] = originalCIValue;
}
Expand Down