-
Notifications
You must be signed in to change notification settings - Fork 60
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1334 from nextstrain/feat/web-revamp-url-params
- Loading branch information
Showing
18 changed files
with
1,686 additions
and
490 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
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 |
---|---|---|
|
@@ -33,6 +33,9 @@ export const URL_CLADE_SCHEMA_REPO = 'https://github.com/nextstrain/ncov-clades- | |
export const URL_CLADE_SCHEMA_SVG = 'https://raw.githubusercontent.com/nextstrain/ncov-clades-schema/master/clades.svg' | ||
|
||
export const URL_GITHUB_DATA_RAW = 'https://raw.githubusercontent.com/nextstrain/nextclade_data' as const | ||
export const DEFAULT_DATA_OWNER = 'nextstrain' as const | ||
export const DEFAULT_DATA_REPO = 'nextclade_data' as const | ||
export const DEFAULT_DATA_REPO_PATH = 'data_output' as const | ||
|
||
export const SUPPORT_EMAIL = '[email protected]' | ||
|
||
|
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,5 @@ | ||
export class ErrorFatal extends Error { | ||
public constructor(message: string) { | ||
super(message) | ||
} | ||
} |
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,3 @@ | ||
export function getTestName(): string { | ||
return expect.getState().currentTestName.split(' ')[1] | ||
} |
78 changes: 78 additions & 0 deletions
78
packages_rs/nextclade-web/src/io/__tests__/getDatasetServerUrl.test.ts
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,78 @@ | ||
import { getDatasetServerUrl } from 'src/io/fetchDatasets' | ||
|
||
describe('parseGitHubRepoShortcut', () => { | ||
const OLD_ENV = process.env | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
process.env = { ...OLD_ENV, BRANCH_NAME: 'default-branch' } | ||
}) | ||
|
||
afterAll(() => { | ||
process.env = OLD_ENV | ||
}) | ||
|
||
it.each([ | ||
['gh', 'https://raw.githubusercontent.com/nextstrain/nextclade_data/default-branch/data_output'], | ||
['gh:', 'https://raw.githubusercontent.com/nextstrain/nextclade_data/default-branch/data_output'], | ||
['gh', 'https://raw.githubusercontent.com/nextstrain/nextclade_data/default-branch/data_output'], | ||
['gh:', 'https://raw.githubusercontent.com/nextstrain/nextclade_data/default-branch/data_output'], | ||
['gh:@test-branch@', 'https://raw.githubusercontent.com/nextstrain/nextclade_data/test-branch/data_output'], | ||
['gh:aaa/bbb', 'https://raw.githubusercontent.com/aaa/bbb/master/'], | ||
['gh:aaa/bbb/', 'https://raw.githubusercontent.com/aaa/bbb/master/'], | ||
['gh:aaa/bbb@test-branch@', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/'], | ||
['gh:aaa/bbb@test-branch@my/path/dir', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/my/path/dir'], | ||
['gh:aaa/bbb@test-branch@/my/path/dir', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/my/path/dir'], | ||
['gh:aaa/bbb@test-branch@my/path/dir/', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/my/path/dir'], | ||
['gh:aaa/bbb@test-branch@/my/path/dir/', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/my/path/dir'], | ||
['gh:aaa/bbb@branch/slashes@/my/path/dir', 'https://raw.githubusercontent.com/aaa/bbb/branch/slashes/my/path/dir'], | ||
['https://github.com/aaa/bbb', 'https://raw.githubusercontent.com/aaa/bbb/master/'], | ||
['https://github.com/aaa/bbb/', 'https://raw.githubusercontent.com/aaa/bbb/master/'], | ||
['https://github.com/aaa/bbb/tree/test-branch', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/'], | ||
['https://github.com/aaa/bbb/tree/test-branch/', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/'], | ||
[ | ||
'https://github.com/aaa/bbb/tree/test-branch/dirname', | ||
'https://raw.githubusercontent.com/aaa/bbb/test-branch/dirname', | ||
], | ||
[ | ||
'https://github.com/aaa/bbb/tree/test-branch/dirname/', | ||
'https://raw.githubusercontent.com/aaa/bbb/test-branch/dirname', | ||
], | ||
[ | ||
'https://github.com/aaa/bbb/tree/test-branch/dirname//', | ||
'https://raw.githubusercontent.com/aaa/bbb/test-branch/dirname', | ||
], | ||
['https://github.com/aaa/bbb/blob/test-branch', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/'], | ||
['https://github.com/aaa/bbb/blob/test-branch/', 'https://raw.githubusercontent.com/aaa/bbb/test-branch/'], | ||
[ | ||
'https://github.com/aaa/bbb/blob/test-branch/dirname', | ||
'https://raw.githubusercontent.com/aaa/bbb/test-branch/dirname', | ||
], | ||
[ | ||
'https://github.com/aaa/bbb/blob/test-branch/my/path/dir/', | ||
'https://raw.githubusercontent.com/aaa/bbb/test-branch/my/path/dir', | ||
], | ||
[ | ||
'https://github.com/aaa/bbb/blob/test-branch/dirname/filename.json', | ||
'https://raw.githubusercontent.com/aaa/bbb/test-branch/dirname/filename.json', | ||
], | ||
[ | ||
'https://github.com/aaa/bbb/blob/branch/slashes/dirname/filename.json', | ||
'https://raw.githubusercontent.com/aaa/bbb/branch/slashes/dirname/filename.json', | ||
], | ||
[ | ||
'https://github.com/aaa/bbb/blob/test-branch/dirname//', | ||
'https://raw.githubusercontent.com/aaa/bbb/test-branch/dirname', | ||
], | ||
[ | ||
'https://github.com/nextstrain/nextclade_data/tree/master/data_output/nextstrain/rsv/a/EPI_ISL_412866/unreleased', | ||
'https://raw.githubusercontent.com/nextstrain/nextclade_data/master/data_output/nextstrain/rsv/a/EPI_ISL_412866/unreleased', | ||
], | ||
[ | ||
'https://github.com/nextstrain/nextclade_data/tree/release/data_output/nextstrain/rsv/a/EPI_ISL_412866/unreleased', | ||
'https://raw.githubusercontent.com/nextstrain/nextclade_data/release/data_output/nextstrain/rsv/a/EPI_ISL_412866/unreleased', | ||
], | ||
])('%p', async (input: string, result: string) => { | ||
expect(await getDatasetServerUrl({ 'dataset-server': input })).toBe(result) | ||
}) | ||
}) |
106 changes: 106 additions & 0 deletions
106
packages_rs/nextclade-web/src/io/__tests__/parseGitHubRepoShortcut.test.ts
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,106 @@ | ||
import { DEFAULT_DATA_OWNER, DEFAULT_DATA_REPO, DEFAULT_DATA_REPO_PATH } from 'src/constants' | ||
import { getTestName } from 'src/helpers/jestUtils' | ||
import { parseGitHubRepoShortcut } from 'src/io/fetchSingleDatasetFromGithub' | ||
|
||
describe('parseGitHubRepoShortcut', () => { | ||
const OLD_ENV = process.env | ||
|
||
beforeEach(() => { | ||
jest.resetModules() | ||
process.env = { ...OLD_ENV, BRANCH_NAME: 'default-branch' } | ||
}) | ||
|
||
afterAll(() => { | ||
process.env = OLD_ENV | ||
}) | ||
|
||
it('gh', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: DEFAULT_DATA_OWNER, | ||
repo: DEFAULT_DATA_REPO, | ||
branch: 'default-branch', | ||
path: DEFAULT_DATA_REPO_PATH, | ||
}) | ||
}) | ||
|
||
it('gh:', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: DEFAULT_DATA_OWNER, | ||
repo: DEFAULT_DATA_REPO, | ||
branch: 'default-branch', | ||
path: DEFAULT_DATA_REPO_PATH, | ||
}) | ||
}) | ||
|
||
it('gh:@test-branch@', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: DEFAULT_DATA_OWNER, | ||
repo: DEFAULT_DATA_REPO, | ||
branch: 'test-branch', | ||
path: DEFAULT_DATA_REPO_PATH, | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'default-branch', | ||
path: '/', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb/', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'default-branch', | ||
path: '/', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: '/', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@my/path/dir', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@/my/path/dir', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@my/path/dir/', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@/my/path/dir/', async () => { | ||
expect(await parseGitHubRepoShortcut(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
}) |
148 changes: 148 additions & 0 deletions
148
packages_rs/nextclade-web/src/io/__tests__/parseGitHubRepoShortcutComponents.test.ts
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,148 @@ | ||
import { getTestName } from 'src/helpers/jestUtils' | ||
import { parseGitHubRepoShortcutComponents } from 'src/io/fetchSingleDatasetFromGithub' | ||
|
||
describe('parseGitHubRepoShortcutComponents', () => { | ||
it('gh', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: undefined, | ||
repo: undefined, | ||
branch: undefined, | ||
path: undefined, | ||
}) | ||
}) | ||
|
||
it('gh:', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: undefined, | ||
repo: undefined, | ||
branch: undefined, | ||
path: undefined, | ||
}) | ||
}) | ||
|
||
it('gh:@test-branch@', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: undefined, | ||
repo: undefined, | ||
branch: 'test-branch', | ||
path: undefined, | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: undefined, | ||
path: undefined, | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb/', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: undefined, | ||
path: '/', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: undefined, | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@branch/slashes@', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'branch/slashes', | ||
path: undefined, | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@branch/more/slashes@', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'branch/more/slashes', | ||
path: undefined, | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@my/path/dir', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@/my/path/dir', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@branch/slashes@/my/path/dir', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'branch/slashes', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@branch/more/slashes@/my/path/dir', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'branch/more/slashes', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@my/path/dir/', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb@test-branch@/my/path/dir/', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: 'test-branch', | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb/my/path/dir', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: undefined, | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
|
||
it('gh:aaa/bbb/my/path/dir/', async () => { | ||
expect(parseGitHubRepoShortcutComponents(getTestName())).toStrictEqual({ | ||
owner: 'aaa', | ||
repo: 'bbb', | ||
branch: undefined, | ||
path: 'my/path/dir', | ||
}) | ||
}) | ||
}) |
Oops, something went wrong.
639f3eb
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.
Successfully deployed to the following URLs:
nextclade – ./
nextclade.vercel.app
nextclade-git-master-nextstrain.vercel.app
nextclade-nextstrain.vercel.app