Skip to content

Commit feb2fb4

Browse files
committed
Merge branch 'next' into develop
2 parents 59c41ed + bb51a1f commit feb2fb4

File tree

165 files changed

+6023
-8325
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

165 files changed

+6023
-8325
lines changed

.env.example

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# The client ID you received from GitHub for your GitHub App.
21
GITHUB_OAUTH_CLIENT_ID=GITHUB_OAUTH_CLIENT_ID
3-
4-
# The client secret you received from GitHub for your GitHub App.
52
GITHUB_OAUTH_CLIENT_SECRET=GITHUB_OAUTH_CLIENT_SECRET
3+
4+
SENTRY_PUBLIC_KEY=SENTRY_PUBLIC_KEY
5+
SENTRY_PROJECT_ID=SENTRY_PROJECT_ID

.github/workflows/ci.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ jobs:
2929
id: yarn-cache-dir-path
3030
run: echo "::set-output name=dir::$(yarn cache dir)"
3131

32-
- name: Cache deps
32+
- name: Cache Dependencies
3333
uses: actions/cache@v1
3434
id: yarn-cache
3535
with:
@@ -38,7 +38,7 @@ jobs:
3838
restore-keys: |
3939
${{ runner.os }}-yarn-
4040
41-
- name: Install deps
41+
- name: Install Dependencies
4242
env:
4343
PUPPETEER_SKIP_CHROMIUM_DOWNLOAD: true
4444
run: |
@@ -48,7 +48,11 @@ jobs:
4848
run: |
4949
make build
5050
51-
- name: Test
51+
- name: Unit Test
52+
run: |
53+
yarn jest src
54+
55+
- name: E2E Test
5256
uses: mujo-code/puppeteer-headful@master
5357
env:
5458
CI: 'true'

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/usr/bin/env sh
2+
. "$(dirname -- "$0")/_/husky.sh"
3+
4+
yarn lint-staged --quiet

.prettierignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
*-profile/
22
dist/
33
vscode-icons/
4+
Safari

__tests__/cases/non-parallel/pjax.commits-page.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { expectToFind, expectToNotFind, sleep, waitForLegacyPJAXRedirect } from '../../utils'
1+
import { expectToFind, expectToNotFind, sleep, waitForRedirect } from '../../utils'
22

