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`
53 lines
1.4 KiB
JavaScript
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);
|
|
},
|
|
}
|
|
);
|
|
}
|
|
);
|