Skip to content

Commit

Permalink
Rearrange tests to assume text commenting is disabled by default
Browse files Browse the repository at this point in the history
  • Loading branch information
mikemonteith committed Oct 22, 2020
1 parent 5b54a38 commit bba15f3
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="nhsuk-width-container">
<main class="nhsuk-main-wrapper">
<h1>User feedback form:</h1>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/"></div>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/" data-enable-text-response></div>

<!--
If you have the user-feedback-store running locally and want to test it, the endpoint setting should probably be this:
Expand Down
2 changes: 1 addition & 1 deletion tests/example/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="nhsuk-width-container">
<main class="nhsuk-main-wrapper">
<h1>User feedback form:</h1>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/" data-enable-text-response></div>
<div id="nhsuk-user-feedback-form" data-form-endpoint="http://localhost:8080/my-endpoint/"></div>

<!--
If you have the user-feedback-store running locally and want to test it, the endpoint setting should probably be this:
Expand Down
8 changes: 5 additions & 3 deletions tests/integration/answer-no.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,14 @@ describe('Can answer no', () => {
expect(noButton).not.toBe(null);
});

it('should proceed to next question', async () => {
it('should proceed to confirmation page', async () => {
const yesButton = await page.$('.nhsuk-user-feedback-form--no');
await yesButton.click();

const labelText = await page.$eval('label', (element) => element.innerText);
expect(labelText).toBe('What were you looking for? (optional)');
const title = await page.$('h2');
expect(title).not.toBe(null);
const text = await page.evaluate((element) => element.innerText, title);
expect(text).toBe('Thank you for your feedback.');
});

it('should register a negative vote', async (done) => {
Expand Down
6 changes: 4 additions & 2 deletions tests/integration/answer-yes.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ describe('Can answer yes', () => {
const yesButton = await page.$('.nhsuk-user-feedback-form--yes');
await yesButton.click();

const labelText = await page.$eval('label', (element) => element.innerText);
expect(labelText).toBe('What happened to make you visit the NHS website today? (optional)');
const title = await page.$('h2');
expect(title).not.toBe(null);
const text = await page.evaluate((element) => element.innerText, title);
expect(text).toBe('Thank you for your feedback.');
});

it('should register a positive vote', async (done) => {
Expand Down
3 changes: 1 addition & 2 deletions tests/integration/confirmation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
beforeEach(async () => {
await page.goto('http://localhost:8080/tests/example/');
await page.click('.nhsuk-user-feedback-form--yes');
await page.click('.nhsuk-user-feedback-form--submit');
});

describe('Confirmation text', () => {
Expand All @@ -20,6 +19,6 @@ describe('Confirmation text', () => {
expect(message).not.toBe(null);

const text = await page.evaluate((element) => element.innerText, message);
expect(text).toBe('We do not check feedback every day and cannot respond to comments.');
expect(text).toBe('Find out how to contact the NHS if you need to speak to someone.');
});
});
25 changes: 0 additions & 25 deletions tests/integration/disable-text-response.test.js

This file was deleted.

4 changes: 3 additions & 1 deletion tests/integration/text-comments.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/* global page expect */

beforeEach(async () => {
await page.goto('http://localhost:8080/tests/example/');
// Text commenting is disabled at /tests/example/index.html,
// we need to use enabled-text-response.html instead.
await page.goto('http://localhost:8080/tests/example/enabled-text-response.html');
await page.click('.nhsuk-user-feedback-form--yes');
});

Expand Down

0 comments on commit bba15f3

Please sign in to comment.