33
describe(`in Gitako project page`, () => {
44
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/commits/develop'))
@@ -10,7 +10,7 @@ describe(`in Gitako project page`, () => {
1010
)
1111
if (commitLinks.length < 2) throw new Error(`No enough commits`)
1212
commitLinks[i].click()
13-
await waitForLegacyPJAXRedirect()
13+
await waitForRedirect()
1414
await expectToFind('div.commit')
1515
await sleep(1000)
1616

__tests__/cases/non-parallel/pjax.files-page.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
1-
import { expectToFind, expectToNotFind, sleep, waitForLegacyPJAXRedirect } from '../../utils'
1+
import {
2+
expectToFind,
3+
expectToNotFind,
4+
sleep, waitForRedirect
5+
} from '../../utils'
26

37
describe(`in Gitako project page`, () => {
48
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/tree/develop/src'))
@@ -9,7 +13,7 @@ describe(`in Gitako project page`, () => {
913
`.js-details-container div[role="row"] div[role="rowheader"] a[title*="."]`,
1014
)
1115
if (commitLinks.length < 2) throw new Error(`No enough files`)
12-
await waitForLegacyPJAXRedirect(async () => {
16+
await waitForRedirect(async () => {
1317
await commitLinks[i].click()
1418
})
1519
await expectToFind('table.js-file-line-container')

__tests__/cases/non-parallel/pjax.general.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import {
33
expandFloatModeSidebar,
44
patientClick,
55
selectFileTreeItem,
6-
sleep,
7-
waitForLegacyPJAXRedirect
6+
sleep, waitForRedirect
87
} from '../../utils'
98

109
describe(`in Gitako project page`, () => {
@@ -15,14 +14,14 @@ describe(`in Gitako project page`, () => {
1514

1615
await expandFloatModeSidebar()
1716
await patientClick(selectFileTreeItem('src/analytics.ts'))
18-
await waitForLegacyPJAXRedirect()
17+
await waitForRedirect()
1918
await collapseFloatModeSidebar()
2019

2120
await page.click('a[data-selected-links^="repo_issues "]')
22-
await waitForLegacyPJAXRedirect()
21+
await waitForRedirect()
2322

2423
await page.click('a[data-selected-links^="repo_pulls "]')
25-
await waitForLegacyPJAXRedirect()
24+
await waitForRedirect()
2625

2726
page.goBack()
2827
await sleep(1000)

__tests__/cases/non-parallel/pjax.internal.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ import {
44
expectToNotFind,
55
patientClick,
66
selectFileTreeItem,
7-
sleep,
8-
waitForLegacyPJAXRedirect
7+
sleep, waitForRedirect
98
} from '../../utils'
109

1110
describe(`in Gitako project page`, () => {
@@ -16,12 +15,12 @@ describe(`in Gitako project page`, () => {
1615

1716
await expandFloatModeSidebar()
1817
await patientClick(selectFileTreeItem('.babelrc'))
19-
await waitForLegacyPJAXRedirect()
18+
await waitForRedirect()
2019

2120
// The selector for file content
2221
await expectToFind('table.js-file-line-container')
2322

24-
await waitForLegacyPJAXRedirect(async () => {
23+
await waitForRedirect(async () => {
2524
await sleep(1000) // This prevents failing in some cases due to some mystery scheduling issue of puppeteer or jest
2625
page.goBack()
2726
})

__tests__/cases/non-parallel/project-page.gitako.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ import {
77
} from '../../utils'
88

99
describe(`in Gitako project page`, () => {
10-
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/tree/test/200-changed-files-200-lines-each'))
10+
beforeAll(() =>
11+
page.goto('https://github.com/EnixCoda/Gitako/tree/test/200-changed-files-200-lines-each'),
12+
)
1113

1214
it('should render Gitako', async () => {
1315
await expectToFind('.gitako-side-bar .gitako-side-bar-body-wrapper')
@@ -26,7 +28,7 @@ describe(`in Gitako project page`, () => {
2628
const box = await filesEle?.boundingBox()
2729
if (box) {
2830
await page.mouse.move(box.x + 40, box.y + 40)
29-
await scroll({ totalDistance: 7000, stepDistance: 100 })
31+
await scroll({ totalDistance: 10000, stepDistance: 100 })
3032

3133
// node of tsconfig.json should be rendered now
3234
await expectToFind(selectFileTreeItem('tsconfig.json'))

__tests__/cases/parallel/expand-to-target.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
1-
import {
2-
expectToFind,
3-
selectFileTreeItem,
4-
sleep,
5-
waitForLegacyPJAXRedirect
6-
} from '../../utils'
1+
import { expectToFind, selectFileTreeItem, sleep, waitForRedirect } from '../../utils'
72

83
describe(`in Gitako project page`, () => {
94
beforeAll(() => page.goto('https://github.com/EnixCoda/Gitako/tree/develop/src'))
105

11-
it('expand to target on load and after PJAX', async () => {
6+
it('expand to target on load and after redirect', async () => {
127
await sleep(3000)
138

149
// Expect Gitako sidebar to have expanded src to see contents
@@ -17,7 +12,7 @@ describe(`in Gitako project page`, () => {
1712
await page.click(
1813
`.js-details-container div[role="row"] div[role="rowheader"] [title="components"]`,
1914
)
20-
await waitForLegacyPJAXRedirect()
15+
await waitForRedirect()
2116

2217
// Expect Gitako sidebar to have expanded components and see contents
2318
await expectToFind(selectFileTreeItem('src/components/Gitako.tsx'))

__tests__/utils.ts

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export async function listenTo<Args extends any[] = any[]>(
4040
(event, target, callbackName, oneTime) => {
4141
const t = target === 'document' ? document : window
4242
const onEvent = (...args: any[]): void => {
43-
;((window[callbackName as any] as any) as (...args: any[]) => void)(...args)
43+
;(window[callbackName as any] as any as (...args: any[]) => void)(...args)
4444
if (oneTime) t.removeEventListener(event, onEvent)
4545
}
4646
t.addEventListener(event, onEvent)
@@ -71,6 +71,24 @@ export async function waitForLegacyPJAXRedirect(action?: () => void | Promise<vo
7171
return promise
7272
}
7373

74+
export async function waitForTurboRedirect(action?: () => void | Promise<void>) {
75+
const promise = once('turbo:load', 'document')
76+
await action?.()
77+
return promise
78+
}
79+
80+
export async function waitForRedirect(action?: () => void | Promise<void>) {
81+
let fired = false
82+
const $action =
83+
action &&
84+
(() => {
85+
if (fired) return
86+
fired = true
87+
return action()
88+
})
89+
return Promise.race([waitForLegacyPJAXRedirect($action), waitForTurboRedirect($action)])
90+
}
91+
7492
export function selectFileTreeItem(path: string): string {
7593
return `.gitako-side-bar .files a[title="${path}"]`
7694
}
@@ -81,7 +99,9 @@ export async function patientClick(selector: string) {
8199
}
82100

83101
export async function expandFloatModeSidebar() {
84-
const rect = await (await page.$('.gitako-toggle-show-button'))?.evaluate(button => {
102+
const rect = await (
103+
await page.$('.gitako-toggle-show-button')
104+
)?.evaluate(button => {
85105
const { x, y, width, height } = button.getBoundingClientRect()
86106
// pass required properties to avoid serialization issues
87107
return { x, y, width, height }

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ module.exports = {
130130
// snapshotSerializers: [],
131131

132132
// The test environment that will be used for testing
133-
// testEnvironment: 'node',
133+
testEnvironment: 'jsdom',
134134

135135
// Options that will be passed to the testEnvironment
136136
// testEnvironmentOptions: {},

0 commit comments

Comments
 (0)