This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/widgets/software-update-prompt-test.js
Joffrey JAFFEUX 68a032a734
DEV: prevents test timeout (#12631)
Clock manipulation seems not reliable in component tests. This blog post does a great job of explaining it: https://dockyard.com/blog/2018/04/18/bending-time-in-ember-tests

Sadly, we don't have all the "recent" ember test helpers and can't use things like `getSettledState()`.

For now this pattern seems the most reliable and easy to apply, albeit not great.

Note if you wish to reproduce the current timeout, the following command should do it: `QUNIT_SEED=215263717493121190480103670124734840282 rake qunit:test`
2021-04-07 15:50:06 +02:00

53 lines
1.4 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import {
discourseModule,
publishToMessageBus,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
import { later } from "@ember/runloop";
discourseModule(
"Integration | Component | software-update-prompt",
function (hooks) {
setupRenderingTest(hooks);
componentTest(
"software-update-prompt gets correct CSS class after messageBus message",
{
template: hbs`{{software-update-prompt}}`,
test(assert) {
assert.ok(
queryAll("div.software-update-prompt.require-software-refresh")
.length === 0,
"it does not have the class to show the prompt"
);
assert.equal(
queryAll("div.software-update-prompt")[0].getAttribute(
"aria-hidden"
),
"",
"it does have the aria-hidden attribute"
);
publishToMessageBus("/global/asset-version", "somenewversion");
const done = assert.async();
later(() => {
assert.ok(
queryAll("div.software-update-prompt.require-software-refresh")
.length === 1,
"it does have the class to show the prompt"
);
done();
}, 10);
},
}
);
}
);