mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-06 03:13:42 -05:00
New template button takes user to new template page
for all services that only allow sending one type of notifications
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
const helpers = require('./support/helpers');
|
||||
|
||||
function setFixtures (hierarchy) {
|
||||
function setFixtures (hierarchy, newTemplateDataModules = "") {
|
||||
|
||||
const foldersCheckboxesHTML = function (filter) {
|
||||
let count = 0;
|
||||
@@ -27,7 +27,7 @@ function setFixtures (hierarchy) {
|
||||
|
||||
}();
|
||||
|
||||
function controlsHTML () {
|
||||
function controlsHTML (newTemplateDataModules) {
|
||||
|
||||
return `<div id="sticky_template_forms">
|
||||
<button type="submit" name="operation" value="unknown" hidden=""></button>
|
||||
@@ -78,7 +78,7 @@ function setFixtures (hierarchy) {
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<div id="add_new_template_form">
|
||||
<div id="add_new_template_form" ${newTemplateDataModules}>
|
||||
<div class="js-will-stick-at-bottom-when-scrolling">
|
||||
<div class="form-group ">
|
||||
<fieldset id="add_template_by_template_type">
|
||||
@@ -127,7 +127,7 @@ function setFixtures (hierarchy) {
|
||||
document.body.innerHTML = `
|
||||
<form method="post" data-module="template-folder-form">
|
||||
${helpers.templatesAndFoldersCheckboxes(hierarchy)}
|
||||
${controlsHTML()}
|
||||
${controlsHTML(newTemplateDataModules)}
|
||||
</form>`;
|
||||
|
||||
};
|
||||
@@ -309,6 +309,37 @@ describe('TemplateFolderForm', () => {
|
||||
|
||||
});
|
||||
|
||||
describe("Click 'New template' for single channel service", () => {
|
||||
test("should redirect to new template page", () => {
|
||||
setFixtures(hierarchy, "data-channel='sms' data-service='123'")
|
||||
templateFolderForm = document.querySelector('form[data-module=template-folder-form]');
|
||||
|
||||
// start module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
formControls = templateFolderForm.querySelector('#sticky_template_forms');
|
||||
|
||||
// reset sticky JS mocks called when the module starts
|
||||
resetStickyMocks();
|
||||
// add listener for url change
|
||||
const descriptor1 = Object.getOwnPropertyDescriptor(window, 'location');
|
||||
delete window.location
|
||||
|
||||
const mockCallback = jest.fn(x => {});
|
||||
|
||||
Object.defineProperty(window, 'location', {
|
||||
set: mockCallback
|
||||
});
|
||||
// click
|
||||
helpers.triggerEvent(formControls.querySelector('[value=add-new-template]'), 'click');
|
||||
// expect url to change
|
||||
expect(mockCallback).toHaveBeenCalledWith("/services/123/templates/add-sms")
|
||||
|
||||
setFixtures(hierarchy)
|
||||
resetStickyMocks()
|
||||
});
|
||||
})
|
||||
|
||||
describe("Clicking 'New template'", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
Reference in New Issue
Block a user