mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-07-10 11:24:10 -04:00
remove email branding
This commit is contained in:
@@ -25,451 +25,6 @@ describe('Live search', () => {
|
||||
}
|
||||
};
|
||||
|
||||
describe("With a list of radios", () => {
|
||||
|
||||
searchLabelText = "Search branding styles by name";
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
const departmentData = {
|
||||
name: 'departments',
|
||||
hideLegend: true,
|
||||
fields: [
|
||||
{
|
||||
'label': 'NHS',
|
||||
'id': 'nhs',
|
||||
'name': 'branding',
|
||||
'value': 'nhs'
|
||||
},
|
||||
{
|
||||
'label': 'Department for Work and Pensions',
|
||||
'id': 'dwp',
|
||||
'name': 'branding',
|
||||
'value': 'dwp'
|
||||
},
|
||||
{
|
||||
'label': 'Department for Education',
|
||||
'id': 'dfe',
|
||||
'name': 'branding',
|
||||
'value': 'dfe'
|
||||
},
|
||||
{
|
||||
'label': 'Home Office',
|
||||
'id': 'home-office',
|
||||
'name': 'branding',
|
||||
'value': 'home-office'
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// set up DOM
|
||||
document.body.innerHTML = `
|
||||
<div class="live-search js-header" data-module="live-search" data-targets=".usa-radio">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="search">
|
||||
${searchLabelText}
|
||||
</label>
|
||||
<input autocomplete="off" class="form-control form-control-1-1 " id="search" name="search" rows="8" type="search" value="">
|
||||
<div role="region" aria-live="polite" class="live-search__status usa-sr-only"></div>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" autocomplete="off" novalidate>
|
||||
</form>`;
|
||||
|
||||
searchTextbox = document.getElementById('search');
|
||||
liveRegion = document.querySelector('.live-search__status');
|
||||
list = document.querySelector('form');
|
||||
|
||||
// getRadioGroup returns a DOM node so append once DOM is set up
|
||||
list.appendChild(helpers.getRadioGroup(departmentData));
|
||||
|
||||
});
|
||||
|
||||
describe("When the page loads", () => {
|
||||
|
||||
test("If there is no search term, the results should be unchanged", () => {
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
const listItems = list.querySelectorAll('.usa-radio');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(listItems.length);
|
||||
expect(searchTextbox.hasAttribute('aria-label')).toBe(false);
|
||||
|
||||
});
|
||||
|
||||
test("If there is a single word search term, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'Department';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
const listItems = list.querySelectorAll('.usa-radio');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(2);
|
||||
expect(searchTextbox.hasAttribute('aria-label')).toBe(true);
|
||||
expect(searchTextbox.getAttribute('aria-label')).toEqual(`${searchLabelText}, ${liveRegionResults(2)}`);
|
||||
|
||||
});
|
||||
|
||||
test("If there is a search term made of several words, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'Department for Work';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
const listItems = list.querySelectorAll('.usa-radio');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(1);
|
||||
expect(searchTextbox.hasAttribute('aria-label')).toBe(true);
|
||||
expect(searchTextbox.getAttribute('aria-label')).toEqual(`${searchLabelText}, ${liveRegionResults(1)}`);
|
||||
|
||||
});
|
||||
|
||||
test("If an item doesn't match the search term but is selected, it should still show in the results", () => {
|
||||
|
||||
searchTextbox.value = 'Department for Work';
|
||||
|
||||
// mark an item as selected
|
||||
checkedItem = list.querySelector('input[id=nhs]');
|
||||
checkedItem.checked = true;
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
expect(window.getComputedStyle(checkedItem).display).not.toEqual('none');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("When the search text changes", () => {
|
||||
|
||||
test("If there is no search term, the results should be unchanged", () => {
|
||||
|
||||
searchTextbox.value = 'Department';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate the input of new search text
|
||||
searchTextbox.value = '';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
const listItems = list.querySelectorAll('.usa-radio');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(listItems.length);
|
||||
expect(liveRegion.textContent.trim()).toEqual(liveRegionResults(listItemsShowing.length));
|
||||
|
||||
});
|
||||
|
||||
test("If there is a single word search term, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'Department';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate the input of new search text
|
||||
searchTextbox.value = 'Home';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
const listItems = list.querySelectorAll('.usa-radio');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(1);
|
||||
expect(liveRegion.textContent.trim()).toEqual(liveRegionResults(1));
|
||||
|
||||
});
|
||||
|
||||
test("If there is a search term made of several words, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'Department';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate the input of new search text
|
||||
searchTextbox.value = 'Department for';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
const listItems = list.querySelectorAll('.usa-radio');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(2);
|
||||
expect(liveRegion.textContent.trim()).toEqual(liveRegionResults(2));
|
||||
|
||||
});
|
||||
|
||||
test("If an item doesn't match the search term but is selected, it should still show in the results", () => {
|
||||
|
||||
searchTextbox.value = 'Department';
|
||||
|
||||
// mark an item as selected
|
||||
checkedItem = list.querySelector('input[id=nhs]');
|
||||
checkedItem.checked = true;
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate the input of new search text
|
||||
searchTextbox.value = 'Home Office';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
expect(window.getComputedStyle(checkedItem).display).not.toEqual('none');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("With a list of checkboxes", () => {
|
||||
|
||||
searchLabelText = "Search branding styles by name";
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
const templatesAndFolders = [
|
||||
{
|
||||
"label": "Appointments",
|
||||
"type": "folder",
|
||||
"meta": "2 templates"
|
||||
},
|
||||
{
|
||||
"label": "New patient",
|
||||
"type": "template",
|
||||
"meta": "Email template"
|
||||
},
|
||||
{
|
||||
"label": "Prescriptions",
|
||||
"type": "folder",
|
||||
"meta": "1 template, 1 folder"
|
||||
},
|
||||
{
|
||||
"label": "New doctor",
|
||||
"type": "template",
|
||||
"meta": "Email template"
|
||||
}
|
||||
];
|
||||
|
||||
// set up DOM
|
||||
document.body.innerHTML = `
|
||||
<div class="live-search js-header" data-module="live-search" data-targets="#template-list .template-list-item">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="search">
|
||||
${searchLabelText}
|
||||
</label>
|
||||
<input autocomplete="off" class="form-control form-control-1-1 " id="search" name="search" rows="8" type="search" value="">
|
||||
<div role="region" aria-live="polite" class="live-search__status govuk-visually=hidden"></div>
|
||||
</div>
|
||||
</div>
|
||||
<form method="post" autocomplete="off" novalidate>
|
||||
<nav id="template-list">
|
||||
${helpers.templatesAndFoldersCheckboxes(templatesAndFolders)}
|
||||
</nav>
|
||||
</form>`;
|
||||
|
||||
searchTextbox = document.getElementById('search');
|
||||
liveRegion = document.querySelector('.live-search__status');
|
||||
list = document.querySelector('form');
|
||||
|
||||
});
|
||||
|
||||
describe("When the page loads", () => {
|
||||
|
||||
test("If there is no search term, the results should be unchanged", () => {
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(listItems.length);
|
||||
expect(searchTextbox.hasAttribute('aria-label')).toBe(false);
|
||||
|
||||
});
|
||||
|
||||
test("If there is a single word search term, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'New';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
// should match 'New patient' and 'New doctor'
|
||||
expect(listItemsShowing.length).toEqual(2);
|
||||
expect(searchTextbox.hasAttribute('aria-label')).toBe(true);
|
||||
expect(searchTextbox.getAttribute('aria-label')).toEqual(`${searchLabelText}, ${liveRegionResults(2)}`);
|
||||
|
||||
});
|
||||
|
||||
test("If there is a search term made of several words, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'New patient';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(1);
|
||||
expect(searchTextbox.hasAttribute('aria-label')).toBe(true);
|
||||
expect(searchTextbox.getAttribute('aria-label')).toEqual(`${searchLabelText}, ${liveRegionResults(1)}`);
|
||||
|
||||
});
|
||||
|
||||
test("If an item doesn't match the search term but is selected, it should still show in the results", () => {
|
||||
|
||||
searchTextbox.value = 'New patient';
|
||||
|
||||
// mark 'Appointments' item as selected
|
||||
checkedItem = list.querySelector('input[id=templates-or-folder-0]');
|
||||
checkedItem.checked = true;
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// should show despite not matching
|
||||
expect(window.getComputedStyle(checkedItem).display).not.toEqual('none');
|
||||
|
||||
});
|
||||
|
||||
test("If the items have a block of text to match against, only results that match it should show", () => {
|
||||
|
||||
searchTextbox.value = 'Email template';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
// 2 items contain the "Email template" text
|
||||
// only the text containing the name of the item is matched against (ie 'New patient')
|
||||
expect(listItemsShowing.length).toEqual(0);
|
||||
expect(searchTextbox.getAttribute('aria-label')).toEqual(`${searchLabelText}, ${liveRegionResults(0)}`);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("When the search text changes", () => {
|
||||
|
||||
test("If there is no search term, the results should be unchanged", () => {
|
||||
|
||||
searchTextbox.value = 'Appointments';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate input of new search text
|
||||
searchTextbox.value = '';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(listItems.length);
|
||||
expect(liveRegion.textContent.trim()).toEqual(liveRegionResults(listItemsShowing.length));
|
||||
|
||||
});
|
||||
|
||||
test("If there is a single word search term, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'Appointments';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate input of new search text
|
||||
searchTextbox.value = 'Prescriptions';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(1);
|
||||
expect(liveRegion.textContent.trim()).toEqual(liveRegionResults(1));
|
||||
|
||||
});
|
||||
|
||||
test("If there is a search term made of several words, only the results that match should show", () => {
|
||||
|
||||
searchTextbox.value = 'Appointments';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate input of new search text
|
||||
searchTextbox.value = 'New doctor';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
expect(listItemsShowing.length).toEqual(1);
|
||||
expect(liveRegion.textContent.trim()).toEqual(liveRegionResults(1));
|
||||
|
||||
});
|
||||
|
||||
test("If an item doesn't match the search term but is selected, it should still show in the results", () => {
|
||||
|
||||
searchTextbox.value = 'Appointments';
|
||||
|
||||
// mark 'Appointments' item as selected
|
||||
checkedItem = list.querySelector('input[id=templates-or-folder-0]');
|
||||
checkedItem.checked = true;
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate input of new search text
|
||||
searchTextbox.value = 'Prescriptions';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
// should show despite not matching
|
||||
expect(window.getComputedStyle(checkedItem).display).not.toEqual('none');
|
||||
|
||||
});
|
||||
|
||||
test("If the items have a block of text to match against, only results that match it should show", () => {
|
||||
|
||||
searchTextbox.value = 'Appointments';
|
||||
|
||||
// start the module
|
||||
window.GOVUK.modules.start();
|
||||
|
||||
// simulate input of new search text
|
||||
searchTextbox.value = 'Email template';
|
||||
helpers.triggerEvent(searchTextbox, 'input');
|
||||
|
||||
const listItems = list.querySelectorAll('.template-list-item');
|
||||
const listItemsShowing = Array.from(listItems).filter(item => window.getComputedStyle(item).display !== 'none');
|
||||
|
||||
// 2 items contain the "Email template" text
|
||||
// only the text containing the name of the item is matched against (ie 'New patient')
|
||||
expect(listItemsShowing.length).toEqual(0);
|
||||
expect(liveRegion.textContent.trim()).toEqual(liveRegionResults(0));
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
})
|
||||
|
||||
describe("With a list of content items", () => {
|
||||
|
||||
searchLabelText = "Search by name or email address";
|
||||
|
||||
@@ -1,234 +0,0 @@
|
||||
const helpers = require('./support/helpers.js');
|
||||
|
||||
const emailPageURL = '/services/6658542f-0cad-491f-bec8-ab8457700ead/service-settings/set-email-branding';
|
||||
const emailPreviewConfirmationURL = '/services/6658542f-0cad-491f-bec8-ab8457700ead/service-settings/preview-email-branding';
|
||||
const letterPageURL = '/services/6658542f-0cad-491f-bec8-ab8457700ead/service-settings/set-letter-branding';
|
||||
const letterPreviewConfirmationURL = '/services/6658542f-0cad-491f-bec8-ab8457700ead/service-settings/preview-letter-branding';
|
||||
|
||||
let locationMock;
|
||||
|
||||
beforeAll(() => {
|
||||
|
||||
// mock calls to window.location
|
||||
// default to the email page, the pathname can be changed inside specific tests
|
||||
locationMock = new helpers.LocationMock(emailPageURL);
|
||||
|
||||
});
|
||||
|
||||
afterAll(() => {
|
||||
|
||||
// reset window.location to its original state
|
||||
locationMock.reset();
|
||||
require('./support/teardown.js');
|
||||
|
||||
});
|
||||
|
||||
describe('Preview pane', () => {
|
||||
|
||||
let form;
|
||||
let radios;
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
const brands = {
|
||||
"name": "branding_style",
|
||||
"label": "Branding style",
|
||||
"cssClasses": [],
|
||||
"fields": [
|
||||
{
|
||||
"label": "Department for Education",
|
||||
"value": "dfe",
|
||||
"checked": true
|
||||
},
|
||||
{
|
||||
"label": "Home Office",
|
||||
"value": "ho",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"label": "Her Majesty's Revenue and Customs",
|
||||
"value": "hmrc",
|
||||
"checked": false
|
||||
},
|
||||
{
|
||||
"label": "Department for Work and Pensions",
|
||||
"value": "dwp",
|
||||
"checked": false
|
||||
}
|
||||
]
|
||||
};
|
||||
|
||||
// set up DOM
|
||||
document.body.innerHTML =
|
||||
`<form method="post" action="${emailPageURL}" autocomplete="off" data-preview-type="email" novalidate>
|
||||
<div class="govuk-grid-row"></div>
|
||||
<div class="govuk-grid-row">
|
||||
<div class="govuk-grid-column-full">
|
||||
<div data-module="autofocus">
|
||||
<div class="live-search js-header" data-module="live-search" data-targets=".usa-radio">
|
||||
<div class="form-group">
|
||||
<label class="form-label" for="search">
|
||||
Search branding styles by name
|
||||
</label>
|
||||
<input autocomplete="off" class="form-control form-control-1-1 " id="search" name="search" required="" rows="8" type="search" value="">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="page-footer">
|
||||
<button type="submit" class="govuk-button">Preview</button>
|
||||
</div>
|
||||
</form>`;
|
||||
|
||||
document.querySelector('.govuk-grid-column-full').appendChild(helpers.getRadioGroup(brands));
|
||||
form = document.querySelector('form');
|
||||
radios = form.querySelector('fieldset');
|
||||
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
|
||||
document.body.innerHTML = '';
|
||||
|
||||
// we run the previewPane.js script every test
|
||||
// the module cache needs resetting each time for the script to execute
|
||||
jest.resetModules();
|
||||
|
||||
});
|
||||
|
||||
describe("If the page type is 'email'", () => {
|
||||
|
||||
describe("When the page loads", () => {
|
||||
|
||||
test("it should add the preview pane", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
expect(document.querySelector('iframe')).not.toBeNull();
|
||||
|
||||
});
|
||||
|
||||
test("it should change the form to submit the selection instead of posting to a preview page", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
expect(form.getAttribute('action')).toEqual(emailPreviewConfirmationURL);
|
||||
|
||||
});
|
||||
|
||||
test("the preview pane should show the page for the selected brand", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
const selectedValue = Array.from(radios.querySelectorAll('input[type=radio]')).filter(radio => radio.checked)[0].value;
|
||||
|
||||
expect(document.querySelector('iframe').getAttribute('src')).toEqual(`/_email?branding_style=${selectedValue}`);
|
||||
|
||||
});
|
||||
|
||||
test("the submit button should change from 'Preview' to 'Save'", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
expect(document.querySelector('button[type=submit]').textContent).toEqual('Save');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("If the selection changes", () => {
|
||||
|
||||
test("the page shown should match the selected brand", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
const newSelection = radios.querySelectorAll('input[type=radio]')[1];
|
||||
|
||||
helpers.moveSelectionToRadio(newSelection);
|
||||
|
||||
expect(document.querySelector('iframe').getAttribute('src')).toEqual(`/_email?branding_style=${newSelection.value}`);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("If the page type is 'letter'", () => {
|
||||
|
||||
beforeEach(() => {
|
||||
|
||||
// set page URL and page type to 'letter'
|
||||
window.location.pathname = letterPreviewConfirmationURL;
|
||||
form.setAttribute('data-preview-type', 'letter');
|
||||
|
||||
});
|
||||
|
||||
describe("When the page loads", () => {
|
||||
|
||||
test("it should add the preview pane", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
expect(document.querySelector('iframe')).not.toBeNull();
|
||||
|
||||
});
|
||||
|
||||
test("it should change the form to submit the selection instead of posting to a preview page", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
expect(form.getAttribute('action')).toEqual(letterPreviewConfirmationURL);
|
||||
|
||||
});
|
||||
|
||||
test("the preview pane should show the page for the selected brand", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
const selectedValue = Array.from(radios.querySelectorAll('input[type=radio]')).filter(radio => radio.checked)[0].value;
|
||||
|
||||
expect(document.querySelector('iframe').getAttribute('src')).toEqual(`/_letter?branding_style=${selectedValue}`);
|
||||
|
||||
});
|
||||
|
||||
test("the submit button should change from 'Preview' to 'Save'", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
expect(document.querySelector('button[type=submit]').textContent).toEqual('Save');
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe("If the selection changes", () => {
|
||||
|
||||
test("the page shown should match the selected brand", () => {
|
||||
|
||||
// run preview pane script
|
||||
require('../../app/assets/javascripts/previewPane.js');
|
||||
|
||||
const newSelection = radios.querySelectorAll('input[type=radio]')[1];
|
||||
|
||||
helpers.moveSelectionToRadio(newSelection);
|
||||
|
||||
expect(document.querySelector('iframe').getAttribute('src')).toEqual(`/_letter?branding_style=${newSelection.value}`);
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
Reference in New Issue
Block a user