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

WIP: Update Jest Coverage and Fix a11y Async Errors #567

Open
wants to merge 35 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
79da00f
Fix a11y async errors by flushing promises first
jjbennett Sep 24, 2021
52245b5
Merge ae441d22dbd935379753e2ada5618665169f8c0f into feature/234__jest…
salesforce-org-metaci[bot] Sep 24, 2021
1dcd5fa
Add the index to the service delivery records.
jjbennett Sep 25, 2021
33f048e
Merge branch 'feature/234__jest-test-updates' of github.com:Salesforc…
jjbennett Sep 25, 2021
282c63e
Add jest tests for accordion section and move aria text from icon to …
jjbennett Sep 27, 2021
e2fdb28
Return the a11y check to ensure we wait for it to finish.
jjbennett Sep 27, 2021
ed7b902
Verify each theme and a11y for each.
jjbennett Sep 27, 2021
54e0395
Remove inner flush, added by mistake.
jjbennett Sep 27, 2021
09a2c23
Remove a11y when modal is closed, the component lives within the modal.
jjbennett Sep 27, 2021
4dd4ce3
Fix new tests.
jjbennett Sep 27, 2021
7c561c7
Merge 8b33e5b5cdf19088f02918bb37d0643ab0f75262 into feature/234__jest…
salesforce-org-metaci[bot] Sep 29, 2021
3d47e94
Update jest tests on attendance.
jjbennett Oct 1, 2021
b325db7
Merge 833935283677dbd61a953d88c3b1069efeef7961 into feature/234__jest…
salesforce-org-metaci[bot] Oct 6, 2021
1093e1f
Merge bd1e542714d15863079fa6dae1d648249aa128c0 into feature/234__jest…
salesforce-org-metaci[bot] Oct 19, 2021
3a7f83f
Merge 3f64e7f99dc6084fcbc4f151af333e629d7df591 into feature/234__jest…
salesforce-org-metaci[bot] Oct 22, 2021
96847b1
Resolve merge conflicts
jjbennett Feb 4, 2022
cbda8b3
Remove getFieldSet test data, no longer calling the method separately.
jjbennett Feb 4, 2022
576c577
Add comment update year
jjbennett Feb 4, 2022
bbbc3d5
Merge aa91874b2c162707cee4407b806ff6e87b537aa9 into feature/238__jest…
salesforce-org-metaci[bot] Feb 4, 2022
c75cd64
Merge 10aad62a0b3a5930136c4be6ef0e762384bf2513 into feature/238__jest…
salesforce-org-metaci[bot] Feb 4, 2022
8634675
Merge e96b0329b14e448ade53089cdcd55e1fd2c5aa54 into feature/238__jest…
salesforce-org-metaci[bot] Feb 7, 2022
4485c20
Merge b2ba11bc7d4f32c54ee9af2ca784101fe1f00b4d into feature/238__jest…
salesforce-org-metaci[bot] Feb 14, 2022
56a55ce
Merge b9ebd4101022b141660397c5a88f76b5d7e7bf10 into feature/238__jest…
salesforce-org-metaci[bot] Feb 15, 2022
17589ef
Resolve merge conflict.
jjbennett Mar 2, 2022
35ffbb6
Merge c07fceb2a6b9e2569b30b4bee2a33d4672ec22bd into feature/238__jest…
salesforce-org-metaci[bot] Mar 8, 2022
4342be8
Merge 969c03f3803349277643582a1f0a05daa4c18e11 into feature/238__jest…
salesforce-org-metaci[bot] Mar 8, 2022
7a0c253
Merge 69751606371d920b6fa9632314c59917c86082ea into feature/238__jest…
salesforce-org-metaci[bot] Mar 10, 2022
a74f771
Resolve merge conflicts.
jjbennett Mar 24, 2022
44167ac
Merge 6d350b9d3e5fb9adcb4fb41b6ebd8dac6f500676 into feature/238__jest…
salesforce-org-metaci[bot] Mar 24, 2022
5965f9e
Merge a305bb2888d74d9e0ddd7fa24a74d94c92c17555 into feature/238__jest…
salesforce-org-metaci[bot] Mar 24, 2022
2e20e1a
Merge 3e7199642df34c1e8c145665f3d0714abcdb80eb into feature/238__jest…
salesforce-org-metaci[bot] Mar 25, 2022
d529af3
Merge 6ce577bb637dcc9cb1b51ac1bd24b223ae34da82 into feature/238__jest…
salesforce-org-metaci[bot] Mar 30, 2022
c400a19
Resolve merge conflicts.
jjbennett Mar 30, 2022
5abe22a
Merge ea44ed921bdac6507ac3fe054276f3cb1f21cb6a into feature/238__jest…
salesforce-org-metaci[bot] Mar 30, 2022
8ee4fae
Merge 6399e8f9ab5b28f853cfbd067eece5818f7f9ef0 into feature/238__jest…
salesforce-org-metaci[bot] Mar 31, 2022
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
6 changes: 6 additions & 0 deletions force-app/main/default/lwc/__tests__/data/apexError.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"body": { "message": "An internal server error has occurred" },
"ok": false,
"status": 400,
"statusText": "Bad Request"
}
36 changes: 36 additions & 0 deletions force-app/main/default/lwc/__tests__/lightning/uiRecordApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018, salesforce.com, inc.
* All rights reserved.
* SPDX-License-Identifier: MIT
* For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/MIT
*/
export const getRecord = jest.fn();
export const getRecordCreateDefaults = jest.fn();
export const updateRecord = jest.fn();
export const createRecord = jest.fn().mockResolvedValue({});
export const deleteRecord = jest.fn().mockResolvedValue();
export const generateRecordInputForCreate = jest.fn();
export const generateRecordInputForUpdate = jest.fn();
export const createRecordInputFilteredByEditedFields = jest.fn();
export const getRecordInput = jest.fn();
export const refresh = jest.fn().mockResolvedValue();
export const getRecordUi = jest.fn();
export const getFieldValue = jest.fn((data, fieldReference) => {
if (data) {
const fields = fieldReference.fieldApiName.split(".");
if (data.result) {
const fieldData = fields.reduce((o, i) => o[i], data.result.fields);
if (fieldData && fieldData.value) {
return fieldData.value;
}
} else {
const fieldData = fields.reduce((o, i) => o[i], data.fields);
if (fieldData && fieldData.value) {
return fieldData.value;
}
}
return null;
}
return null;
});
export const getFieldDisplayValue = jest.fn();
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
/*
*
* * Copyright (c) 2020, salesforce.com, inc.
* * All rights reserved.
* * SPDX-License-Identifier: BSD-3-Clause
* * For full license text, see the LICENSE file in the repo root or https://opensource.org/licenses/BSD-3-Clause
*
*/

