-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feature to save and load a pattern in IndexedDB #35
Comments
This issue is not that simple. |
There is a simple wrapper for IndexedDB. |
As I guessed, I have to carefully handle IndexedDB when it is combined with Cypress. |
It looks the following code works.
But is it guaranteed that
|
It is up to what is inside It is configured by the function setWindowDocumentProps. |
Tests occasionally fail unless I append |
By the way, I noticed that
|
- A pattern is experimentally loaded from the IndexedDB. The root and `pattern` stores require a Promise that will be resolved into an IDBDatabase object. - An IDBDatabase is opened in `src/index.js`. - The `editor-container` component triggers a `loadCurrentPattern` action of the `pattern` store. issue #35
- The `pattern` store has a new action `saveCurrentPattern` that saves the current pattern to the IndexedDB. - The `pattern-editor` component saves the current pattern by calling the `saveCurrentPattern` action every time the current pattern is edited. issue #35
- Since the last commit the current pattern is saved in the IndexedDB as an `AmidzDatabase` database. So E2E tests became unstable because the application remembers the last pattern. To fix this, the `AmidzDatabase` database is deleted at the beginning of every test. The default pattern stored in the `AmidzDatabase` is now same as the default value of the `patternData` state of the `pattern` store. issue #35
- The default pattern is given by a single blank cell. - Tests occasionally fail unless `cy.wait` is appended after `cy.reload`. It currently waits for 100ms but I do not know an appropriate duration. - `cy.window` calls are removed since `cy.visit` yields a window. The database deletion code is moved to the `then` function following `cy.visit`. issue #35
I am still facing irreproducible tests failure especially when they are executed with |
How about to wait for the pattern loaded from IndexedDB before rendering the editor component. |
How long does |
It looks |
- A loading spinner is shown until the pattern that was edited last time is loaded from the database. When the pattern is loaded, the loading spinner is hidden and a class `is-ready` is added to the editor container component. The `is-ready` class facilitates E2E tests to know when the pattern is actually loaded. issue #35
Why don't you flush the database at |
You missed a critical thing That is why your |
By the way, this would be better because you do not need to call |
- A `versionchange` event was not handled by `AmidzDatabase`, that is fired when a database is going to be deleted by `deleteDatabase`. `deleteDatabase` does not fire a `success` event until the database is closed. This is why tests timed out if a `success` event was expected. So I did not wait for `deleteDatabase` to fire a `success` event at that time. This can be a cause of E2E test instability. Now `AmidzDatabase` is closed when a `versionchange` event is fired. And by moving `deleteDatabase` call to `afterEach`, `cy.reload` is no longer necessary. issue #35 issue #47
- `AmidzDatabase` is closed when `deleteDatabase` is triggered. issue #35
Where to save?
Here I want to provide an offline feature first.
So I will give IndexedDB a shot.
IndexedDB Structure
Database
AmidzDatabase
Object Store
pattern
keyPath
:'name'
name
: Stringrows
: Array.Objectcolumns
: Array.ObjectsymbolId
: StringA value object has the same structure as the
patternData
state of thepattern
Vuex store.The text was updated successfully, but these errors were encountered: