Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stub/BrowserStorage] reimplement and test the BrowserStorage stub #8021

Merged
merged 1 commit into from
Aug 18, 2016

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Aug 18, 2016

While working on another pull request that requires testing against a fake browser storage object, I ran into some stuff that the existing StubBrowserStorage didn't provide, and since the existing module was so tiny this technically is a rewrite.

  • return null when an item is not in the store (like the browser does)
  • the length property and keys() method, necessary for iterating the store
  • the ability to limit its size

This PR implements all of these things and adds test for the stub itself.

@spalger spalger added the review label Aug 18, 2016
@spalger spalger force-pushed the reimplement/BrowserStorageStub branch from b9f668e to a97319c Compare August 18, 2016 07:23
@cjcenizal
Copy link
Contributor

This looks like great code! It's difficult for me to judge its utility, though. What are the uses cases for this?

In my experience, I've tested storage-dependent code by spying on localStorage or sessionStorage interface methods, returning fake values where necessary, and asserting that they methods been called with the correct values. This way the test execution is unaffected by the implementation details of those APIs. Would this work for your use cases?

@spalger
Copy link
Contributor Author

spalger commented Aug 18, 2016

I guess I have a couple reasons why I moved from stubbing individual functions to stubbing the whole thing:

  • The specific class I was testing was using sessionStorage in its constructor, so I would have had to stub the same methods in every fucnton on top of test specific stubs
  • The size limit thing. I initially implemented that by stubbing the sessionStorage object and it was much more difficult to understand that way
  • By making it a part of the shared stub other tests have the opportunity to utilize it

@cjcenizal
Copy link
Contributor

LGTM

@tylersmalley
Copy link
Contributor

LGTM 👍

@spalger spalger merged commit ce33785 into elastic:master Aug 18, 2016
@spalger spalger deleted the reimplement/BrowserStorageStub branch September 9, 2016 23:13
airow pushed a commit to airow/kibana that referenced this pull request Feb 16, 2017
…geStub

[stub/BrowserStorage] reimplement and test the BrowserStorage stub

Former-commit-id: ce33785
jbudz pushed a commit that referenced this pull request Sep 30, 2024
`v95.11.0`⏩`v95.12.0-backport.0`

