Skip to content

Commit

Permalink
Merge pull request #4330 from alphagov/puppeteer-arguments
Browse files Browse the repository at this point in the history
Support `beforeInitialisation()` options, multiple modules
  • Loading branch information
colinrotherham authored Oct 17, 2023
2 parents 94e66e6 + e9842b7 commit dd74830
Show file tree
Hide file tree
Showing 12 changed files with 344 additions and 277 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -685,8 +685,7 @@ describe('/components/accordion', () => {
})

it('injects the localised strings as text not HTML', async () => {
await renderAndInitialise(page, 'accordion', {
params: examples.default,
await renderAndInitialise(page, 'accordion', examples.default, {
config: {
i18n: {
showAllSections: 'Show <strong>all sections</strong>',
Expand Down Expand Up @@ -722,8 +721,7 @@ describe('/components/accordion', () => {

it('throws when GOV.UK Frontend is not supported', async () => {
await expect(
renderAndInitialise(page, 'accordion', {
params: examples.default,
renderAndInitialise(page, 'accordion', examples.default, {
beforeInitialisation() {
document.body.classList.remove('govuk-frontend-supported')
}
Expand All @@ -736,8 +734,7 @@ describe('/components/accordion', () => {

it('throws when $module is not set', async () => {
await expect(
renderAndInitialise(page, 'accordion', {
params: examples.default,
renderAndInitialise(page, 'accordion', examples.default, {
beforeInitialisation($module) {
$module.remove()
}
Expand All @@ -750,8 +747,7 @@ describe('/components/accordion', () => {

it('throws when receiving the wrong type for $module', async () => {
await expect(
renderAndInitialise(page, 'accordion', {
params: examples.default,
renderAndInitialise(page, 'accordion', examples.default, {
beforeInitialisation($module) {
// Replace with an `<svg>` element which is not an `HTMLElement` in the DOM (but an `SVGElement`)
$module.outerHTML = `<svg data-module="govuk-accordion"></svg>`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,7 @@ describe('/components/button', () => {
let $button

beforeEach(async () => {
await renderAndInitialise(page, 'button', {
params: examples.default,
await renderAndInitialise(page, 'button', examples.default, {
config: {
preventDoubleClick: true
}
Expand Down Expand Up @@ -238,12 +237,16 @@ describe('/components/button', () => {
let $button

beforeEach(async () => {
await renderAndInitialise(page, 'button', {
params: examples["don't prevent double click"],
config: {
preventDoubleClick: true
await renderAndInitialise(
page,
'button',
examples["don't prevent double click"],
{
config: {
preventDoubleClick: true
}
}
})
)

$button = await setButtonTracking(await page.$('button'))
})
Expand All @@ -263,8 +266,7 @@ describe('/components/button', () => {
let $button

beforeEach(async () => {
await renderAndInitialise(page, 'button', {
params: examples.default,
await renderAndInitialise(page, 'button', examples.default, {
config: {
preventDoubleClick: true
}
Expand Down Expand Up @@ -327,8 +329,7 @@ describe('/components/button', () => {

it('throws when GOV.UK Frontend is not supported', async () => {
await expect(
renderAndInitialise(page, 'button', {
params: examples.default,
renderAndInitialise(page, 'button', examples.default, {
beforeInitialisation() {
document.body.classList.remove('govuk-frontend-supported')
}
Expand All @@ -341,8 +342,7 @@ describe('/components/button', () => {

it('throws when $module is not set', async () => {
await expect(
renderAndInitialise(page, 'button', {
params: examples.default,
renderAndInitialise(page, 'button', examples.default, {
beforeInitialisation($module) {
$module.remove()
}
Expand All @@ -355,8 +355,7 @@ describe('/components/button', () => {

it('throws when receiving the wrong type for $module', async () => {
await expect(
renderAndInitialise(page, 'button', {
params: examples.default,
renderAndInitialise(page, 'button', examples.default, {
beforeInitialisation($module) {
// Replace with an `<svg>` element which is not an `HTMLElement` in the DOM (but an `SVGElement`)
$module.outerHTML = `<svg data-module="govuk-button"></svg>`
Expand Down
Loading

0 comments on commit dd74830

Please sign in to comment.