diff --git a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx
index 002652cfab..f0e47a2504 100644
--- a/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx
+++ b/plugins/scaffolder/src/components/fields/RepoUrlPicker/RepoUrlPicker.test.tsx
@@ -214,13 +214,14 @@ describe('RepoUrlPicker', () => {
describe('requestUserCredentials', () => {
it('should call the scmAuthApi with the correct params', async () => {
+ const secretsKey = 'testKey';
+
const SecretsComponent = () => {
const { secrets } = useTemplateSecrets();
- return (
-
{JSON.stringify({ secrets })}
- );
+ const secret = secrets[secretsKey];
+ return secret ? {secret}
: null;
};
- const { getByTestId } = await renderInTestApp(
+ const { getByText } = await renderInTestApp(
{
'ui:field': 'RepoUrlPicker',
'ui:options': {
requestUserCredentials: {
- secretsKey: 'testKey',
+ secretsKey,
additionalScopes: { github: ['workflow'] },
},
},
@@ -265,21 +266,9 @@ describe('RepoUrlPicker', () => {
},
});
- const currentSecrets = JSON.parse(
- getByTestId('current-secrets').textContent!,
- );
-
- expect(currentSecrets).toEqual({
- secrets: { testKey: 'abc123' },
- });
+ expect(getByText('abc123')).toBeInTheDocument();
});
it('should call the scmAuthApi with the correct params if workspace is nested', async () => {
- const SecretsComponent = () => {
- const { secrets } = useTemplateSecrets();
- return (
- {JSON.stringify({ secrets })}
- );
- };
await renderInTestApp(
{
RepoUrlPicker: RepoUrlPicker as ScaffolderRJSFField,
}}
/>
-
,
);
@@ -324,13 +312,14 @@ describe('RepoUrlPicker', () => {
});
it('should not call the scmAuthApi if secret is available in the state', async () => {
+ const secretsKey = 'testKey';
+
const SecretsComponent = () => {
const { secrets } = useTemplateSecrets();
- return (
- {JSON.stringify({ secrets })}
- );
+ const secret = secrets[secretsKey];
+ return secret ? {secret}
: null;
};
- const { getByTestId } = await renderInTestApp(
+ const { getByText } = await renderInTestApp(
{
[scaffolderApiRef, mockScaffolderApi],
]}
>
-
+