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

Introduce Testing to Stacks #1194

Merged
merged 38 commits into from
Dec 15, 2022
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
f07da4d
test(setup): add a poc for component testing
giamir Oct 7, 2022
d1e430f
match orginial indentation for diff purposes
dancormier Oct 18, 2022
414fb28
test(tooltip): add wtr visual regression example
giamir Oct 27, 2022
de78eb0
Merge branch 'develop' into gbuoncristiani/introduce-testing-setup
giamir Nov 25, 2022
b3c1ba1
refactor(tooltip): remove old tooltip version
giamir Nov 25, 2022
3df1318
test(backstop): mark backstop tests as legacy
giamir Nov 25, 2022
7f075c3
ci(workflow): add basic pipeline to build and run tests
giamir Nov 28, 2022
664bef5
fix(styles): fix stylelint rules violations
giamir Nov 28, 2022
53937b3
fix(ts): fix eslint rules violations
giamir Nov 28, 2022
b5d1aea
fix(format): fix all prettier violations
giamir Nov 28, 2022
7559641
test(visual): remove baseline images from regular git tracking
giamir Nov 28, 2022
4793b1a
test(visual): track baseline images with git lfs
giamir Nov 28, 2022
688c071
fix(lint-ts): adjust rule exception after formatting
giamir Nov 28, 2022
d03dea1
ci(test): trigger another netlify deployment
giamir Nov 28, 2022
0d0b6dd
Merge branch 'develop' into gbuoncristiani/testing
giamir Nov 28, 2022
55d0c85
ci(test): update github workflow
giamir Nov 29, 2022
440ecc1
test(tooltip): fix width for visual regression test
giamir Nov 29, 2022
b7ab801
test(tooltip): adjust width for visual regression test
giamir Nov 29, 2022
1a850b9
ci(test): upload visual regression diffs on failure
giamir Nov 29, 2022
4e1fecf
ci(test): fix workflow syntax
giamir Nov 29, 2022
5f7a2f1
test(visual): settle on a default font family for tests
giamir Nov 29, 2022
56d88db
ci(test): fix small typo
giamir Nov 29, 2022
3613a6d
test(visual): set a failure threshold
giamir Nov 29, 2022
bf8999a
ci(test): adjust playwright install command
giamir Nov 29, 2022
9cc7f65
ci(test): add firefox launch options
giamir Nov 29, 2022
a4e6d71
ci(test): disable firefox temporarily
giamir Nov 29, 2022
b472f08
test(tooltip): add prefix s- for consistency
giamir Nov 29, 2022
f795b07
ci(test): fix and add back testing against firefox in CI
giamir Nov 29, 2022
690a8fe
Update README.md
giamir Dec 1, 2022
6055c67
Merge branch 'develop' into gbuoncristiani/testing
giamir Dec 1, 2022
c46b5b9
Merge branch 'develop' into gbuoncristiani/testing
giamir Dec 2, 2022
170ba48
fix(dev-server-rollup): apply temp patch to run tests in windows
giamir Dec 4, 2022
b4e1b0b
test(visual): relax failure threshold to 5 percent
giamir Dec 4, 2022
166236f
test(cleanup): remove backstop legacy tests
giamir Dec 4, 2022
91a56eb
test(visual): update default fonts
giamir Dec 6, 2022
b1ebfac
Merge branch 'develop' into gbuoncristiani/testing
giamir Dec 6, 2022
0caa564
Update .gitignore
giamir Dec 15, 2022
483c0cc
Merge branch 'develop' into gbuoncristiani/testing
giamir Dec 15, 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
Prev Previous commit
Next Next commit
fix(ts): fix eslint rules violations
  • Loading branch information
