Skip to content

Commit

Permalink
eslint auto fix & fix merging
Browse files Browse the repository at this point in the history
  • Loading branch information
anshengxu committed Mar 7, 2024
1 parent 5aea46c commit ba6badf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ const JenkinsSetup = (): JSX.Element => {
const secretRef = useRef<HTMLDivElement>(null);
const siteNameRef = useRef<HTMLDivElement>(null);
const webhookUrlRef = useRef<HTMLDivElement>(null);
const { id: uuid, settings } = useParams<ParamTypes>();
const { id: uuid } = useParams<ParamTypes>();
const [serverName, setServerName] = useState('');
const [showMyJenkinsAdmin, setShowMyJenkinsAdmin] = useState(false);
const [showIAmTheJenkinsAdmin, setShowIAmTheJenkinsAdmin] = useState(false);
Expand All @@ -280,7 +280,6 @@ const JenkinsSetup = (): JSX.Element => {
const [globalPageUrl, setGlobalPageUrl] = useState<string>('');
const [primaryCopyButtonName, setPrimaryCopyButtonName] =
useState<CopyButtonNameEnum>('nonAdminWebhook');
const connectionSettings = settings === 'connection-settings';

const updateAdminCopyButtonState = (key: CopyButtonNameEnum, isClicked: boolean) => {
const existingItemIndex = copyAdminButtonStates.findIndex((item) => item.name === key);
Expand Down Expand Up @@ -434,26 +433,13 @@ const JenkinsSetup = (): JSX.Element => {
);
};

const handleNavigateToConnectionCompleteScreen = (e: React.MouseEvent) => {
const handleNavigateToConnectionServerManagementScreen = (e: React.MouseEvent) => {
e.preventDefault();

let pathParam = '';

if (showMyJenkinsAdmin) {
pathParam = 'requires-jenkins-admin';
} else {
pathParam = 'is-admin';
}

if (connectionSettings) {
if (path === 'admin') {
history.push('/');
} else {
router.navigate(globalPageUrl);
}
} else {
history.push(`/connection-complete/${uuid}/${pathParam}/${path}`);
if (path === 'global') {
router.navigate(globalPageUrl);
}
history.push('/');
};

const isFetchingData = !serverName || !webhookUrl || !secret;
Expand Down Expand Up @@ -533,7 +519,7 @@ const JenkinsSetup = (): JSX.Element => {
type="button"
appearance="primary"
isDisabled={!isAllRequiredButtonsClicked}
onClick={(e) => handleNavigateToConnectionCompleteScreen(e)}
onClick={(e) => handleNavigateToConnectionServerManagementScreen(e)}
testId="jenkins-set-up-next-btn"
>
Finish
Expand Down
42 changes: 21 additions & 21 deletions app/jenkins-for-jira-ui/src/components/SharePage/SharePage.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ import { AnalyticsScreenEventsEnum } from '../../common/analytics/analytics-even
import { SharePage } from './SharePage';

const testJenkinsServer: JenkinsServer = {
name: 'server four',
uuid: '56046af9-d0eb-4efb-8896-sjnd893rsd',
pluginConfig: {
ipAddress: '10.10.10.12',
lastUpdatedOn: new Date()
},
pipelines: [
{
name: '#3456',
lastEventType: EventType.BUILD,
lastEventStatus: 'successful',
lastEventDate: new Date()
}
]
}
name: 'server four',
uuid: '56046af9-d0eb-4efb-8896-sjnd893rsd',
pluginConfig: {
ipAddress: '10.10.10.12',
lastUpdatedOn: new Date()
},
pipelines: [
{
name: '#3456',
lastEventType: EventType.BUILD,
lastEventStatus: 'successful',
lastEventDate: new Date()
}
]
};

jest.mock('../../api/fetchGlobalPageUrl');
jest.mock('../../api/redirectFromGetStarted');

describe('SharePage Component', () => {
test('should copy to clipboard when "Copy to clipboard" is clicked', async () => {
test('should copy to clipboard when "Copy to clipboard" is clicked', async () => {
const mockWriteText = jest.fn().mockResolvedValueOnce(undefined);
Object.defineProperty(navigator, 'clipboard', {
value: {
writeText: mockWriteText,
},
value: {
writeText: mockWriteText
}
});
jest.spyOn(getAllJenkinsServersModule, 'getAllJenkinsServers').mockResolvedValueOnce([testJenkinsServer]);
jest.spyOn(fetchGlobalPageUrlModule, 'fetchGlobalPageUrl').mockResolvedValueOnce('https://somesite.atlassian.net/blah');
Expand All @@ -45,7 +45,7 @@ describe('SharePage Component', () => {
expect(navigator.clipboard.writeText).toBeCalled();
});

test('should close the share modal when "Close" is clicked', async () => {
test('should close the share modal when "Close" is clicked', async () => {
jest.spyOn(getAllJenkinsServersModule, 'getAllJenkinsServers').mockResolvedValueOnce([testJenkinsServer]);
jest.spyOn(fetchGlobalPageUrlModule, 'fetchGlobalPageUrl').mockResolvedValueOnce('https://somesite.atlassian.net/blah');

Expand All @@ -62,4 +62,4 @@ describe('SharePage Component', () => {
expect(screen.queryByText('Copy to clipboard')).not.toBeInTheDocument();
});
});
})
});

0 comments on commit ba6badf

Please sign in to comment.