Skip to content

Commit

Permalink
test: improved the coverage of the githubComponent
Browse files Browse the repository at this point in the history
Signed-off-by: Abinand P <[email protected]>
  • Loading branch information
Abiji-2020 committed Nov 29, 2024
1 parent f7560d6 commit acc865b
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
77 changes: 77 additions & 0 deletions tests/github.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -385,4 +385,81 @@ describe('GiHub Complete Flow', () => {
const frameString = lastFrame()?.toString() ?? '';
expect(frameString).toMatch(/GitOps Configuration Wizard - GitHub/);
});
it('should display Error message for invalid status of the repo', async () => {
(configurePermit as any).mockResolvedValueOnce({
id: '1',
status: 'invalid',
key: 'repo3',
});
const { stdin, lastFrame } = render(
<GitHub options={{ key: demoPermitKey }} />,
);
const frameString = lastFrame()?.toString() ?? '';
expect(frameString).toMatch(/Loading Token/);
await delay(50);
expect(lastFrame()?.toString()).toMatch(
/GitOps Configuration Wizard - GitHub/,
);
await delay(50);
stdin.write(arrowDown);
await delay(50);
stdin.write(enter);
await delay(50);
expect(lastFrame()?.toString()).toMatch(/Enter Your RepositoryKey :/);
await delay(50);
stdin.write('repo3');
await delay(50);
stdin.write(enter);
await delay(50);
expect(lastFrame()?.toString()).toMatch(/SSH Key Generated./);
await delay(50);
stdin.write('[email protected]:user/repository.git');
await delay(50);
stdin.write(enter);
expect(lastFrame()?.toString()).toMatch(/Enter the Branch Name:/);
await delay(50);
stdin.write('main');
await delay(50);
stdin.write(enter);
await delay(50);
expect(lastFrame()?.toString()).toMatch(
'Invalid configuration. Please check the configuration and try again.',
);
});
it('should work with inactive argument', async () => {
const { stdin, lastFrame } = render(
<GitHub options={{ key: demoPermitKey, inactive: true }} />,
);
const frameString = lastFrame()?.toString() ?? '';
expect(frameString).toMatch(/Loading Token/);
await delay(100);
expect(lastFrame()?.toString()).toMatch(
/GitOps Configuration Wizard - GitHub/,
);
await delay(50);
stdin.write(arrowDown);
await delay(50);
stdin.write(enter);
await delay(50);
expect(lastFrame()?.toString()).toMatch(/Enter Your RepositoryKey :/);
await delay(50);
stdin.write('repo3');
await delay(50);
stdin.write(enter);
await delay(50);
expect(lastFrame()?.toString()).toMatch(/SSH Key Generated./);
await delay(50);
stdin.write('[email protected]:user/repository.git');
await delay(50);
stdin.write(enter);
expect(lastFrame()?.toString()).toMatch(/Enter the Branch Name:/);
await delay(50);
stdin.write('main');
await delay(50);
stdin.write(enter);
await delay(50);
expect(lastFrame()?.toString()).toMatch(
/Your GitOps is configured succesffuly. To complete the setup, remember to activate it later/,
);
});
});
Empty file added tests/lib/auth.test.ts
Empty file.

0 comments on commit acc865b

Please sign in to comment.