mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
Merge branch 'develop' into manifest-v3
# Conflicts: # package.json # webpack.config.js # yarn.lock
This commit is contained in:
commit
6fe3135ae8
24 changed files with 1437 additions and 892 deletions
2
.github/workflows/tests.yml
vendored
2
.github/workflows/tests.yml
vendored
|
|
@ -53,7 +53,7 @@ jobs:
|
|||
yarn --ignore-platform --ignore-engines --frozen-lockfile --prefer-offline
|
||||
|
||||
- name: E2E Test
|
||||
uses: mujo-code/puppeteer-headful@master
|
||||
uses: mymindstorm/puppeteer-headful@8f745c770f7f4c0f9f332d7c43a775f90e53779a
|
||||
env:
|
||||
CI: 'true'
|
||||
with:
|
||||
|
|
|
|||
|
|
@ -579,7 +579,7 @@
|
|||
"@executable_path/../../../../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MARKETING_VERSION = 3.12.0;
|
||||
MARKETING_VERSION = 3.12.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
|
@ -604,7 +604,7 @@
|
|||
"@executable_path/../../../../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MARKETING_VERSION = 3.12.0;
|
||||
MARKETING_VERSION = 3.12.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako.Extension;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
|
@ -631,7 +631,7 @@
|
|||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MARKETING_VERSION = 3.12.0;
|
||||
MARKETING_VERSION = 3.12.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution";
|
||||
|
|
@ -657,7 +657,7 @@
|
|||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 10.14;
|
||||
MARKETING_VERSION = 3.12.0;
|
||||
MARKETING_VERSION = 3.12.1;
|
||||
PRODUCT_BUNDLE_IDENTIFIER = enixcoda.Gitako;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "Developer Sign for Distribution";
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
* Confirm basic behaviors of puppeteer assertions
|
||||
*/
|
||||
|
||||
import { testURL } from '../../testURL'
|
||||
import { expectToFind, expectToNotFind } from '../../utils'
|
||||
import { testURL } from '../testURL'
|
||||
import { expectToFind, expectToNotFind, expectToReject } from '../utils'
|
||||
|
||||
describe(`in random page`, () => {
|
||||
beforeAll(() => page.goto(testURL`https://google.com`))
|
||||
|
|
@ -23,7 +23,7 @@ describe(`in random page`, () => {
|
|||
})
|
||||
|
||||
it('wait for non-exist element reject should throw', async () => {
|
||||
await expect(page.waitForSelector('.non-exist-element', { timeout: 1000 })).rejects.toThrow()
|
||||
await expectToReject(page.waitForSelector('.non-exist-element', { timeout: 1000 }))
|
||||
})
|
||||
|
||||
// Cases below are expected to fail to show how async test works
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { getTextContent, sleep } from '../../utils'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import { getTextContent, sleep } from '../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
beforeAll(() => page.goto(testURL`https://github.com/GitakoExtension/test-empty`))
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { expectToFind, sleep, waitForRedirect } from '../../utils'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import { expectToFind, sleep, waitForRedirect } from '../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
beforeAll(() => page.goto(testURL`https://github.com/EnixCoda/Gitako/tree/develop/src`))
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { testURL } from '../../testURL'
|
||||
import { expectToNotFind } from '../../utils'
|
||||
import { testURL } from '../testURL'
|
||||
import { expectToNotFind } from '../utils'
|
||||
|
||||
describe(`in GitHub homepage`, () => {
|
||||
beforeAll(() => page.goto(testURL`https://github.com`))
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { expectToFind, expectToNotFind, sleep, waitForRedirect } from '../../utils'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import { expectToFind, expectToNotFind, sleep, waitForRedirect } from '../utils'
|
||||
|
||||
jest.retryTimes(3)
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { expectToFind, expectToNotFind, sleep, waitForRedirect } from '../../utils'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import { expectToFind, expectToNotFind, sleep, waitForRedirect } from '../utils'
|
||||
|
||||
jest.retryTimes(3)
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import {
|
||||
collapseFloatModeSidebar,
|
||||
expandFloatModeSidebar,
|
||||
|
|
@ -7,7 +7,7 @@ import {
|
|||
patientClick,
|
||||
sleep,
|
||||
waitForRedirect,
|
||||
} from '../../utils'
|
||||
} from '../utils'
|
||||
|
||||
jest.retryTimes(3)
|
||||
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import {
|
||||
expandFloatModeSidebar,
|
||||
expectToFind,
|
||||
|
|
@ -7,7 +7,7 @@ import {
|
|||
patientClick,
|
||||
sleep,
|
||||
waitForRedirect,
|
||||
} from '../../utils'
|
||||
} from '../utils'
|
||||
|
||||
jest.retryTimes(3)
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { expandFloatModeSidebar, expectToFind, expectToNotFind, scroll } from '../../utils'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import { expandFloatModeSidebar, expectToFind, expectToNotFind, scroll } from '../utils'
|
||||
|
||||
jest.retryTimes(3)
|
||||
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
import { selectors } from '../../selectors'
|
||||
import { testURL } from '../../testURL'
|
||||
import { expectToFind } from '../../utils'
|
||||
import { selectors } from '../selectors'
|
||||
import { testURL } from '../testURL'
|
||||
import { expectToFind } from '../utils'
|
||||
|
||||
describe(`in Gitako project page`, () => {
|
||||
beforeAll(() => page.goto(testURL`https://github.com/EnixCoda/Gitako/pull/71`))
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
const baseConfig = require('./jest.config')
|
||||
|
||||
/**
|
||||
* @type {import('@jest/types').Config.InitialOptions}
|
||||
*/
|
||||
module.exports = {
|
||||
...baseConfig,
|
||||
maxWorkers: 1,
|
||||
testMatch: [...baseConfig.testMatch, '**/__tests__/cases/non-parallel/*.ts?(x)'],
|
||||
setupFilesAfterEnv: ['<rootDir>/setup.ts'],
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
const baseConfig = require('./jest.config')
|
||||
|
||||
module.exports = {
|
||||
...baseConfig,
|
||||
testMatch: [...baseConfig.testMatch, '**/__tests__/cases/parallel/*.ts?(x)'],
|
||||
}
|
||||
7
__tests__/jest.puppeteer.config.js
Normal file
7
__tests__/jest.puppeteer.config.js
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
const baseConfig = require('./jest.config')
|
||||
|
||||
module.exports = {
|
||||
...baseConfig,
|
||||
testMatch: [...baseConfig.testMatch, '**/__tests__/cases/**/*.ts?(x)'],
|
||||
setupFilesAfterEnv: ['<rootDir>/setup.ts'],
|
||||
}
|
||||
|
|
@ -2,7 +2,7 @@ export const selectors = {
|
|||
github: {
|
||||
breadcrumbFileName: `[data-testid="breadcrumbs-filename"]`,
|
||||
fileContent: 'textarea[aria-label="file content"]',
|
||||
commitLinks: `li[data-testid="commit-row-item"] [data-testid="listview-item-title-container"] a[href*="/commit/"]`,
|
||||
commitLinks: `li[data-testid="commit-row-item"] [data-testid="list-view-item-title-container"] a[href*="/commit/"]`,
|
||||
// assume title contains `.` is file item
|
||||
fileListItemFileLinks: `table[aria-labelledby="folders-and-files"] tr.react-directory-row td.react-directory-row-name-cell-large-screen .react-directory-filename-column .react-directory-truncate a[aria-label$="(File)"]`,
|
||||
fileListItemLinkOf: (name: string) =>
|
||||
|
|
|
|||
|
|
@ -1,9 +1,21 @@
|
|||
export async function expectToResolve<T>(promise: Promise<T>) {
|
||||
const pass = jest.fn()
|
||||
await promise.then(pass)
|
||||
expect(pass).toHaveBeenCalled()
|
||||
}
|
||||
|
||||
export async function expectToReject<T>(promise: Promise<T>) {
|
||||
const pass = jest.fn()
|
||||
await promise.catch(pass)
|
||||
expect(pass).toHaveBeenCalled()
|
||||
}
|
||||
|
||||
export async function expectToFind(selector: string) {
|
||||
await expect(page.waitForSelector(selector)).resolves.not.toBeNull()
|
||||
await expectToResolve(page.waitForSelector(selector))
|
||||
}
|
||||
|
||||
export async function expectToNotFind(selector: string) {
|
||||
await expect(page.waitForSelector(selector, { timeout: 1000 })).rejects.toThrow()
|
||||
await expectToReject(page.waitForSelector(selector, { timeout: 1000 }))
|
||||
}
|
||||
|
||||
export function sleep(timeout: number) {
|
||||
|
|
|
|||
|
|
@ -12,6 +12,10 @@ module.exports = {
|
|||
executablePath: process.env.PUPPETEER_EXEC_PATH,
|
||||
// required for enabling extensions
|
||||
headless: false,
|
||||
args: [`--disable-extensions-except=${CRX_PATH}`, `--load-extension=${CRX_PATH}`],
|
||||
args: [
|
||||
`--no-sandbox`,
|
||||
`--disable-extensions-except=${CRX_PATH}`,
|
||||
`--load-extension=${CRX_PATH}`,
|
||||
],
|
||||
},
|
||||
}
|
||||
|
|
|
|||
23
package.json
23
package.json
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "gitako",
|
||||
"version": "3.12.0",
|
||||
"version": "3.12.1",
|
||||
"description": "File tree for GitHub, and more than that.",
|
||||
"repository": "https://github.com/EnixCoda/Gitako",
|
||||
"author": "EnixCoda",
|
||||
|
|
@ -17,10 +17,8 @@
|
|||
"postversion": "sh scripts/post-version.sh",
|
||||
"build": "NODE_OPTIONS=--openssl-legacy-provider VERSION=v$(node scripts/get-version.js) NODE_ENV=production webpack",
|
||||
"roll": "make release",
|
||||
"test": "yarn run test:parallel && yarn run test:non-parallel",
|
||||
"test:unit": "NODE_ENV=test jest --config jest.config.js",
|
||||
"test:parallel": "NODE_ENV=test jest --config __tests__/jest.parallel.config.js",
|
||||
"test:non-parallel": "NODE_ENV=test jest --config __tests__/jest.non-parallel.config.js"
|
||||
"test": "NODE_ENV=test jest --config __tests__/jest.puppeteer.config.js",
|
||||
"test:unit": "NODE_ENV=test jest --config jest.config.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"@primer/css": "^20.4.3",
|
||||
|
|
@ -47,8 +45,8 @@
|
|||
"react-window": "^1.8.7",
|
||||
"styled-components": "^5.3.5",
|
||||
"superstruct": "^1.0.3",
|
||||
"webext-domain-permission-toggle": "^3.0.0",
|
||||
"webext-dynamic-content-scripts": "^9.0.0",
|
||||
"webext-permission-toggle": "^5.0.2",
|
||||
"webextension-polyfill": "^0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
|
|
@ -61,9 +59,10 @@
|
|||
"@babel/preset-typescript": "^7.16.7",
|
||||
"@sentry/cli": "^1.64.2",
|
||||
"@testing-library/react": "^13.3.0",
|
||||
"@types/jest": "^29.2.2",
|
||||
"@types/firefox-webext-browser": "^70.0.1",
|
||||
"@types/jest": "^29.5.12",
|
||||
"@types/node": "^11.10.4",
|
||||
"@types/puppeteer": "^5.4.3",
|
||||
"@types/puppeteer": "^7.0.4",
|
||||
"@typescript-eslint/eslint-plugin": "^5.33.1",
|
||||
"@typescript-eslint/parser": "^5.33.1",
|
||||
"babel-loader": "^8.2.5",
|
||||
|
|
@ -79,14 +78,14 @@
|
|||
"file-loader": "^3.0.1",
|
||||
"fork-ts-checker-webpack-plugin": "^6.5.0",
|
||||
"husky": "^8.0.1",
|
||||
"jest": "^29.2.2",
|
||||
"jest-environment-jsdom": "^29.2.2",
|
||||
"jest-puppeteer": "^6.1.0",
|
||||
"jest": "^29.7.0",
|
||||
"jest-environment-jsdom": "^29.7.0",
|
||||
"jest-puppeteer": "^10.0.1",
|
||||
"json-loader": "^0.5.7",
|
||||
"lint-staged": "^13.0.3",
|
||||
"mini-css-extract-plugin": "^0.9.0",
|
||||
"prettier": "^2.8.3",
|
||||
"puppeteer": "^10.1.0",
|
||||
"puppeteer": "^22.12.1",
|
||||
"raw-loader": "^4.0.0",
|
||||
"sass": "^1.26.2",
|
||||
"sass-loader": "^8.0.2",
|
||||
|
|
|
|||
|
|
@ -38,7 +38,6 @@ async function fixDeps() {
|
|||
for (const fix of [
|
||||
require('./pjax-api').fix,
|
||||
require('./styled-components').fix,
|
||||
require('./webext-domain-permission-toggle').fix,
|
||||
require('./@primer__behaviors').fix,
|
||||
]) {
|
||||
await fix()
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
const { fixDep } = require('.')
|
||||
|
||||
const targetFilePath = `webext-domain-permission-toggle/index.js`
|
||||
const pairs = [
|
||||
[
|
||||
`const { name, optional_permissions: optionalPermissions } = chrome.runtime.getManifest();`, // prettier-ignore
|
||||
`const { name, optional_host_permissions: optionalPermissions } = chrome.runtime.getManifest();`, // prettier-ignore
|
||||
],
|
||||
[
|
||||
`const optionalHosts = optionalPermissions === null || optionalPermissions === void 0 ? void 0 : optionalPermissions.filter(permission => /<all_urls>|\\*/.test(permission));`, // prettier-ignore
|
||||
`const optionalHosts = optionalPermissions === null || optionalPermissions === void 0 ? void 0 : optionalPermissions.filter(permission => '*://*/*' === permission);`, // prettier-ignore
|
||||
],
|
||||
[
|
||||
`contexts: ['page_action', 'browser_action']`, // prettier-ignore
|
||||
`contexts: ['action', 'page_action', 'browser_action']`, // prettier-ignore
|
||||
],
|
||||
]
|
||||
|
||||
exports.fix = async () => {
|
||||
try {
|
||||
await fixDep(targetFilePath, pairs)
|
||||
} catch (err) {
|
||||
console.error((err && err.message) || err)
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
import addDomainPermissionToggle from 'webext-domain-permission-toggle'
|
||||
import addPermissionToggle from 'webext-permission-toggle'
|
||||
import 'webext-dynamic-content-scripts'
|
||||
|
||||
addDomainPermissionToggle({
|
||||
addPermissionToggle({
|
||||
title: 'Enable Gitako on this domain',
|
||||
reloadOnSuccess: 'Refresh to activate Gitako?',
|
||||
})
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ module.exports = {
|
|||
resolve: {
|
||||
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
|
||||
modules: [srcPath, packagesPath, 'node_modules'],
|
||||
mainFields: ['main', 'exports'],
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
|
|
@ -117,11 +118,28 @@ module.exports = {
|
|||
sideEffects: false,
|
||||
},
|
||||
{
|
||||
test: /\.m?js$/,
|
||||
test: /\.[cm]?js$/,
|
||||
loader: 'babel-loader',
|
||||
// Transpile as least files under node_modules
|
||||
include:
|
||||
/node_modules\/(webext-content-scripts|webext-detect-page|webext-dynamic-content-scripts|superstruct)\/.*\.m?js$/,
|
||||
include: new RegExp(
|
||||
[
|
||||
``,
|
||||
`node_modules`,
|
||||
`(${[
|
||||
`superstruct`,
|
||||
`webext-alert`,
|
||||
`webext-content-scripts`,
|
||||
`webext-detect-page`,
|
||||
`webext-detect`,
|
||||
`webext-dynamic-content-scripts`,
|
||||
`webext-events`,
|
||||
`webext-permission-toggle`,
|
||||
`webext-permissions`,
|
||||
`webext-tools`,
|
||||
].join('|')})`,
|
||||
``,
|
||||
].join('/'),
|
||||
),
|
||||
options: {
|
||||
cacheDirectory: true,
|
||||
},
|
||||
|
|
|
|||
Loading…
Reference in a new issue