-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d90a139
commit c703afe
Showing
12 changed files
with
270 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { invoke } from '@forge/bridge'; | ||
|
||
type FetchGlobalPageUrlContext = { | ||
siteUrl: string; | ||
appId: string; | ||
environmentId: string; | ||
}; | ||
|
||
const fetchGlobalPageUrl = async (): Promise<string> => { | ||
const context: FetchGlobalPageUrlContext = await invoke('fetchAppData'); | ||
const { | ||
siteUrl, | ||
appId, | ||
environmentId | ||
} = context; | ||
|
||
return `${siteUrl}/jira/settings/apps/${appId}/${environmentId}`; | ||
}; | ||
|
||
export { | ||
fetchGlobalPageUrl | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 33 additions & 1 deletion
34
app/jenkins-for-jira-ui/src/components/ServerManagement/ServerManagement.styles.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
app/jenkins-for-jira-ui/src/components/ServerManagement/ServerManagement.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import React from 'react'; | ||
import { | ||
render, screen, fireEvent, waitFor | ||
} from '@testing-library/react'; | ||
import { getSiteNameFromUrl, ServerManagement } from './ServerManagement'; | ||
|
||
document.execCommand = jest.fn(); | ||
|
||
describe('ServerManagement Component', () => { | ||
test('should copy to clipboard when "Copy to clipboard" is clicked', async () => { | ||
render(<ServerManagement />); | ||
fireEvent.click(screen.getByText('Share page')); | ||
fireEvent.click(screen.getByText('Copy to clipboard')); | ||
|
||
await waitFor(() => screen.getByText('Copied to clipboard')); | ||
expect(document.execCommand).toHaveBeenCalledWith('copy'); | ||
}); | ||
|
||
test('should close the share modal when "Close" is clicked', async () => { | ||
render(<ServerManagement />); | ||
fireEvent.click(screen.getByText('Share page')); | ||
expect(screen.getByText('Copy to clipboard')).toBeInTheDocument(); | ||
|
||
await waitFor(() => screen.getByText('Close')); | ||
|
||
fireEvent.click(screen.getByText('Close')); | ||
|
||
await waitFor(() => { | ||
expect(screen.queryByText('Copy to clipboard')).not.toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
test('correctly extracts site name from URL', () => { | ||
const url = 'https://testjira.atlassian.net/jira/apps/blah-blah'; | ||
const siteName = getSiteNameFromUrl(url); | ||
expect(siteName).toEqual('testjira.atlassian.net'); | ||
}); | ||
}); |
108 changes: 97 additions & 11 deletions
108
app/jenkins-for-jira-ui/src/components/ServerManagement/ServerManagement.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.