Skip to content

Commit 66043af

Browse files
authored
Merge branch 'main' into fix_use_re
2 parents 7ebc776 + 6935193 commit 66043af

5 files changed

Lines changed: 42 additions & 34 deletions

File tree

src/Components/CreateImageWizard/steps/Registration/components/ManualActivationKey.tsx

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
import React, { MutableRefObject, useEffect, useRef } from 'react';
1+
import React, { useEffect } from 'react';
22

33
import {
4+
Button,
45
Content,
56
ContentVariants,
67
FormGroup,
7-
FormGroupLabelHelp,
88
Popover,
99
} from '@patternfly/react-core';
10+
import { HelpIcon } from '@patternfly/react-icons';
1011

1112
import { ValidatedInput } from '@/Components/CreateImageWizard/ValidatedInput';
1213
import { CDN_PROD_URL } from '@/constants';
@@ -20,14 +21,9 @@ import {
2021
selectOrgId,
2122
} from '@/store/slices/wizard';
2223

23-
const ManualRegistrationPopover = ({
24-
ref,
25-
}: {
26-
ref: MutableRefObject<null>;
27-
}) => {
24+
const ManualRegistrationPopover = () => {
2825
return (
2926
<Popover
30-
triggerRef={ref}
3127
headerContent='About Activation Keys & Organization ID'
3228
position='right'
3329
minWidth='30rem'
@@ -46,9 +42,12 @@ const ManualRegistrationPopover = ({
4642
</Content>
4743
}
4844
>
49-
<FormGroupLabelHelp
50-
ref={ref}
45+
<Button
46+
icon={<HelpIcon />}
47+
variant='plain'
48+
size='sm'
5149
aria-label='About Activation Keys & Organization ID'
50+
hasNoPadding
5251
/>
5352
</Popover>
5453
);
@@ -58,8 +57,6 @@ export const ManualActivationKey = () => {
5857
const dispatch = useAppDispatch();
5958
const orgId = useAppSelector(selectOrgId);
6059
const activationKey = useAppSelector(selectActivationKey);
61-
const orgIdRef = useRef(null);
62-
const activationKeyRef = useRef(null);
6360

6461
useEffect(() => {
6562
dispatch(changeServerUrl('subscription.rhsm.redhat.com'));
@@ -71,7 +68,7 @@ export const ManualActivationKey = () => {
7168
<FormGroup
7269
className='pf-v6-u-mb-md'
7370
label={'Activation key'}
74-
labelHelp={<ManualRegistrationPopover ref={activationKeyRef} />}
71+
labelHelp={<ManualRegistrationPopover />}
7572
isRequired
7673
>
7774
<ValidatedInput
@@ -88,7 +85,7 @@ export const ManualActivationKey = () => {
8885
</FormGroup>
8986
<FormGroup
9087
label={'Organization ID'}
91-
labelHelp={<ManualRegistrationPopover ref={orgIdRef} />}
88+
labelHelp={<ManualRegistrationPopover />}
9289
isRequired
9390
>
9491
<ValidatedInput

src/Components/CreateImageWizard/steps/Repositories/tests/Repositories.test.tsx

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import { screen, waitFor } from '@testing-library/react';
33
import { mapRequestFromState } from '@/Components/CreateImageWizard/utilities/requestMapper';
44
import { CreateBlueprintRequest } from '@/store/api/backend';
55
import { server } from '@/test/mocks/server';
6-
import { createTestStore, createUser, typeWithWait } from '@/test/testUtils';
6+
import {
7+
clickWithWait,
8+
createTestStore,
9+
createUser,
10+
typeWithWait,
11+
} from '@/test/testUtils';
712

813
import {
914
removeRepo,
@@ -101,7 +106,7 @@ describe('Repositories Component', () => {
101106
const toggle = await screen.findByRole('button', {
102107
name: /menu toggle/i,
103108
});
104-
await user.click(toggle);
109+
await clickWithWait(user, toggle);
105110

106111
// Should show repositories without typing
107112
expect(
@@ -123,7 +128,7 @@ describe('Repositories Component', () => {
123128
const toggle = await screen.findByRole('button', {
124129
name: /menu toggle/i,
125130
});
126-
await user.click(toggle);
131+
await clickWithWait(user, toggle);
127132

128133
expect(
129134
await screen.findByRole('option', {
@@ -135,7 +140,7 @@ describe('Repositories Component', () => {
135140
const searchInput = await screen.findByRole('textbox', {
136141
name: /filter repositories/i,
137142
});
138-
await user.type(searchInput, 'nonexistent');
143+
await typeWithWait(user, searchInput, 'nonexistent');
139144

140145
expect(
141146
await screen.findByRole('option', {
@@ -166,15 +171,15 @@ describe('Repositories Component', () => {
166171
const toggle = await screen.findByRole('button', {
167172
name: /menu toggle/i,
168173
});
169-
await user.click(toggle);
174+
await clickWithWait(user, toggle);
170175

171176
await screen.findByRole('option', { name: /no repositories available/i });
172177

173178
// Type to search - should use limit=50
174179
const searchInput = await screen.findByRole('textbox', {
175180
name: /filter repositories/i,
176181
});
177-
await user.type(searchInput, 'test');
182+
await typeWithWait(user, searchInput, 'test');
178183

179184
await screen.findByRole('option', {
180185
name: /no repositories found for "test"/i,
@@ -295,14 +300,16 @@ describe('Repositories Component', () => {
295300
await selectRepo(user, '01-test-valid-repo');
296301
await selectRepo(user, '04-test-another-valid-repo');
297302

298-
expect(
299-
await screen.findByRole('cell', { name: /01-test-valid-repo/i }),
300-
).toBeInTheDocument();
301-
expect(
302-
await screen.findByRole('cell', {
303-
name: /04-test-another-valid-repo/i,
304-
}),
305-
).toBeInTheDocument();
303+
await waitFor(() => {
304+
expect(
305+
screen.getByRole('cell', { name: /01-test-valid-repo/i }),
306+
).toBeInTheDocument();
307+
expect(
308+
screen.getByRole('cell', {
309+
name: /04-test-another-valid-repo/i,
310+
}),
311+
).toBeInTheDocument();
312+
});
306313
});
307314
});
308315

src/test/Components/ImagesTable/ImagesTable.test.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,13 @@ describe('Images Table', () => {
3232
expect(headerCells[2]).toHaveTextContent('Updated');
3333
expect(headerCells[3]).toHaveTextContent('OS');
3434
expect(headerCells[4]).toHaveTextContent('Target');
35-
expect(headerCells[5]).toHaveTextContent('Version');
36-
expect(headerCells[6]).toHaveTextContent('Status');
37-
expect(headerCells[7]).toHaveTextContent('Instance');
35+
if (!process.env.IS_ON_PREMISE) {
36+
expect(headerCells[5]).toHaveTextContent('Version');
37+
expect(headerCells[6]).toHaveTextContent('Status');
38+
expect(headerCells[7]).toHaveTextContent('Instance');
39+
} else {
40+
expect(headerCells[5]).toHaveTextContent('Status');
41+
}
3842

3943
const imageNameValues = mockComposes.map((compose) =>
4044
compose.image_name ? compose.image_name : compose.id,

src/test/fixtures/repositories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -610,7 +610,7 @@ const generateLinks = (
610610
const generateFillerRepos = (num: number): ApiRepositoryResponse[] => {
611611
const repos = new Array(num).fill(undefined).map((_, i) => {
612612
return {
613-
uuid: '9cf1d45d-aa06-46fe-87ea-121845cc6bbb',
613+
uuid: `filler-repo-${i}`,
614614
name: `z-filler repo ${i}`,
615615
url: `http://fillerRepos.org/9/x86_64/packages/${i}`,
616616
distribution_versions: ['any'],

src/test/mocks/cockpit/fsinfo.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import path from 'path';
55
import { mockBlueprintIds } from '../../fixtures/blueprints';
66
import { mockComposes } from '../../fixtures/composes';
77

8-
const bpDir = '/default/.cache/cockpit-image-builder/';
8+
const bpDir = '/default/.local/state/cockpit-image-builder';
99

1010
type fileinfo = {
1111
entries?: Record<string, fileinfo>;
@@ -65,7 +65,7 @@ export const fsinfo = (
6565
// abuse one blueprint to return all composes.
6666
if (
6767
filepath ===
68-
'/default/.cache/cockpit-image-builder/b3ff8307-18bd-418a-9a91-836ce039b035'
68+
'/default/.local/state/cockpit-image-builder/b3ff8307-18bd-418a-9a91-836ce039b035'
6969
) {
7070
return listComposes();
7171
}

0 commit comments

Comments
 (0)