-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correct invalid stored preference for in-app notifications (#27237)
- Loading branch information
1 parent
c921fdf
commit a3e4a8a
Showing
7 changed files
with
100 additions
and
4 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
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
64 changes: 64 additions & 0 deletions
64
packages/data-context/test/unit/actions/LocalSettingsActions.spec.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,64 @@ | ||
import { expect } from 'chai' | ||
import sinon from 'sinon' | ||
import { LocalSettingsActions } from '../../../src/actions/LocalSettingsActions' | ||
import { createTestDataContext } from '../helper' | ||
import type { DataContext } from '../../../src' | ||
import { NotifyCompletionStatuses } from '@packages/types' | ||
|
||
describe('LocalSettingsActions', () => { | ||
let ctx: DataContext | ||
let actions: LocalSettingsActions | ||
|
||
beforeEach(() => { | ||
sinon.restore() | ||
|
||
ctx = createTestDataContext('open') | ||
|
||
actions = new LocalSettingsActions(ctx) | ||
}) | ||
|
||
context('refreshLocalSettings', () => { | ||
context('notifyWhenRunCompletes', () => { | ||
it('should fix false value', async () => { | ||
ctx._apis.localSettingsApi.getPreferences = sinon.stub().resolves({ | ||
//@ts-ignore | ||
notifyWhenRunCompletes: false, | ||
}) | ||
|
||
await actions.refreshLocalSettings() | ||
|
||
expect(ctx.coreData.localSettings.preferences.notifyWhenRunCompletes).to.eql([]) | ||
}) | ||
|
||
it('should fix true value', async () => { | ||
ctx._apis.localSettingsApi.getPreferences = sinon.stub().resolves({ | ||
//@ts-ignore | ||
notifyWhenRunCompletes: true, | ||
}) | ||
|
||
await actions.refreshLocalSettings() | ||
|
||
expect(ctx.coreData.localSettings.preferences.notifyWhenRunCompletes).to.eql([...NotifyCompletionStatuses]) | ||
}) | ||
|
||
it('should leave value alone if value is an array', async () => { | ||
ctx._apis.localSettingsApi.getPreferences = sinon.stub().resolves({ | ||
//@ts-ignore | ||
notifyWhenRunCompletes: ['errored'], | ||
}) | ||
|
||
await actions.refreshLocalSettings() | ||
|
||
expect(ctx.coreData.localSettings.preferences.notifyWhenRunCompletes).to.eql(['errored']) | ||
}) | ||
|
||
it('should pass through default value if not set ', async () => { | ||
ctx._apis.localSettingsApi.getPreferences = sinon.stub().resolves({}) | ||
|
||
await actions.refreshLocalSettings() | ||
|
||
expect(ctx.coreData.localSettings.preferences.notifyWhenRunCompletes).to.eql(['failed']) | ||
}) | ||
}) | ||
}) | ||
}) |
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
a3e4a8a
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.
Circle has built the
linux arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
a3e4a8a
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.
Circle has built the
linux x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
a3e4a8a
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.
Circle has built the
darwin arm64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
a3e4a8a
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.
Circle has built the
darwin x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally:
a3e4a8a
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.
Circle has built the
win32 x64
version of the Test Runner.Learn more about this pre-release build at https://on.cypress.io/advanced-installation#Install-pre-release-version
Run this command to install the pre-release locally: