From 71314581b42b2db2bf1ce15f7dc0d3842c3a78d2 Mon Sep 17 00:00:00 2001 From: Andrew Steele Date: Thu, 19 Dec 2024 11:33:19 -0500 Subject: [PATCH] Updates to va-statement-of-truth tests --- .../test/va-statement-of-truth.e2e.ts | 42 +++++++++++++------ 1 file changed, 29 insertions(+), 13 deletions(-) diff --git a/packages/web-components/src/components/va-statement-of-truth/test/va-statement-of-truth.e2e.ts b/packages/web-components/src/components/va-statement-of-truth/test/va-statement-of-truth.e2e.ts index 997d600e7..6bd1ffc6d 100644 --- a/packages/web-components/src/components/va-statement-of-truth/test/va-statement-of-truth.e2e.ts +++ b/packages/web-components/src/components/va-statement-of-truth/test/va-statement-of-truth.e2e.ts @@ -62,7 +62,9 @@ describe('va-statement-of-truth', () => { const page = await newE2EPage(); await page.setContent(''); const vaCheckboxChangeSpy = await page.spyOnEvent('vaCheckboxChange'); - const checkboxEl = await page.find('va-statement-of-truth >>> va-checkbox >>> label.usa-checkbox__label'); + const checkboxEl = await page.find( + 'va-statement-of-truth >>> va-checkbox >>> label', + ); await checkboxEl.click(); expect(vaCheckboxChangeSpy).toHaveReceivedEvent(); }); @@ -76,7 +78,9 @@ describe('va-statement-of-truth', () => { it('sets an input aria described by message', async () => { const page = await newE2EPage(); - await page.setContent(''); + await page.setContent( + '', + ); const span = await page.$('pierce/span#input-message'); const text = await page.evaluate(element => element.textContent, span); expect(text).toContain('testing one two three'); @@ -84,28 +88,40 @@ describe('va-statement-of-truth', () => { it('permits prefilling the form', async () => { const page = await newE2EPage(); - await page.setContent(''); - - const value = await page.$eval('va-statement-of-truth >>> va-text-input >>> input', (comp: HTMLInputElement) => comp.value); + await page.setContent( + '', + ); + + const value = await page.$eval( + 'va-statement-of-truth >>> va-text-input >>> input', + (comp: HTMLInputElement) => comp.value, + ); expect(value).toBe('John Doe'); - const checked = await page.$eval('va-statement-of-truth >>> va-checkbox >>> input', (comp: HTMLInputElement) => comp.checked); + const checked = await page.$eval( + 'va-statement-of-truth >>> va-checkbox >>> input', + (comp: HTMLInputElement) => comp.checked, + ); expect(checked).toBeTruthy(); }); it('adds custom label to va-text-input', async () => { const page = await newE2EPage(); await page.setContent(''); - const labelEl = await page.$('pierce/label.usa-label'); - const text = await page.evaluate(element => element.textContent, labelEl); - expect(text).toContain('test label'); + const textInputEl = await page.find( + 'va-statement-of-truth >>> va-text-input', + ); + const textInputLabel = await textInputEl.getProperty('label'); + expect(textInputLabel).toBe('test label'); }); it('adds custom label to va-checkbox', async () => { const page = await newE2EPage(); - await page.setContent(''); - const labelEl = await page.$('pierce/label.usa-checkbox__label'); - const text = await page.evaluate(element => element.textContent, labelEl); - expect(text).toContain('test label'); + await page.setContent( + '', + ); + const checkboxEl = await page.find('va-statement-of-truth >>> va-checkbox'); + const checkboxLabel = await checkboxEl.getProperty('label'); + expect(checkboxLabel).toBe('test label'); }); })