Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style(EMS-4039): declarations - modern slavery - definition of terms #3412

Merged
merged 5 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@
"npmrc",
"numbergenerator",
"NVARCHAR",
"OHCHR",
"octocat",
"organisation",
"osgb",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,85 @@ export const MODERN_SLAVERY = {
},
IF_YOU_SAY_NO: 'If you say no to any of the questions you must explain why.',
},
EXPANDABLE: {
VERSIONS: [
{
VERSION: '1',
INTRO: 'Definition of terms in this declaration',
TABLE: {
HEADERS: {
TERM: 'Term',
DEFINITION: 'Definition',
},
BODY: [
{
TERM: 'Holding company',
DEFINITION: [{ TEXT: 'Means, in relation to a person, any other person in respect of which it is a Subsidiary.' }],
},
{
TERM: 'Modern slavery',
DEFINITION: [
{
TEXT: 'Means the recruitment, movement, harbouring or receiving of children, women or men through the use of force, coercion, abuse of vulnerability, deception or other means for the purpose of exploitation and includes holding a person in a position of slavery, servitude forced or compulsory labour, or facilitating their travel with the intention of exploiting them soon after.',
},
],
},
{
TERM: 'Subsidiary',
DEFINITION: [
{
CHILDREN: [
{
TEXT: 'Means a subsidiary within the meaning of ',
},
{
HREF: '#',
Zainzzkk marked this conversation as resolved.
Show resolved Hide resolved
TEXT: 'section 1159 of the Companies Act 2006',
},
{
TEXT: '.',
},
],
},
],
},
{
TERM: 'The Modern Slavery Act 2015',
DEFINITION: [
{
CHILDREN: [
{
TEXT: 'The ',
},
{
HREF: '#',
TEXT: 'Modern Slavery Act 2015',
},
{
TEXT: ' is an Act of the Parliament of the United Kingdom. It is designed to combat modern slavery in the UK and consolidates previous offences relating to trafficking and slavery. The Act also imposes reporting obligations on businesses that exceed a given annual turnover value and that carry out business in the UK. Please refer to ',
},
{
HREF: '#',
TEXT: 'the guidance on the reporting obligations established by the Act',
},
{
TEXT: 'for further information.',
},
],
},
],
},
{
TERM: 'UN Guiding Principles on Business and Human Rights',
DEFINITION: [
{
TEXT: 'The UN Guiding Principles on Business and Human Rights (Guiding Principles on Business and Human Rights: Implementing the United Nations “Protect, Respect and Remedy” Framework | OHCHR) provide guidance and advice on the approach companies should take to respecting human rights wherever they operate.',
},
],
},
],
},
},
],
},
};
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { antiBriberyPage } from '../../../../../../pages/insurance/declarations';
import { expandable } from '../../../../../../partials';
import { PAGES } from '../../../../../../content-strings';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';

Expand All @@ -11,8 +11,6 @@ const {
},
} = INSURANCE_ROUTES;

const { expandable } = antiBriberyPage;

const { INTRO, TABLE } = CONTENT_STRINGS.EXPANDABLE;

const baseUrl = Cypress.config('baseUrl');
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
import { expandable } from '../../../../../../partials';
import { PAGES } from '../../../../../../content-strings';
import { INSURANCE_ROUTES } from '../../../../../../constants/routes/insurance';

const CONTENT_STRINGS = PAGES.INSURANCE.DECLARATIONS.MODERN_SLAVERY.EXPANDABLE.VERSIONS[0];

const {
ROOT: INSURANCE_ROOT,
DECLARATIONS: { MODERN_SLAVERY },
} = INSURANCE_ROUTES;

const { INTRO, TABLE } = CONTENT_STRINGS;

// TODO: DRY - with anti bribery expandable content
ttbarnes marked this conversation as resolved.
Show resolved Hide resolved
const assertTermColumn = (selector, content) => {
cy.checkText(selector, content.TERM);
};

const baseUrl = Cypress.config('baseUrl');