giamir committed Nov 28, 2022
commit 53937b39ee621399b3459205dce391fab8d02927
4 changes: 2 additions & 2 deletions lib/ts/controllers/s-modal.ts
Original file line number Diff line number Diff line change
@@ -220,7 +220,7 @@ export class ModalController extends Stacks.StacksController {
} else if (!e.shiftKey && e.target === lastTabbable) {
e.preventDefault();
firstTabbable.focus();
}
}
}
}
}
@@ -255,7 +255,7 @@ export class ModalController extends Stacks.StacksController {
const target = <Node>e.target;
// check if the document was clicked inside either the toggle element or the modal itself
// note: .contains also returns true if the node itself matches the target element
if (!this.modalTarget.querySelector(".s-modal--dialog")!.contains(target) && document.body.contains(target)) {
if (!this.modalTarget.querySelector(".s-modal--dialog")?.contains(target) && document.body.contains(target)) {
this._toggle(false, e);
}
}
8 changes: 4 additions & 4 deletions lib/ts/controllers/s-table.ts
Original file line number Diff line number Diff line change
@@ -82,7 +82,7 @@ export class TableController extends Stacks.StacksController {
// unless the to-be-sorted-by value is explicitly provided on the element via this attribute,
// the value we're using is the cell's text, trimmed of any whitespace
const explicit = controller.getElementData(cell, "sort-val");
const d = typeof explicit === "string" ? explicit : cell.textContent!.trim();
const d = typeof explicit === "string" ? explicit : cell.textContent?.trim() ?? '';

if ((d !== "") && (`${parseInt(d, 10)}` !== d)) {
anyNonInt = true;
@@ -117,7 +117,7 @@ export class TableController extends Stacks.StacksController {
// this is the actual reordering of the table rows
data.forEach(function (tup) {
const row = rows[tup[1]];
row.parentElement!.removeChild(row);
row.parentElement?.removeChild(row);
if (firstBottomRow) {
tbody.insertBefore(row, firstBottomRow);
} else {
@@ -214,8 +214,8 @@ function buildIndexOrGetCellSlot(section: HTMLTableSectionElement, findCell?: HT
}
curSlot++;
}
if (curRow) {
curRow = curRow.nextElementSibling!;
if (curRow?.nextElementSibling) {
curRow = curRow.nextElementSibling;
}
}
return findCell ? -1 : index; /* if findCell was given but we end up here, that means it isn't in this section */
2 changes: 1 addition & 1 deletion lib/ts/controllers/s-tooltip.ts
Original file line number Diff line number Diff line change
@@ -173,7 +173,7 @@ export class TooltipController extends BasePopoverController {
* @param event An event object from s-popover:shown
*/
private hideIfWithin(event: Event) {
if ((<Element>event.target!).contains(this.referenceElement)) {
if ((<Element>event.target).contains(this.referenceElement)) {
this.scheduleHide();
}
}
11 changes: 6 additions & 5 deletions lib/ts/stacks.ts
Original file line number Diff line number Diff line change
@@ -63,23 +63,24 @@ export class StacksController extends Stimulus.Controller {

// ControllerDefinition/createController/addController is here to make
// it easier to consume Stimulus from ES5 files (without classes)
export interface ControllerDefinition {
[name: string]: any;
export interface ControllerDefinition {
[name: string]: unknown;
targets?: string[];
}
export function createController(controllerDefinition: ControllerDefinition): typeof StacksController {
// eslint-disable-next-line no-prototype-builtins
const Controller = controllerDefinition.hasOwnProperty("targets")
? class Controller extends StacksController { static targets = controllerDefinition.targets! }
? class Controller extends StacksController { static targets = controllerDefinition.targets ?? []}
: class Controller extends StacksController {};

for (const prop in controllerDefinition) {
// eslint-disable-next-line no-prototype-builtins
if (prop !== "targets" && controllerDefinition.hasOwnProperty(prop)) {
const ownPropDescriptor = controllerDefinition.hasOwnProperty(prop) && Object.getOwnPropertyDescriptor(controllerDefinition, prop);
if (prop !== "targets" && ownPropDescriptor) {
Object.defineProperty(
Controller.prototype,
prop,
Object.getOwnPropertyDescriptor(controllerDefinition, prop)!
ownPropDescriptor
);
}
}