Comments (6)
Assuming you use #3 - I test this in a few applications with an acceptance test. Something like:
import { module, test } from 'qunit';
import { visit, currentURL } from '@ember/test-helpers';
import { setupApplicationTest } from 'ember-qunit';
import { t } from 'ember-intl/test-support';
import page from '../pages/index';
import config from 'ember-get-config';
module('Acceptance | new build notification', function(hooks) {
setupApplicationTest(hooks);
hooks.beforeEach(function () {
config.environment = 'staging';
window.isUpdateAvailable = new Promise((resolve) => {
resolve(true);
});
});
hooks.afterEach(function () {
config.environment = 'test';
window.isUpdateAvailable = null;
});
test('new build renders when update is available', async function(assert) {
await visit('/');
assert.equal(currentURL(), '/login');
assert.ok(page.build.isVisible, 'see new build notification');
assert.equal(
page.build.text,
t('components.new-build-notifier.text'),
'notification has correct text'
);
assert.ok(page.build.action.isVisible, 'see action to reload');
assert.equal(
page.build.action.text,
t('components.new-build-notifier.action'),
'action button has correct text'
);
});
});
Note that I only enable this notification in staging
and production
environments, hence the config.environment = 'staging';
. The assumption is also that the polling interval is configurable. For production usage, I use 20 minutes, but in the test
environment I cut that down to 1ms.
from ember-service-worker-update-notify.
What I do for an ad-hoc testing locally is to:
- start a development server with live-reload disabled with
ember s -lr false
- open app
- make some change on the app to trigger another build
- wait for the polling to run
This is easier when you set a smaller polling interval in the component with <ServiceWorkerUpdateNotify @pollingInterval={{1000}}>
, for example.
from ember-service-worker-update-notify.
Resolved via: https://github.com/topaxi/ember-service-worker-update-notify#testing-in-your-app
from ember-service-worker-update-notify.
Not that I know of, one way I tested my notifications is to trigger a manual ServiceWorker update in the Google Chrome developer tools in the Application -> ServiceWorkers tab. Not sure if I changed something here as I don't seem to be able to reproduce this in one of my Apps.
It would probably nice to be able to trigger this manually somehow..
from ember-service-worker-update-notify.
@topaxi I tried to reproduce just like you said, but not works.
from ember-service-worker-update-notify.
is there a way we can at least have automated tests for this?
Like, we could mock the behavior of service-worker registration, and then test the affected UI?
I've added ember-concurrency in #3, and that adds enough complexity, where I think tests will be very welcome :)
from ember-service-worker-update-notify.
Related Issues (12)
- Realtime update HOT 5
- A note on testing HOT 3
- Question about first time visitors HOT 3
- Show update notification immediately after start up HOT 12
- Remove default component content HOT 2
- Polling prevents settledness in tests HOT 1
- Triggers on refresh with latest build
- Should not register a SW if ember-service-worker is disabled
- Not working in octane app
- Failed to find a valid digest in the 'integrity' attribute for resource
- Support for Ember 4.x HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ember-service-worker-update-notify.