-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Prevent invalid links in update task script #316
Merged
alistairjcbrown
merged 1 commit into
main
from
abrown/prevent-invalid-links-in-update-task-script
May 15, 2023
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
146 changes: 146 additions & 0 deletions
146
scripts/release/tests/__snapshots__/asana-update-tasks.test.js.snap
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,146 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`when all data is available updates each platforms task notes 1`] = ` | ||
[ | ||
[ | ||
"android-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/android/pr/1\\">Android PR</a></li> | ||
|
||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
[ | ||
"bsk-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/BrowserServicesKit/pr/1\\">BrowserServicesKit PR</a></li> | ||
<li><a href=\\"https://github.com/duckduckgo/ios/pr/1\\">iOS PR</a></li><li><a href=\\"https://github.com/duckduckgo/macos-browser/pr/1\\">macOS PR</a></li> | ||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
[ | ||
"ios-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/ios/pr/1\\">iOS PR</a></li> | ||
|
||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
[ | ||
"macos-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/macos-browser/pr/1\\">macOS PR</a></li> | ||
|
||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
[ | ||
"windows-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/windows-browser/pr/1\\">Windows PR</a></li> | ||
|
||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
] | ||
`; | ||
|
||
exports[`when not all PR URLs are available updates each platforms task notes except for missing platforms 1`] = ` | ||
[ | ||
[ | ||
"android-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/android/pr/1\\">Android PR</a></li> | ||
|
||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
[ | ||
"bsk-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/BrowserServicesKit/pr/1\\">BrowserServicesKit PR</a></li> | ||
<li>Error creating iOS PR</li><li><a href=\\"https://github.com/duckduckgo/macos-browser/pr/1\\">macOS PR</a></li> | ||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
[ | ||
"macos-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/macos-browser/pr/1\\">macOS PR</a></li> | ||
|
||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
[ | ||
"windows-123", | ||
{ | ||
"html_notes": "<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li><a href=\\"https://github.com/duckduckgo/windows-browser/pr/1\\">Windows PR</a></li> | ||
|
||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>", | ||
}, | ||
], | ||
] | ||
`; |
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,120 @@ | ||
let mockAsanaClient | ||
jest.mock('asana', () => { | ||
const notes = `<h2>New release:<h2> | ||
<ol> | ||
<li>version [[version]]</li> | ||
<li>[[commit]]</li> | ||
<li>[[release_url]]</li> | ||
<li>[[pr_url]]</li> | ||
<li>[[extra_content]]</li> | ||
</ol> | ||
<h2>Release notes:</h2> | ||
<p>[[notes]]</p>` | ||
|
||
mockAsanaClient = { | ||
useAccessToken: () => mockAsanaClient, | ||
tasks: { | ||
getTask: () => ({ html_notes: notes }), | ||
updateTask: jest.fn() | ||
} | ||
} | ||
return { Client: { create: () => mockAsanaClient } } | ||
}) | ||
|
||
beforeEach(() => { | ||
process.env.ASANA_ACCESS_TOKEN = 'mock-asana-access-token' | ||
process.env.ANDROID_PR_URL = 'https://github.com/duckduckgo/android/pr/1' | ||
process.env.BSK_PR_URL = 'https://github.com/duckduckgo/BrowserServicesKit/pr/1' | ||
process.env.IOS_PR_URL = 'https://github.com/duckduckgo/ios/pr/1' | ||
process.env.MACOS_PR_URL = 'https://github.com/duckduckgo/macos-browser/pr/1' | ||
process.env.WINDOWS_PR_URL = 'https://github.com/duckduckgo/windows-browser/pr/1' | ||
process.env.ASANA_OUTPUT = JSON.stringify({ | ||
'android': { | ||
'displayName': 'Android', | ||
'taskGid': 'android-123', | ||
'taskUrl': 'https://example.com/android-task' | ||
}, | ||
'bsk': { | ||
'displayName': 'BrowserServicesKit', | ||
'taskGid': 'bsk-123', | ||
'taskUrl': 'https://example.com/bsk-task' | ||
}, | ||
'ios': { | ||
'displayName': 'iOS', | ||
'taskGid': 'ios-123', | ||
'taskUrl': 'https://example.com/ios-task' | ||
}, | ||
'macos': { | ||
'displayName': 'macOS', | ||
'taskGid': 'macos-123', | ||
'taskUrl': 'https://example.com/macos-task' | ||
}, | ||
'extensions': { | ||
'displayName': 'Extensions', | ||
'taskGid': 'extension-123', | ||
'taskUrl': 'https://example.com/extension-task' | ||
}, | ||
'windows': { | ||
'displayName': 'Windows', | ||
'taskGid': 'windows-123', | ||
'taskUrl': 'https://example.com/windows-task' | ||
} | ||
}) | ||
}) | ||
|
||
describe('when Asana output is not available', () => { | ||
beforeEach(() => { | ||
process.env.ASANA_OUTPUT = undefined | ||
}) | ||
|
||
it('displays an error message', async () => { | ||
// @ts-ignore | ||
const mockExit = jest.spyOn(process, 'exit').mockImplementation(() => {}) | ||
const mockConsole = jest.spyOn(console, 'error').mockImplementation(() => {}) | ||
jest.isolateModules(() => { | ||
require('../asana-update-tasks.js') | ||
}) | ||
// Wait for update tasks to run | ||
await new Promise((resolve) => setTimeout(resolve, 200)) | ||
|
||
expect(mockExit).toHaveBeenCalledTimes(1) | ||
expect(mockConsole).toHaveBeenCalledTimes(1) | ||
expect(mockConsole.mock.calls).toMatchInlineSnapshot(` | ||
[ | ||
[ | ||
[Error: Unable to parse Asana output JSON], | ||
], | ||
] | ||
`) | ||
}) | ||
}) | ||
|
||
describe('when not all PR URLs are available', () => { | ||
beforeEach(() => { | ||
delete process.env.IOS_PR_URL | ||
}) | ||
|
||
it('updates each platforms task notes except for missing platforms', async () => { | ||
jest.isolateModules(() => { | ||
require('../asana-update-tasks.js') | ||
}) | ||
// Wait for update tasks to run | ||
await new Promise((resolve) => setTimeout(resolve, 200)) | ||
|
||
expect(mockAsanaClient.tasks.updateTask).toBeCalledTimes(4) | ||
expect(mockAsanaClient.tasks.updateTask.mock.calls).toMatchSnapshot() | ||
}) | ||
}) | ||
|
||
describe('when all data is available', () => { | ||
it('updates each platforms task notes', async () => { | ||
jest.isolateModules(() => { | ||
require('../asana-update-tasks.js') | ||
}) | ||
// Wait for update tasks to run | ||
await new Promise((resolve) => setTimeout(resolve, 200)) | ||
|
||
expect(mockAsanaClient.tasks.updateTask).toBeCalledTimes(5) | ||
expect(mockAsanaClient.tasks.updateTask.mock.calls).toMatchSnapshot() | ||
}) | ||
}) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if I've made a mistake here, but it seemed strange that here we didn't replace the wrapping
<li>
, but below we did -- surely we'd want to replace it both times? (either to replace it with the two bullet points created above, or to remove it completely)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mhm, not 100% sure, but we'll see when it runs.