context('Insurance - Declarations - Modern slavery page - expandable `definition` content', () => {
let referenceNumber;
let url;

before(() => {
cy.completeSignInAndGoToApplication({}).then(({ referenceNumber: refNumber }) => {
referenceNumber = refNumber;

url = `${baseUrl}${INSURANCE_ROOT}/${referenceNumber}${MODERN_SLAVERY}`;

cy.navigateToUrl(url);
cy.assertUrl(url);
});
});

beforeEach(() => {
cy.saveSession();

cy.navigateToUrl(url);
});

after(() => {
cy.deleteApplication(referenceNumber);
});

it('renders summary text', () => {
expandable.summary().should('exist');

cy.checkText(expandable.summary(), INTRO);
});

it('clicking summary text reveals details', () => {
expandable.summary().click();

expandable.table.headers.term().should('be.visible');
expandable.table.headers.definition().should('be.visible');
});

describe('table', () => {
const { BODY, HEADERS } = TABLE;

let row;
let content;

it('renders table headers', () => {
expandable.summary().click();

cy.checkText(expandable.table.headers.term(), HEADERS.TERM);
cy.checkText(expandable.table.headers.definition(), HEADERS.DEFINITION);
});

describe('body row 1', () => {
beforeEach(() => {
expandable.summary().click();

row = expandable.table.body.row(1);

const { 0: contentRow } = BODY;
content = contentRow;
});

it('renders `term` column', () => {
assertTermColumn(row.term(), content);
});

it('renders `definition` column', () => {
cy.checkText(row.definition(), content.DEFINITION[0].TEXT);
});
});

describe('body row 2', () => {
beforeEach(() => {
expandable.summary().click();

row = expandable.table.body.row(2);

const { 1: contentRow } = BODY;
content = contentRow;
ttbarnes marked this conversation as resolved.
Show resolved Hide resolved
});

it('renders `term` column', () => {
assertTermColumn(row.term(), content);
});

it('renders `definition` column', () => {
cy.checkText(row.definition(), content.DEFINITION[0].TEXT);
});
});

describe('body row 3', () => {
beforeEach(() => {
expandable.summary().click();

row = expandable.table.body.row(3);

const { 2: contentRow } = BODY;
content = contentRow;
});

it('renders `term` column', () => {
assertTermColumn(row.term(), content);
});

it('renders `definition` column', () => {
row
.definitionListItemChild(1, 1)
.invoke('text')
.then((text) => {
expect(text).includes(content.DEFINITION[0].CHILDREN[0].TEXT);
ttbarnes marked this conversation as resolved.
Show resolved Hide resolved
});

cy.checkLink(row.definitionListItemChild(1, 2), '#', content.DEFINITION[0].CHILDREN[1].TEXT);

cy.checkText(row.definitionListItemChild(1, 3), content.DEFINITION[0].CHILDREN[2].TEXT);
});
});

describe('body row 4', () => {
beforeEach(() => {
expandable.summary().click();

row = expandable.table.body.row(4);

const { 3: contentRow } = BODY;
content = contentRow;
});

it('renders `term` column', () => {
assertTermColumn(row.term(), content);
});

it('renders `definition` column', () => {
row
.definitionListItemChild(1, 1)
.invoke('text')
.then((text) => {
expect(text).includes(content.DEFINITION[0].CHILDREN[0].TEXT);
});

cy.checkLink(row.definitionListItemChild(1, 2), '#', content.DEFINITION[0].CHILDREN[1].TEXT);

row
.definitionListItemChild(1, 3)
.invoke('text')
.then((text) => {
expect(text).includes(content.DEFINITION[0].CHILDREN[2].TEXT);
});

cy.checkLink(row.definitionListItemChild(1, 4), '#', content.DEFINITION[0].CHILDREN[3].TEXT);

row
.definitionListItemChild(1, 5)
.invoke('text')
.then((text) => {
expect(text).includes(content.DEFINITION[0].CHILDREN[4].TEXT);
});
});
});

describe('body row 5', () => {
beforeEach(() => {
expandable.summary().click();

row = expandable.table.body.row(5);

const { 4: contentRow } = BODY;
content = contentRow;
});

it('renders `term` column', () => {
assertTermColumn(row.term(), content);
});

it('renders `definition` column', () => {
cy.checkText(row.definition(), content.DEFINITION[0].TEXT);
});
});
});
});
17 changes: 0 additions & 17 deletions e2e-tests/pages/insurance/declarations/anti-bribery.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,6 @@ const antiBriberyPage = {
item: (itemNumber) => cy.get('.lower-alpha-counter-list').last().children(`[data-cy='list-level-2-item-${itemNumber}']`),
},
},
expandable: {
summary: () => cy.get('[data-cy="definition-of-terms"] summary'),
details: () => cy.get('[data-cy="definition-of-terms"]'),
table: {
headers: {
term: () => cy.get('[data-cy="header-term"]'),
definition: () => cy.get('[data-cy="header-definition"]'),
},
body: {
row: (row) => ({
term: () => cy.get(`[data-cy="row-${row}-cell-term"]`),
definition: () => cy.get(`[data-cy="row-${row}-cell-definition"]`),
definitionListItem: (listItem) => cy.get(`[data-cy="row-${row}-cell-definition-list-item-${listItem}"]`),
}),
},
},
},
};

export default antiBriberyPage;
18 changes: 18 additions & 0 deletions e2e-tests/partials/expandable.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const expandable = {
summary: () => cy.get('[data-cy="definition-of-terms"] summary'),
details: () => cy.get('[data-cy="definition-of-terms"]'),
table: {
headers: {
term: () => cy.get('[data-cy="header-term"]'),
definition: () => cy.get('[data-cy="header-definition"]'),
},
body: {
row: (row) => ({
term: () => cy.get(`[data-cy="row-${row}-cell-term"]`),
definition: () => cy.get(`[data-cy="row-${row}-cell-definition"]`),
definitionListItem: (listItem) => cy.get(`[data-cy="row-${row}-cell-definition-list-item-${listItem}"]`),
definitionListItemChild: (listItem, childItem) => cy.get(`[data-cy="row-${row}-cell-definition-list-item-${listItem}-child-${childItem}"]`),
}),
},
},
};
1 change: 1 addition & 0 deletions e2e-tests/partials/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export * from './contactDetails';
export * from './cookieBanner';
export * from './creditPeriodWithBuyer';
export * from './errorSummaryList';
export * from './expandable';
export * from './footer';
export * from './header';
export * from './headingCaption';
Expand Down
Loading
Loading