Skip to content

Commit 13bb8d4

Browse files
fix and improve workday overlay options
1 parent 30b1555 commit 13bb8d4

File tree

14 files changed

+208
-116
lines changed

14 files changed

+208
-116
lines changed

.eslintrc.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,13 @@
4343
},
4444
{
4545
"files": [
46-
"./server/**/*"
46+
"./test-server/**/*"
4747
],
4848
"env": {
4949
"node": true
50+
},
51+
"rules": {
52+
"@typescript-eslint/no-var-requires": 0
5053
}
5154
},
5255
{

cypress/e2e/05-a-sw-datacenter.cy.ts

+34
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,40 @@ describe('Service Worker - Datacenter API', () => {
515515
.should('deep.equal', ACTIONS.UPDATE_BADGE.response(true))
516516
})
517517

518+
it('should wait for workday permissions on AWAIT_WORKDAY_PERMISSION message', () => {
519+
cy.networkMocks()
520+
cy.openWithOptions({...defaultOptions, disableWorkdaySync: true}, true)
521+
cy.startSw()
522+
cy.wait(100)
523+
cy.window().then((win) => {
524+
win.chrome.permissions.contains = () => { return Promise.resolve(false) }
525+
})
526+
cy.window().then((win) => {
527+
console.log(win.chrome.permissions.contains)
528+
})
529+
cy.sendMessage(ACTIONS.AWAIT_WORKDAY_PERMISSION.create())
530+
531+
cy.getOptions().should('have.property', 'disableWorkdaySync', true)
532+
533+
cy.wait(600)
534+
cy.getOptions().should('have.property', 'disableWorkdaySync', true)
535+
536+
cy.window().then((win) => {
537+
win.chrome.permissions.contains = () => Promise.resolve(true)
538+
})
539+
cy.wait(600)
540+
cy.window().its('chrome.scripting.scripts').should('have.length', 1)
541+
cy.window().its('chrome.scripting.scripts.0').should('deep.equal', {
542+
id: 'workday-script',
543+
js: ['workday-script.js'],
544+
persistAcrossSessions: true,
545+
matches: ['https://wd5.myworkday.com/*'],
546+
runAt: 'document_start',
547+
allFrames: true
548+
})
549+
cy.getOptions().should('have.property', 'disableWorkdaySync', false)
550+
})
551+
518552
it('should listen to hotkeys', () => {
519553
cy.networkMocks()
520554
cy.openWithOptions(undefined, true)

cypress/support/data.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ export const defaultOptions: Options = {
4848
'TE-17'
4949
],
5050
customTheme: undefined,
51-
workdaySync: false
51+
disableWorkdaySync: true
5252
}
5353
export const baseDate = new Date('2020-10-08T15:00:00.000Z')
5454

cypress/support/e2e.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,10 @@ declare global {
3939
chrome: {
4040
runtime: { sendMessage?: (message: unknown, callback: (status: unknown) => void) => void },
4141
// eslint-disable-next-line @typescript-eslint/ban-types
42-
messageListeners: Function[]
42+
messageListeners: Function[],
43+
permissions: {
44+
contains: (options: unknown, cb: (granted: boolean) => void) => void
45+
}
4346
},
4447
messages: unknown[]
4548
}

0 commit comments

Comments
 (0)