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
Martin Brennan 432b839997
FEATURE: Move site updated modal into a less obtrusive prompt (#12577)
This moves the "This site was just updated" modal asking the user if they want to refresh into a subtle prompt that slides down from the header.

Also in this PR I've added a helper to publish message bus messages in JS tests. So instead of this:

```javascript
// Mimic a messagebus message
MessageBus.callbacks
  .filterBy("channel", "/global/asset-version")
  .map((c) => c.func("somenewversion"));
```

We can have:

```javascript
publishToMessageBus("/global/asset-version", "somenewversion");
```
2021-04-07 08:56:48 +10:00

61 lines
1.6 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import sinon from "sinon";
import {
discourseModule,
fakeTime,
publishToMessageBus,
queryAll,
} from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
let clock = null;
discourseModule(
"Integration | Component | software-update-prompt",
function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
clock = fakeTime("2019-12-10T08:00:00", "Australia/Brisbane", true);
});
hooks.afterEach(function () {
clock.restore();
sinon.restore();
});
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");
clock.tick(1000 * 60 * 24 * 60 + 10);
assert.ok(
queryAll("div.software-update-prompt.require-software-refresh")
.length === 1,
"it does have the class to show the prompt"
);
},
}
);
}
);