Skip to content

Commit

Permalink
chore: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarpl committed Oct 22, 2024
1 parent a833673 commit cc9bced
Show file tree
Hide file tree
Showing 18 changed files with 10,197 additions and 8,693 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/node.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 18.x
- name: Test in Chromium
run: |
yarn
Expand All @@ -36,10 +36,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 18.x
- name: Check release is desired
id: do-publish
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 18.x
- name: Test in Chromium
run: |
yarn
Expand All @@ -35,10 +35,10 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Use Node.js 16.x
- name: Use Node.js 18.x
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 18.x
- name: Check release is desired
id: do-publish
run: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
.yarn/cache/**/*
node_modules
dist
src/**.js
Expand Down
Binary file added .yarn/install-state.gz
Binary file not shown.
1 change: 1 addition & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
1 change: 1 addition & 0 deletions jest-puppeteer.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module.exports = {
server: {
command: 'yarn webpack serve --env test',
port: 9000,
launchTimeout: 10000,
},
browserContext: 'default',
}
25 changes: 11 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,23 +54,20 @@
"@types/jest-environment-puppeteer": "^4.4.1",
"@types/node": "^14.0.0",
"concurrently": "^6.2.0",
"expect-puppeteer": "^5.0.4",
"jest": "^27.0.6",
"jest-puppeteer": "^5.0.4",
"puppeteer": "^10.1.0",
"expect-puppeteer": "^10.1.2",
"jest": "^29.7.0",
"jest-puppeteer": "^10.1.2",
"puppeteer": "^23.6.0",
"rimraf": "^3.0.2",
"standard-version": "^9.3.1",
"ts-jest": "^27.0.4",
"ts-loader": "8.2.0",
"ts-jest": "^29.2.5",
"ts-loader": "9.5.1",
"typedoc": "^0.20.33",
"typescript": "4.2.4",
"webpack": "^4.46.0",
"webpack-cli": "4.5.0",
"webpack-dev-server": "3.11.2",
"typescript": "5.6.3",
"webpack": "^5.95.0",
"webpack-cli": "5.1.4",
"webpack-dev-server": "5.1.0",
"yargs": "^17.0.1"
},
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json",
"resolutions": {
"webpack-dev-server/**/glob-parent": "^5.1.2"
}
"prettier": "@sofie-automation/code-standard-preset/.prettierrc.json"
}
13 changes: 6 additions & 7 deletions src/__tests__/amdModule.test.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import expectPuppet from 'expect-puppeteer'
import { expect as expectPuppet } from 'expect-puppeteer'

describe('AMD Module export', () => {
beforeAll(async () => {
await Promise.all([
page.goto('http://localhost:9000/requirejs.html'),
page.waitForNavigation(),
page.waitForTimeout(1000),
])
})
await page.goto('http://localhost:9000/requirejs.html', {
waitUntil: 'domcontentloaded'
})
}, 10000)

it('should initialize', async () => {
await page.waitForSelector('p[data-ready]')
await expectPuppet(page).toMatchElement('p', { text: 'Sørensen is initialized' })
})
})
28 changes: 10 additions & 18 deletions src/__tests__/bind.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { bindCombo, expectToBePrevented, expectToTrigger, resetAllCombos } from './utils/bindCombo'
import { sleep } from './utils/sleep'

jest.setTimeout(300000)

Expand All @@ -8,7 +9,7 @@ describe('Sørensen.bind', () => {
await Promise.all([page.goto('http://localhost:9000/index.html'), page.waitForNavigation()])

await page.bringToFront()
})
}, 10000)