> [!note]
> A few fun highlights from this release:
> - Content within `EuiDataGrid`, `EuiBasicTable`, and
`EuiInMemoryTable`, when manually selected/highlighted by users, should
now more cleanly copy and paste into various spreadsheet apps
> - `EuiProvider` will now detect the user's system-level dark or light
mode and default to that if no `colorMode` prop is passed manually

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v95.12.0`](https://github.com/elastic/eui/releases/v95.12.0)

- Enhanced `EuiDataGrid` and `EuiBasic/InMemoryTable` to clean content
newlines/tabs when users copy and paste from their tabular data
([#8019](elastic/eui#8019))
- Updated `EuiResizableButton` with a new `accountForScrollbars` prop
([#8021](elastic/eui#8021))
- Updated `EuiProvider` to inherit from the user's OS/system light/dark
mode setting if a `colorMode` prop has not been passed
([#8026](elastic/eui#8026))

**Bug fixes**

- Fixed `EuiDatePicker`'s `onClear` button to not appear when the input
is `disabled` ([#8020](elastic/eui#8020))
- Fixed several `EuiDataGrid` row height bugs:
([#8025](elastic/eui#8025))
- Fixed row heights not recalculating when
`rowHeightOptions.lineHeight`, `gridStyles.fontSize`, or
`gridStyles.cellPadding` changed
- Fixed incorrect height calculations for `rowHeightOptions.rowHeights`
with `lineCount`s
- Fixed control column content to align better with multi-line row
heights, as well as custom line-heights
##
[`v95.12.0-backport.0`](https://github.com/elastic/eui/releases/v95.12.0-backport.0)

**This is a backport release only intended for use by Kibana.**

**Bug fixes**

- Fixed `EuiProvider`'s system color mode detection causing errors
during server-side rendering
([#8040](elastic/eui#8040))
- Fixed an `EuiDataGrid` rendering bug that was causing bouncing
scrollbar issues ([#8041](elastic/eui#8041))
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Sep 30, 2024
`v95.11.0`⏩`v95.12.0-backport.0`

> [!note]
> A few fun highlights from this release:
> - Content within `EuiDataGrid`, `EuiBasicTable`, and
`EuiInMemoryTable`, when manually selected/highlighted by users, should
now more cleanly copy and paste into various spreadsheet apps
> - `EuiProvider` will now detect the user's system-level dark or light
mode and default to that if no `colorMode` prop is passed manually

_[Questions? Please see our Kibana upgrade
FAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_

---

## [`v95.12.0`](https://github.com/elastic/eui/releases/v95.12.0)

- Enhanced `EuiDataGrid` and `EuiBasic/InMemoryTable` to clean content
newlines/tabs when users copy and paste from their tabular data
([elastic#8019](elastic/eui#8019))
- Updated `EuiResizableButton` with a new `accountForScrollbars` prop
([elastic#8021](elastic/eui#8021))
- Updated `EuiProvider` to inherit from the user's OS/system light/dark
mode setting if a `colorMode` prop has not been passed
([elastic#8026](elastic/eui#8026))

**Bug fixes**

- Fixed `EuiDatePicker`'s `onClear` button to not appear when the input
is `disabled` ([elastic#8020](elastic/eui#8020))
- Fixed several `EuiDataGrid` row height bugs:
([elastic#8025](elastic/eui#8025))
- Fixed row heights not recalculating when
`rowHeightOptions.lineHeight`, `gridStyles.fontSize`, or
`gridStyles.cellPadding` changed
- Fixed incorrect height calculations for `rowHeightOptions.rowHeights`
with `lineCount`s
- Fixed control column content to align better with multi-line row
heights, as well as custom line-heights
##
[`v95.12.0-backport.0`](https://github.com/elastic/eui/releases/v95.12.0-backport.0)

**This is a backport release only intended for use by Kibana.**

**Bug fixes**

- Fixed `EuiProvider`'s system color mode detection causing errors
during server-side rendering
([elastic#8040](elastic/eui#8040))
- Fixed an `EuiDataGrid` rendering bug that was causing bouncing
scrollbar issues ([elastic#8041](elastic/eui#8041))

(cherry picked from commit 8a89c85)
kibanamachine added a commit that referenced this pull request Oct 1, 2024
# Backport

This will backport the following commits from `main` to `8.x`:
- [Upgrade EUI to v95.12.0
(#193805)](#193805)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Cee
Chen","email":"549407+cee-chen@users.noreply.github.com"},"sourceCommit":{"committedDate":"2024-09-30T23:25:47Z","message":"Upgrade
EUI to v95.12.0 (#193805)\n\n`v95.11.0`⏩`v95.12.0-backport.0`\r\n\r\n>
[!note]\r\n> A few fun highlights from this release:\r\n> - Content
within `EuiDataGrid`, `EuiBasicTable`, and\r\n`EuiInMemoryTable`, when
manually selected/highlighted by users, should\r\nnow more cleanly copy
and paste into various spreadsheet apps\r\n> - `EuiProvider` will now
detect the user's system-level dark or light\r\nmode and default to that
if no `colorMode` prop is passed manually\r\n\r\n_[Questions? Please see
our Kibana
upgrade\r\nFAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_\r\n\r\n---\r\n\r\n##
[`v95.12.0`](https://github.com/elastic/eui/releases/v95.12.0)\r\n\r\n-
Enhanced `EuiDataGrid` and `EuiBasic/InMemoryTable` to clean
content\r\nnewlines/tabs when users copy and paste from their tabular
data\r\n([#8019](https://github.com/elastic/eui/pull/8019))\r\n- Updated
`EuiResizableButton` with a new `accountForScrollbars`
prop\r\n([#8021](https://github.com/elastic/eui/pull/8021))\r\n- Updated
`EuiProvider` to inherit from the user's OS/system light/dark\r\nmode
setting if a `colorMode` prop has not been
passed\r\n([#8026](https://github.com/elastic/eui/pull/8026))\r\n\r\n**Bug
fixes**\r\n\r\n- Fixed `EuiDatePicker`'s `onClear` button to not appear
when the input\r\nis `disabled`
([#8020](https://github.com/elastic/eui/pull/8020))\r\n- Fixed several
`EuiDataGrid` row height
bugs:\r\n([#8025](https://github.com/elastic/eui/pull/8025))\r\n- Fixed
row heights not recalculating when\r\n`rowHeightOptions.lineHeight`,
`gridStyles.fontSize`, or\r\n`gridStyles.cellPadding` changed\r\n- Fixed
incorrect height calculations for `rowHeightOptions.rowHeights`\r\nwith
`lineCount`s\r\n- Fixed control column content to align better with
multi-line row\r\nheights, as well as custom
line-heights\r\n##\r\n[`v95.12.0-backport.0`](https://github.com/elastic/eui/releases/v95.12.0-backport.0)\r\n\r\n**This
is a backport release only intended for use by Kibana.**\r\n\r\n**Bug
fixes**\r\n\r\n- Fixed `EuiProvider`'s system color mode detection
causing errors\r\nduring server-side
rendering\r\n([#8040](https://github.com/elastic/eui/pull/8040))\r\n-
Fixed an `EuiDataGrid` rendering bug that was causing
bouncing\r\nscrollbar issues
([#8041](https://github.com/elastic/eui/pull/8041))","sha":"8a89c8576df104c16ae3abf39b9db766e56d4e3b","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:skip","EUI","v9.0.0","v8.16.0","backport:version"],"title":"Upgrade
EUI to
v95.12.0","number":193805,"url":"https://github.com/elastic/kibana/pull/193805","mergeCommit":{"message":"Upgrade
EUI to v95.12.0 (#193805)\n\n`v95.11.0`⏩`v95.12.0-backport.0`\r\n\r\n>
[!note]\r\n> A few fun highlights from this release:\r\n> - Content
within `EuiDataGrid`, `EuiBasicTable`, and\r\n`EuiInMemoryTable`, when
manually selected/highlighted by users, should\r\nnow more cleanly copy
and paste into various spreadsheet apps\r\n> - `EuiProvider` will now
detect the user's system-level dark or light\r\nmode and default to that
if no `colorMode` prop is passed manually\r\n\r\n_[Questions? Please see
our Kibana
upgrade\r\nFAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_\r\n\r\n---\r\n\r\n##
[`v95.12.0`](https://github.com/elastic/eui/releases/v95.12.0)\r\n\r\n-
Enhanced `EuiDataGrid` and `EuiBasic/InMemoryTable` to clean
content\r\nnewlines/tabs when users copy and paste from their tabular
data\r\n([#8019](https://github.com/elastic/eui/pull/8019))\r\n- Updated
`EuiResizableButton` with a new `accountForScrollbars`
prop\r\n([#8021](https://github.com/elastic/eui/pull/8021))\r\n- Updated
`EuiProvider` to inherit from the user's OS/system light/dark\r\nmode
setting if a `colorMode` prop has not been
passed\r\n([#8026](https://github.com/elastic/eui/pull/8026))\r\n\r\n**Bug
fixes**\r\n\r\n- Fixed `EuiDatePicker`'s `onClear` button to not appear
when the input\r\nis `disabled`
([#8020](https://github.com/elastic/eui/pull/8020))\r\n- Fixed several
`EuiDataGrid` row height
bugs:\r\n([#8025](https://github.com/elastic/eui/pull/8025))\r\n- Fixed
row heights not recalculating when\r\n`rowHeightOptions.lineHeight`,
`gridStyles.fontSize`, or\r\n`gridStyles.cellPadding` changed\r\n- Fixed
incorrect height calculations for `rowHeightOptions.rowHeights`\r\nwith
`lineCount`s\r\n- Fixed control column content to align better with
multi-line row\r\nheights, as well as custom
line-heights\r\n##\r\n[`v95.12.0-backport.0`](https://github.com/elastic/eui/releases/v95.12.0-backport.0)\r\n\r\n**This
is a backport release only intended for use by Kibana.**\r\n\r\n**Bug
fixes**\r\n\r\n- Fixed `EuiProvider`'s system color mode detection
causing errors\r\nduring server-side
rendering\r\n([#8040](https://github.com/elastic/eui/pull/8040))\r\n-
Fixed an `EuiDataGrid` rendering bug that was causing
bouncing\r\nscrollbar issues
([#8041](https://github.com/elastic/eui/pull/8041))","sha":"8a89c8576df104c16ae3abf39b9db766e56d4e3b"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/193805","number":193805,"mergeCommit":{"message":"Upgrade
EUI to v95.12.0 (#193805)\n\n`v95.11.0`⏩`v95.12.0-backport.0`\r\n\r\n>
[!note]\r\n> A few fun highlights from this release:\r\n> - Content
within `EuiDataGrid`, `EuiBasicTable`, and\r\n`EuiInMemoryTable`, when
manually selected/highlighted by users, should\r\nnow more cleanly copy
and paste into various spreadsheet apps\r\n> - `EuiProvider` will now
detect the user's system-level dark or light\r\nmode and default to that
if no `colorMode` prop is passed manually\r\n\r\n_[Questions? Please see
our Kibana
upgrade\r\nFAQ.](https://github.com/elastic/eui/blob/main/wiki/eui-team-processes/upgrading-kibana.md#faq-for-kibana-teams)_\r\n\r\n---\r\n\r\n##
[`v95.12.0`](https://github.com/elastic/eui/releases/v95.12.0)\r\n\r\n-
Enhanced `EuiDataGrid` and `EuiBasic/InMemoryTable` to clean
content\r\nnewlines/tabs when users copy and paste from their tabular
data\r\n([#8019](https://github.com/elastic/eui/pull/8019))\r\n- Updated
`EuiResizableButton` with a new `accountForScrollbars`
prop\r\n([#8021](https://github.com/elastic/eui/pull/8021))\r\n- Updated
`EuiProvider` to inherit from the user's OS/system light/dark\r\nmode
setting if a `colorMode` prop has not been
passed\r\n([#8026](https://github.com/elastic/eui/pull/8026))\r\n\r\n**Bug
fixes**\r\n\r\n- Fixed `EuiDatePicker`'s `onClear` button to not appear
when the input\r\nis `disabled`
([#8020](https://github.com/elastic/eui/pull/8020))\r\n- Fixed several
`EuiDataGrid` row height
bugs:\r\n([#8025](https://github.com/elastic/eui/pull/8025))\r\n- Fixed
row heights not recalculating when\r\n`rowHeightOptions.lineHeight`,
`gridStyles.fontSize`, or\r\n`gridStyles.cellPadding` changed\r\n- Fixed
incorrect height calculations for `rowHeightOptions.rowHeights`\r\nwith
`lineCount`s\r\n- Fixed control column content to align better with
multi-line row\r\nheights, as well as custom
line-heights\r\n##\r\n[`v95.12.0-backport.0`](https://github.com/elastic/eui/releases/v95.12.0-backport.0)\r\n\r\n**This
is a backport release only intended for use by Kibana.**\r\n\r\n**Bug
fixes**\r\n\r\n- Fixed `EuiProvider`'s system color mode detection
causing errors\r\nduring server-side
rendering\r\n([#8040](https://github.com/elastic/eui/pull/8040))\r\n-
Fixed an `EuiDataGrid` rendering bug that was causing
bouncing\r\nscrollbar issues
([#8041](https://github.com/elastic/eui/pull/8041))","sha":"8a89c8576df104c16ae3abf39b9db766e56d4e3b"}},{"branch":"8.x","label":"v8.16.0","branchLabelMappingKey":"^v8.16.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}]
BACKPORT-->

Co-authored-by: Cee Chen <549407+cee-chen@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants