-
Notifications
You must be signed in to change notification settings - Fork 2
Deploy to production 🚀 #646
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
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
0d907a2
Diff sidebar (#607)
oscarlund121 fa9046b
Add scroll-to-change navigation from diff sidebar (#634)
ulrikandersen fbf2e22
Add has-changes indicator for specs in PR branches (#633)
ulrikandersen 0a11200
style: improve diff sidebar layout and colors (#635)
ulrikandersen 1f3f873
fix: pass hasChanges to spec selector for change indicator (#636)
ulrikandersen 5524d29
fix: scroll to change works without operationId for SwaggerUI and Red…
ulrikandersen 04a7219
Bump next from 16.0.7 to 16.0.10 (#638)
dependabot[bot] dbbef79
fix: refresh projects when window regains focus (#639)
ulrikandersen 5e00ecc
feat: add loading indicator when refreshing projects (#640)
ulrikandersen dc61995
fix: preserve scroll position when projects refresh
ulrikandersen f897e1f
Bump the react group with 2 updates
dependabot[bot] 0f61d0c
Bump the everything-else group with 17 updates
dependabot[bot] a1bbbc7
Merge pull request #643 from shapehq/dependabot/npm_and_yarn/react-60…
simonbs d37070e
Merge branch 'develop' into dependabot/npm_and_yarn/everything-else-9…
simonbs 816579e
Merge pull request #644 from shapehq/dependabot/npm_and_yarn/everythi…
simonbs f99db18
Merge pull request #645 from shapehq/hotfix/preserve-scroll-on-projec…
ulrikandersen dfb844c
Rename project configuration filename in .env.example
simonbs af9cdcf
Fixes loading screen shown below documentation
simonbs c23a828
Checks for version and specification
simonbs 6e06dce
Merge pull request #649 from shapehq/bugfix/loading-screen-shown-belo…
simonbs fc9a9da
Merge branch 'develop' into update-env-example
ulrikandersen b7296dc
Merge pull request #647 from shapehq/update-env-example
ulrikandersen 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,142 @@ | ||
| import { OasDiffCalculator } from "../../src/features/diff/data/OasDiffCalculator" | ||
| import IGitHubClient from "../../src/common/github/IGitHubClient" | ||
|
|
||
| const createMockGitHubClient = ( | ||
| baseUrl: string, | ||
| headUrl: string, | ||
| mergeBaseSha = "abc123" | ||
| ): IGitHubClient => ({ | ||
| async compareCommitsWithBasehead() { | ||
| return { mergeBaseSha } | ||
| }, | ||
| async getRepositoryContent(request) { | ||
| if (request.ref === mergeBaseSha) { | ||
| return { downloadURL: baseUrl } | ||
| } | ||
| return { downloadURL: headUrl } | ||
| }, | ||
| async graphql() { | ||
| return {} | ||
| }, | ||
| async getPullRequestFiles() { | ||
| return [] | ||
| }, | ||
| async getPullRequestComments() { | ||
| return [] | ||
| }, | ||
| async addCommentToPullRequest() {}, | ||
| async updatePullRequestComment() {} | ||
| }) | ||
|
|
||
| test("It rejects non-GitHub URLs for base spec", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "https://malicious-site.com/file.yaml", | ||
| "https://raw.githubusercontent.com/owner/repo/main/file.yaml" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| await expect( | ||
| calculator.calculateDiff("owner", "repo", "path.yaml", "base", "head") | ||
| ).rejects.toThrow("Invalid URL for base spec") | ||
| }) | ||
|
|
||
| test("It rejects invalid URLs", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "not-a-valid-url", | ||
| "https://raw.githubusercontent.com/owner/repo/main/file.yaml" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| await expect( | ||
| calculator.calculateDiff("owner", "repo", "path.yaml", "base", "head") | ||
| ).rejects.toThrow("Invalid URL for base spec") | ||
| }) | ||
|
|
||
| test("It accepts raw.githubusercontent.com URLs", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "https://raw.githubusercontent.com/owner/repo/main/file1.yaml", | ||
| "https://raw.githubusercontent.com/owner/repo/main/file2.yaml" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| // This will fail when trying to execute oasdiff, but that's expected | ||
| // We're only testing that URL validation passes | ||
| await expect( | ||
| calculator.calculateDiff("owner", "repo", "path.yaml", "base", "head") | ||
| ).rejects.toThrow("Failed to execute OpenAPI diff tool") | ||
| }) | ||
|
|
||
| test("It accepts github.com URLs", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "https://github.com/owner/repo/raw/main/file1.yaml", | ||
| "https://github.com/owner/repo/raw/main/file2.yaml" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| // This will fail when trying to execute oasdiff, but that's expected | ||
| // We're only testing that URL validation passes | ||
| await expect( | ||
| calculator.calculateDiff("owner", "repo", "path.yaml", "base", "head") | ||
| ).rejects.toThrow("Failed to execute OpenAPI diff tool") | ||
| }) | ||
|
|
||
| test("It accepts api.github.com URLs", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "https://api.github.com/repos/owner/repo/contents/file1.yaml", | ||
| "https://api.github.com/repos/owner/repo/contents/file2.yaml" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| // This will fail when trying to execute oasdiff, but that's expected | ||
| // We're only testing that URL validation passes | ||
| await expect( | ||
| calculator.calculateDiff("owner", "repo", "path.yaml", "base", "head") | ||
| ).rejects.toThrow("Failed to execute OpenAPI diff tool") | ||
| }) | ||
|
|
||
| test("It rejects URLs with GitHub-like subdomains but different domains", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "https://raw.githubusercontent.com.evil.com/file.yaml", | ||
| "https://raw.githubusercontent.com/owner/repo/main/file.yaml" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| await expect( | ||
| calculator.calculateDiff("owner", "repo", "path.yaml", "base", "head") | ||
| ).rejects.toThrow("Invalid URL for base spec") | ||
| }) | ||
|
|
||
| test("It validates both base and head URLs", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "https://raw.githubusercontent.com/owner/repo/main/file1.yaml", | ||
| "https://malicious-site.com/file.yaml" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| await expect( | ||
| calculator.calculateDiff("owner", "repo", "path.yaml", "base", "head") | ||
| ).rejects.toThrow("Invalid URL for head spec") | ||
| }) | ||
|
|
||
| test("It returns empty changes when comparing same refs", async () => { | ||
| const mockGitHubClient = createMockGitHubClient( | ||
| "https://raw.githubusercontent.com/owner/repo/main/file1.yaml", | ||
| "https://raw.githubusercontent.com/owner/repo/main/file2.yaml", | ||
| "abc123" | ||
| ) | ||
| const calculator = new OasDiffCalculator(mockGitHubClient) | ||
|
|
||
| const result = await calculator.calculateDiff( | ||
| "owner", | ||
| "repo", | ||
| "path.yaml", | ||
| "abc123", | ||
| "abc123" | ||
| ) | ||
|
|
||
| expect(result).toEqual({ | ||
| from: "abc123", | ||
| to: "abc123", | ||
| changes: [] | ||
| }) | ||
| }) |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.