import { createElement } from "lwc";
import AccordionSection from "c/accordionSection";

describe("c-accordionSection", () => {
let element;

afterEach(global.clearDOM);

beforeEach(() => {
element = createElement("c-accordionSection", {
is: AccordionSection,
});
});

it("is closed by default", () => {
document.body.appendChild(element);

return global.flushPromises().then(() => {
const button = element.shadowRoot.querySelector("button");
expect(button.ariaExpanded).toBe("false");
return global.isAccessible(element);
});
});

it("is open when open current section is true", () => {
element.openCurrentSection = true;
document.body.appendChild(element);

return global.flushPromises().then(() => {
const button = element.shadowRoot.querySelector("button");
expect(button.ariaExpanded).toBe("true");
return global.isAccessible(element);
});
});

it("is accessible with background shaded", () => {
element.shadeOnOpen = "#EFEFEF";
element.openCurrentSection = true;
document.body.appendChild(element);

return global.flushPromises().then(() => {
// TODO: see if we can verify background color
return global.isAccessible(element);
});
});

it("opens", () => {
document.body.appendChild(element);
element.open();

return global.flushPromises().then(() => {
const button = element.shadowRoot.querySelector("button");
expect(button.ariaExpanded).toBe("true");
return global.isAccessible(element);
});
});

it("closes", () => {
element.openCurrentSection = true;
document.body.appendChild(element);
element.close();

return global.flushPromises().then(() => {
const button = element.shadowRoot.querySelector("button");
expect(button.ariaExpanded).toBe("false");
return global.isAccessible(element);
});
});

it("does not open when prevent toggle is set", () => {
element.preventToggle = true;
document.body.appendChild(element);
element.open();

return global.flushPromises().then(() => {
const button = element.shadowRoot.querySelector("button");
expect(button.ariaExpanded).toBe("false");
return global.isAccessible(element);
});
});

it("override open overrides prevent toggle and opens", () => {
element.preventToggle = true;
document.body.appendChild(element);
element.overrideOpen();

return global.flushPromises().then(() => {
const button = element.shadowRoot.querySelector("button");
expect(button.ariaExpanded).toBe("true");
return global.isAccessible(element);
});
});

it("opens on button click", () => {
document.body.appendChild(element);
const button = element.shadowRoot.querySelector("button");
button.click();

return global.flushPromises().then(() => {
expect(button.ariaExpanded).toBe("true");
return global.isAccessible(element);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
<!-- sldsValidatorIgnore -->
<!--
- /*
- * Copyright (c) 2020, salesforce.com, inc.
Expand All @@ -21,11 +22,11 @@
onclick={handleToggle}
aria-controls="accordion-details"
aria-expanded={isOpen}
aria-label={toggleInstructions}
class="slds-align-middle slds-text-link_reset slds-button"
>
<lightning-icon
icon-name={toggleIcon}
alternative-text={toggleInstructions}
size="x-small"
></lightning-icon>
</button>
Expand Down
Loading