beforeEach(async () => {
await resetAllCombos()
Expand Down Expand Up @@ -40,13 +41,9 @@ describe('Sørensen.bind', () => {
it('KeyA fires once on repeat keydown', async () => {
await expectToTrigger('KeyA', 0)
await page.keyboard.down('KeyA')
await page.waitForTimeout(5)
await page.keyboard.down('KeyA')
await page.waitForTimeout(5)
await page.keyboard.down('KeyA')
await page.waitForTimeout(5)
await page.keyboard.down('KeyA')
await page.waitForTimeout(5)

await expectToTrigger('KeyA', 1)
await page.keyboard.up('KeyA')
Expand Down Expand Up @@ -112,17 +109,11 @@ describe('Sørensen.bind', () => {
await page.focus('input')
await expectToTrigger('KeyX+KeyK', 0)
await page.keyboard.down('KeyX')
await page.waitForTimeout(5)
await page.keyboard.down('KeyX')
await page.waitForTimeout(5)
await page.keyboard.down('KeyX')
await page.waitForTimeout(5)
await page.keyboard.down('KeyK')
await page.waitForTimeout(5)
await page.keyboard.down('KeyK')
await page.waitForTimeout(5)
await page.keyboard.down('KeyK')
await page.waitForTimeout(5)
await page.keyboard.press('KeyA', {
delay: 5,
})
Expand Down Expand Up @@ -553,10 +544,8 @@ describe('Sørensen.bind', () => {
await expectToTrigger('KeyD KeyE KeyF', 0)
await page.keyboard.press('KeyD')
await expectToTrigger('KeyD KeyE KeyF', 0)
await page.waitForTimeout(500)
await page.keyboard.press('KeyE')
await expectToTrigger('KeyD KeyE KeyF', 0)
await page.waitForTimeout(700)
await page.keyboard.press('KeyF')

await expectToTrigger('KeyD KeyE KeyF', 1)
Expand All @@ -566,10 +555,10 @@ describe('Sørensen.bind', () => {
await expectToTrigger('KeyD KeyE KeyF', 0)
await page.keyboard.press('KeyD')
await expectToTrigger('KeyD KeyE KeyF', 0)
await page.waitForTimeout(1000)
await sleep(1000)
await page.keyboard.press('KeyE')
await expectToTrigger('KeyD KeyE KeyF', 0)
await page.waitForTimeout(2000)
await sleep(2000)
await page.keyboard.press('KeyF')

await expectToTrigger('KeyD KeyE KeyF', 0)
Expand Down Expand Up @@ -659,9 +648,10 @@ describe('Sørensen.bind', () => {

describe('keyup', () => {
beforeAll(async () => {
await page.goto('http://localhost:9000/index.html')
await page.waitForTimeout(300)
})
await page.goto('http://localhost:9000/index.html', {
waitUntil: 'domcontentloaded'
})
}, 10000)

beforeEach(async () => {
await resetAllCombos()
Expand Down Expand Up @@ -888,6 +878,7 @@ describe('Sørensen.bind', () => {

it('Global KeyK is preventDefault\'ed in input', async () => {
const input = await page.$('input')
if (!input) throw Error('Input not found')
await page.evaluate(el => el.value = '', input)

await page.focus('input')
Expand All @@ -905,6 +896,7 @@ describe('Sørensen.bind', () => {

it('Non-global KeyL is not preventDefault\'ed in input', async () => {
const input = await page.$('input')
if (!input) throw Error('Input not found')
await page.evaluate(el => el.value = '', input)

await page.focus('input')
Expand Down
6 changes: 3 additions & 3 deletions src/__tests__/globalVar.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import expectPuppet from 'expect-puppeteer'
import { expect as expectPuppet} from 'expect-puppeteer'

describe('Global object injection', () => {
beforeAll(async () => {
await Promise.all([page.goto('http://localhost:9000/index.html'), page.waitForNavigation()])
})
}, 10000)

it('should expose global object', async () => {
const mounted = await page.evaluate<string>('typeof window.sorensen.bind')
const mounted = await page.evaluate('typeof window.sorensen.bind')
expect(mounted).toBe('function')
})

Expand Down
7 changes: 5 additions & 2 deletions src/__tests__/keyCodeConversion.test.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
jest.setTimeout(300000)

async function getKeyForCode(code: string): Promise<string> {
return await page.evaluate<string>(`sorensen.getKeyForCode(${JSON.stringify(code)})`)
const result = await page.evaluate(`sorensen.getKeyForCode(${JSON.stringify(code)})`)
expect(typeof result).toBe('string')

return result as string
}

describe('Sørensen.getKeyForCode', () => {
beforeAll(async () => {
await Promise.all([page.goto('http://localhost:9000/index.html'), page.waitForNavigation()])
})
}, 10000)

// these tests assume running on an US-English machine

Expand Down
10 changes: 5 additions & 5 deletions src/__tests__/utils/bindCombo.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import expectPuppet from 'expect-puppeteer'
import { expect as expectPuppet } from 'expect-puppeteer'
import { BindOptions } from '../../index'

export async function bindCombo(combo: string, options?: BindOptions) {
await page.evaluate<string>(`bindCombo(${JSON.stringify(combo)}, ${JSON.stringify(options || {})})`)
await page.evaluate(`bindCombo(${JSON.stringify(combo)}, ${JSON.stringify(options || {})})`)
}

export async function getPressedKeys() {
return await page.evaluate<string>(`sorensen.getPressedKeys()`).then((val) => val as string)
return await page.evaluate(`sorensen.getPressedKeys()`).then((val) => val as string)
}

export async function expectToTrigger(combo: string, count: number) {
Expand All @@ -22,9 +22,9 @@ export async function expectToBePrevented(combo: string, count: number) {
}

export async function resetCombo(combo: string) {
await page.evaluate<string>(`resetState(${JSON.stringify(combo)})`)
await page.evaluate(`resetState(${JSON.stringify(combo)})`)
}

export async function resetAllCombos() {
await page.evaluate<string>(`resetAllStates()`)
await page.evaluate(`resetAllStates()`)
}
3 changes: 3 additions & 0 deletions src/__tests__/utils/sleep.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export async function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms))
}
9 changes: 6 additions & 3 deletions src/__tests__/windowFocus.test.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,25 @@
import { bindCombo, expectToTrigger, getPressedKeys, resetAllCombos } from './utils/bindCombo'
import { sleep } from './utils/sleep'

jest.setTimeout(300000)

describe('Window focus handling', () => {
beforeAll(async () => {
await Promise.all([page.goto('http://localhost:9000/index.html'), page.waitForNavigation()])
await page.goto('http://localhost:9000/index.html', {
waitUntil: 'domcontentloaded'
})

// this test requires exclusive control of the browser, so spin until we're the last test standing
while (true) {
const targets = (await browser.targets()).filter((t) => !!t.url() && t.url() !== 'about:blank')
if (targets.length < 2) {
break
}
await page.waitForTimeout(1000)
await sleep(1000)
}

await page.bringToFront()
})
}, 10000)

beforeEach(async () => {
await resetAllCombos()
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ let chordTimeout: number | undefined = undefined
function setupChordTimeout() {
clearChordTimeout()
if (CHORD_TIMEOUT > 0) {
chordTimeout = setTimeout(() => {
chordTimeout = window.setTimeout(() => {
chordsInProgress.length = 0
}, CHORD_TIMEOUT)
}
Expand Down
4 changes: 3 additions & 1 deletion test/requirejs.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ <h1>Sørensen AMD module test</h1>
<script>
requirejs(['sorensen'], function (sorensen) {
sorensen.init().then(() => {
document.getElementById('mounted').textContent = 'Sørensen is initialized'
const el = document.getElementById('mounted')
el.dataset['ready'] = true;
el.textContent = 'Sørensen is initialized'
})
})
</script>
Loading

0 comments on commit cc9bced

Please sign in to comment.