@leaflink/dom-testing-utils 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +13 -68
- package/dist/index.js +13 -131
- package/dist/index.js.map +1 -1
- package/dist/setup-env.d.ts +1 -1
- package/dist/setup-env.js +36 -6
- package/dist/setup-env.js.map +1 -1
- package/dist/utils/__tests__/createFixtureGenerator.spec.js +36 -0
- package/dist/utils/__tests__/createFixtureGenerator.spec.js.map +1 -0
- package/dist/utils/__tests__/getAllByDescriptionTerm.spec.d.ts +1 -0
- package/dist/utils/__tests__/getAllByDescriptionTerm.spec.js +17 -0
- package/dist/utils/__tests__/getAllByDescriptionTerm.spec.js.map +1 -0
- package/dist/utils/__tests__/getByDescriptionTerm.spec.d.ts +1 -0
- package/dist/utils/__tests__/getByDescriptionTerm.spec.js +12 -0
- package/dist/utils/__tests__/getByDescriptionTerm.spec.js.map +1 -0
- package/dist/utils/assertAndDismissNoty.d.ts +8 -0
- package/dist/utils/assertAndDismissNoty.js +15 -0
- package/dist/utils/assertAndDismissNoty.js.map +1 -0
- package/dist/utils/cleanupDropdowns.d.ts +6 -0
- package/dist/utils/cleanupDropdowns.js +9 -0
- package/dist/utils/cleanupDropdowns.js.map +1 -0
- package/dist/utils/cleanupModals.d.ts +6 -0
- package/dist/utils/cleanupModals.js +9 -0
- package/dist/utils/cleanupModals.js.map +1 -0
- package/dist/utils/cleanupNoty.d.ts +6 -0
- package/dist/utils/cleanupNoty.js +9 -0
- package/dist/utils/cleanupNoty.js.map +1 -0
- package/dist/utils/cleanupToasts.d.ts +6 -0
- package/dist/utils/cleanupToasts.js +9 -0
- package/dist/utils/cleanupToasts.js.map +1 -0
- package/dist/utils/createFixtureGenerator.d.ts +27 -0
- package/dist/utils/createFixtureGenerator.js +40 -0
- package/dist/utils/createFixtureGenerator.js.map +1 -0
- package/dist/utils/getAllByDescriptionTerm.d.ts +8 -0
- package/dist/utils/getAllByDescriptionTerm.js +18 -0
- package/dist/utils/getAllByDescriptionTerm.js.map +1 -0
- package/dist/utils/getByDescriptionTerm.d.ts +7 -0
- package/dist/utils/getByDescriptionTerm.js +17 -0
- package/dist/utils/getByDescriptionTerm.js.map +1 -0
- package/dist/utils/hasText.d.ts +11 -0
- package/dist/utils/hasText.js +16 -0
- package/dist/utils/hasText.js.map +1 -0
- package/dist/utils/isHTMLElement.d.ts +7 -0
- package/dist/utils/isHTMLElement.js +10 -0
- package/dist/utils/isHTMLElement.js.map +1 -0
- package/dist/{api → utils}/mockEndpoints.d.ts +1 -1
- package/dist/{api → utils}/mockEndpoints.js +3 -3
- package/dist/utils/mockEndpoints.js.map +1 -0
- package/dist/utils/waitForLoadingToFinish.d.ts +8 -0
- package/dist/utils/waitForLoadingToFinish.js +12 -0
- package/dist/utils/waitForLoadingToFinish.js.map +1 -0
- package/package.json +8 -13
- package/dist/api/mockEndpoints.js.map +0 -1
- package/dist/index.spec.js +0 -66
- package/dist/index.spec.js.map +0 -1
- /package/dist/{index.spec.d.ts → utils/__tests__/createFixtureGenerator.spec.d.ts} +0 -0
package/dist/index.d.ts
CHANGED
|
@@ -1,68 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
*/
|
|
15
|
-
export declare function cleanupNoty(): void;
|
|
16
|
-
export declare function cleanupDropdowns(): void;
|
|
17
|
-
/**
|
|
18
|
-
* Queries and returns an array of HTML elements with the role "definition" (DD)
|
|
19
|
-
* that matches the specified text.
|
|
20
|
-
*
|
|
21
|
-
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
22
|
-
* @returns An array of HTML elements that match the given text.
|
|
23
|
-
*/
|
|
24
|
-
export declare function getAllByDescriptionTerm(textMatch: string | RegExp): HTMLElement[];
|
|
25
|
-
/**
|
|
26
|
-
* Finds the first HTML element with the role "definition" (DD) that matches the specified text.
|
|
27
|
-
*
|
|
28
|
-
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
29
|
-
* @returns The matched element, or undefined if no match is found.
|
|
30
|
-
*/
|
|
31
|
-
export declare function getByDescriptionTerm(textMatch: string | RegExp): HTMLElement | undefined;
|
|
32
|
-
/**
|
|
33
|
-
* Helper to assert and manually dismiss a notification. This is useful in scenarios where
|
|
34
|
-
* cleanupNoty() does not work as expected, such as when validating error messages in test suites
|
|
35
|
-
*
|
|
36
|
-
* @param {string | RegExp} text - expected notification text
|
|
37
|
-
*
|
|
38
|
-
* @returns void
|
|
39
|
-
*/
|
|
40
|
-
export declare function assertAndDismissNoty(text: string): Promise<void>;
|
|
41
|
-
/**
|
|
42
|
-
* Higher order function that takes a method whose responsibility is to create a
|
|
43
|
-
* **single** data fixture object and returns a new generator function that
|
|
44
|
-
* allows you to create 1 or many of those fixtures. Fixture generator function
|
|
45
|
-
* that's returned supports passing optional `num` and `overrides` params.
|
|
46
|
-
*
|
|
47
|
-
* @example
|
|
48
|
-
*
|
|
49
|
-
* const generateInvoice = (overrides) => ({ id: uuid(), balance: 15799, classification: "Adult Use", ...overrides});
|
|
50
|
-
* const generateInvoices = createFixtureGenerator(generateInvoice);
|
|
51
|
-
*
|
|
52
|
-
* generateInvoices() // => Single invoice object
|
|
53
|
-
* generateInvoices(1) // => Single invoice object
|
|
54
|
-
* generateInvoices(1, { foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
55
|
-
* generateInvoices({ foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
56
|
-
* generateInvoices(10) // => Array of 10 invoice objects
|
|
57
|
-
* generateInvoices(10, { foo: 'bar' }) // => Array of 10 invoice objects, override `foo` to equal `'bar'` in each
|
|
58
|
-
*
|
|
59
|
-
* @param fixtureFn - Method that generates a JSON data fixture.
|
|
60
|
-
* @returns A fixture generator that return an array of fixture objects or single object if n = 1.
|
|
61
|
-
*/
|
|
62
|
-
export declare function createFixtureGenerator<T>(fixtureFn: (overrides?: Partial<T>) => T): {
|
|
63
|
-
(): T;
|
|
64
|
-
<TNum extends 1>(num: TNum, overrides?: Partial<T>): T;
|
|
65
|
-
(num: Partial<T>): T;
|
|
66
|
-
<TNum_1 extends number>(num: TNum_1, overrides?: Partial<T>): T[];
|
|
67
|
-
};
|
|
68
|
-
export { createMockApiUtils, RestMethod };
|
|
1
|
+
export { default as assertAndDismissNoty } from './utils/assertAndDismissNoty.js';
|
|
2
|
+
export { default as cleanupDropdowns } from './utils/cleanupDropdowns.js';
|
|
3
|
+
export { default as cleanupModals } from './utils/cleanupModals.js';
|
|
4
|
+
export { default as cleanupNoty } from './utils/cleanupNoty.js';
|
|
5
|
+
export { default as cleanupToasts } from './utils/cleanupToasts.js';
|
|
6
|
+
export { default as createFixtureGenerator } from './utils/createFixtureGenerator.js';
|
|
7
|
+
export { default as getAllByDescriptionTerm } from './utils/getAllByDescriptionTerm.js';
|
|
8
|
+
export { default as getByDescriptionTerm } from './utils/getByDescriptionTerm.js';
|
|
9
|
+
export { default as hasText } from './utils/hasText.js';
|
|
10
|
+
export { default as isHTMLElement } from './utils/isHTMLElement.js';
|
|
11
|
+
export { default as createMockApiUtils, RestMethod } from './utils/mockEndpoints.js';
|
|
12
|
+
export { default as mockEndpoints } from './utils/mockEndpoints.js';
|
|
13
|
+
export { default as waitForLoadingToFinish } from './utils/waitForLoadingToFinish.js';
|
package/dist/index.js
CHANGED
|
@@ -1,132 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
|
-
* Helper method to remove all noty alerts from the DOM.
|
|
16
|
-
*
|
|
17
|
-
* @returns void
|
|
18
|
-
*/
|
|
19
|
-
export function cleanupNoty() {
|
|
20
|
-
document
|
|
21
|
-
.querySelectorAll('.noty_bar')
|
|
22
|
-
.forEach((elem) => elem.parentNode?.removeChild(elem));
|
|
23
|
-
}
|
|
24
|
-
export function cleanupDropdowns() {
|
|
25
|
-
document
|
|
26
|
-
.querySelectorAll('.mount-point-container')
|
|
27
|
-
.forEach((elem) => elem.parentNode?.removeChild(elem));
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Type guard function to check if the provided value is an instance of HTMLElement.
|
|
31
|
-
*
|
|
32
|
-
* @param element - The value to check if it is an HTMLElement.
|
|
33
|
-
* @returns Returns true if the value is an HTMLElement, otherwise false.
|
|
34
|
-
*/
|
|
35
|
-
function isHTMLElement(element) {
|
|
36
|
-
return element instanceof HTMLElement;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Checks if the given HTML element contains the specified text or matches the regular expression.
|
|
40
|
-
*
|
|
41
|
-
* @param node - The HTML element to check for the presence of text.
|
|
42
|
-
* @param textMatch - The text or regular expression to match within the HTML element.
|
|
43
|
-
* @returns Returns one of the following:
|
|
44
|
-
* - true, if the element contains the exact text match;
|
|
45
|
-
* - RegExpMatchArray, if the element's text matches the regular expression;
|
|
46
|
-
* - null, if there is no match.
|
|
47
|
-
*/
|
|
48
|
-
function hasText(node, textMatch) {
|
|
49
|
-
const nodeText = getNodeText(node);
|
|
50
|
-
return nodeText === textMatch || nodeText.match(textMatch);
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Queries and returns an array of HTML elements with the role "definition" (DD)
|
|
54
|
-
* that matches the specified text.
|
|
55
|
-
*
|
|
56
|
-
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
57
|
-
* @returns An array of HTML elements that match the given text.
|
|
58
|
-
*/
|
|
59
|
-
export function getAllByDescriptionTerm(textMatch) {
|
|
60
|
-
return screen
|
|
61
|
-
.getAllByRole('definition')
|
|
62
|
-
.filter((term) => term.tagName === 'DD' &&
|
|
63
|
-
isHTMLElement(term.previousElementSibling) &&
|
|
64
|
-
hasText(term?.previousElementSibling, textMatch));
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Finds the first HTML element with the role "definition" (DD) that matches the specified text.
|
|
68
|
-
*
|
|
69
|
-
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
70
|
-
* @returns The matched element, or undefined if no match is found.
|
|
71
|
-
*/
|
|
72
|
-
export function getByDescriptionTerm(textMatch) {
|
|
73
|
-
return screen
|
|
74
|
-
.getAllByRole('definition')
|
|
75
|
-
.find((term) => term.tagName === 'DD' &&
|
|
76
|
-
isHTMLElement(term.previousElementSibling) &&
|
|
77
|
-
hasText(term?.previousElementSibling, textMatch));
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Helper to assert and manually dismiss a notification. This is useful in scenarios where
|
|
81
|
-
* cleanupNoty() does not work as expected, such as when validating error messages in test suites
|
|
82
|
-
*
|
|
83
|
-
* @param {string | RegExp} text - expected notification text
|
|
84
|
-
*
|
|
85
|
-
* @returns void
|
|
86
|
-
*/
|
|
87
|
-
export async function assertAndDismissNoty(text) {
|
|
88
|
-
const noty = await screen.findByText(text);
|
|
89
|
-
expect(noty).toBeInTheDocument();
|
|
90
|
-
await userEvent.click(noty);
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Higher order function that takes a method whose responsibility is to create a
|
|
94
|
-
* **single** data fixture object and returns a new generator function that
|
|
95
|
-
* allows you to create 1 or many of those fixtures. Fixture generator function
|
|
96
|
-
* that's returned supports passing optional `num` and `overrides` params.
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
*
|
|
100
|
-
* const generateInvoice = (overrides) => ({ id: uuid(), balance: 15799, classification: "Adult Use", ...overrides});
|
|
101
|
-
* const generateInvoices = createFixtureGenerator(generateInvoice);
|
|
102
|
-
*
|
|
103
|
-
* generateInvoices() // => Single invoice object
|
|
104
|
-
* generateInvoices(1) // => Single invoice object
|
|
105
|
-
* generateInvoices(1, { foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
106
|
-
* generateInvoices({ foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
107
|
-
* generateInvoices(10) // => Array of 10 invoice objects
|
|
108
|
-
* generateInvoices(10, { foo: 'bar' }) // => Array of 10 invoice objects, override `foo` to equal `'bar'` in each
|
|
109
|
-
*
|
|
110
|
-
* @param fixtureFn - Method that generates a JSON data fixture.
|
|
111
|
-
* @returns A fixture generator that return an array of fixture objects or single object if n = 1.
|
|
112
|
-
*/
|
|
113
|
-
export function createFixtureGenerator(fixtureFn) {
|
|
114
|
-
function _generator(num = 1, overrides = {}) {
|
|
115
|
-
// if the first param is not a number, it must be the overrides
|
|
116
|
-
if (typeof num !== 'number') {
|
|
117
|
-
return fixtureFn(num);
|
|
118
|
-
}
|
|
119
|
-
else if (num === 1) {
|
|
120
|
-
// If num is 1, then we don't want to return an array, so just generate one with any potential overrides
|
|
121
|
-
return fixtureFn(overrides);
|
|
122
|
-
}
|
|
123
|
-
else {
|
|
124
|
-
// Otherwise, let's generate however many requested data objects
|
|
125
|
-
// eslint-disable-next-line prefer-spread
|
|
126
|
-
return Array.apply(null, Array(num)).map(() => fixtureFn(overrides));
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return _generator;
|
|
130
|
-
}
|
|
131
|
-
export { createMockApiUtils };
|
|
1
|
+
export { default as assertAndDismissNoty } from './utils/assertAndDismissNoty.js';
|
|
2
|
+
export { default as cleanupDropdowns } from './utils/cleanupDropdowns.js';
|
|
3
|
+
export { default as cleanupModals } from './utils/cleanupModals.js';
|
|
4
|
+
export { default as cleanupNoty } from './utils/cleanupNoty.js';
|
|
5
|
+
export { default as cleanupToasts } from './utils/cleanupToasts.js';
|
|
6
|
+
export { default as createFixtureGenerator } from './utils/createFixtureGenerator.js';
|
|
7
|
+
export { default as getAllByDescriptionTerm } from './utils/getAllByDescriptionTerm.js';
|
|
8
|
+
export { default as getByDescriptionTerm } from './utils/getByDescriptionTerm.js';
|
|
9
|
+
export { default as hasText } from './utils/hasText.js';
|
|
10
|
+
export { default as isHTMLElement } from './utils/isHTMLElement.js';
|
|
11
|
+
export { default as createMockApiUtils } from './utils/mockEndpoints.js';
|
|
12
|
+
export { default as mockEndpoints } from './utils/mockEndpoints.js';
|
|
13
|
+
export { default as waitForLoadingToFinish } from './utils/waitForLoadingToFinish.js';
|
|
132
14
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"src/","sources":["index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC;AACtF,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AACxF,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,iCAAiC,CAAC;AAClF,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAc,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,sBAAsB,EAAE,MAAM,mCAAmC,CAAC"}
|
package/dist/setup-env.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
package/dist/setup-env.js
CHANGED
|
@@ -1,6 +1,20 @@
|
|
|
1
|
-
import '@testing-library/jest-dom';
|
|
2
|
-
import {
|
|
1
|
+
import '@testing-library/jest-dom/vitest';
|
|
2
|
+
import { configure as configureTestingLibrary } from '@testing-library/vue';
|
|
3
|
+
import { config, flushPromises } from '@vue/test-utils';
|
|
3
4
|
import { vi } from 'vitest';
|
|
5
|
+
import cleanupDropdowns from './utils/cleanupDropdowns';
|
|
6
|
+
import cleanupModals from './utils/cleanupModals';
|
|
7
|
+
import cleanupNoty from './utils/cleanupNoty';
|
|
8
|
+
import cleanupToasts from './utils/cleanupToasts';
|
|
9
|
+
// checking if an element is hidden is quite expensive
|
|
10
|
+
// this is only done in CI as a fail safe. It can still explicitly be checked
|
|
11
|
+
// in the test files which helps documenting what is part of the DOM but hidden
|
|
12
|
+
// from assistive technology
|
|
13
|
+
const defaultHidden = !process.env.CI;
|
|
14
|
+
configureTestingLibrary({ testIdAttribute: 'data-test', defaultHidden });
|
|
15
|
+
vi.mock('lodash-es/debounce', () => {
|
|
16
|
+
return { default: vi.fn((fn) => fn) };
|
|
17
|
+
});
|
|
4
18
|
config.global.mocks['$t'] = (msg) => msg;
|
|
5
19
|
const oldWindowLocation = global.window.location;
|
|
6
20
|
beforeAll(() => {
|
|
@@ -21,12 +35,26 @@ beforeAll(() => {
|
|
|
21
35
|
},
|
|
22
36
|
},
|
|
23
37
|
});
|
|
24
|
-
window.open = vi.fn();
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
38
|
+
global.window.open = vi.fn();
|
|
39
|
+
});
|
|
40
|
+
afterEach(() => {
|
|
41
|
+
// cleanup modals in between tests
|
|
42
|
+
cleanupModals();
|
|
43
|
+
// cleanup toasts in between tests
|
|
44
|
+
cleanupToasts();
|
|
45
|
+
// cleanup noty messages in between tests
|
|
46
|
+
cleanupNoty();
|
|
47
|
+
// cleanup dropdown menus in between tests
|
|
48
|
+
cleanupDropdowns();
|
|
49
|
+
});
|
|
50
|
+
afterEach(async () => {
|
|
51
|
+
// flush out any pending promises so they will fail the test instead of asynchronously at
|
|
52
|
+
// the wrong time
|
|
53
|
+
await flushPromises();
|
|
28
54
|
});
|
|
29
55
|
afterAll(() => {
|
|
56
|
+
// restore `window.location` to the original `jsdom`
|
|
57
|
+
// `Location` object
|
|
30
58
|
global.window.location = oldWindowLocation;
|
|
31
59
|
});
|
|
32
60
|
const IntersectionObserverMock = vi.fn(() => ({
|
|
@@ -39,6 +67,8 @@ const IntersectionObserverMock = vi.fn(() => ({
|
|
|
39
67
|
unobserve: vi.fn(),
|
|
40
68
|
}));
|
|
41
69
|
vi.stubGlobal('IntersectionObserver', IntersectionObserverMock);
|
|
70
|
+
// Uploading a file does not use axios, so mock the fetch api
|
|
71
|
+
// See src/services/api/files.js->uploadFile for more info
|
|
42
72
|
vi.stubGlobal('fetch', vi.fn().mockResolvedValue({ json: vi.fn().mockResolvedValue({}) }));
|
|
43
73
|
// https://github.com/jsdom/jsdom/issues/1695
|
|
44
74
|
Element.prototype.scrollIntoView = vi.fn();
|
package/dist/setup-env.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setup-env.js","sourceRoot":"src/","sources":["setup-env.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"setup-env.js","sourceRoot":"src/","sources":["setup-env.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAC1C,OAAO,EAAE,SAAS,IAAI,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AAC5E,OAAO,EAAE,MAAM,EA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6C;AAC7C,OAAO,CAAC,SAAS,CAAC,cAAc,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import createFixtureGenerator from '../createFixtureGenerator';
|
|
2
|
+
it('returns a function that can generate an array of data objects', () => {
|
|
3
|
+
const generator = (overrides) => ({
|
|
4
|
+
foo: 'bar',
|
|
5
|
+
bar: 'baz',
|
|
6
|
+
...overrides,
|
|
7
|
+
});
|
|
8
|
+
expect(createFixtureGenerator(generator)(5)).toEqual([
|
|
9
|
+
{ foo: 'bar', bar: 'baz' },
|
|
10
|
+
{ foo: 'bar', bar: 'baz' },
|
|
11
|
+
{ foo: 'bar', bar: 'baz' },
|
|
12
|
+
{ foo: 'bar', bar: 'baz' },
|
|
13
|
+
{ foo: 'bar', bar: 'baz' },
|
|
14
|
+
]);
|
|
15
|
+
expect(createFixtureGenerator(generator)(3, { bar: 'yak' })).toEqual([
|
|
16
|
+
{ foo: 'bar', bar: 'yak' },
|
|
17
|
+
{ foo: 'bar', bar: 'yak' },
|
|
18
|
+
{ foo: 'bar', bar: 'yak' },
|
|
19
|
+
]);
|
|
20
|
+
});
|
|
21
|
+
it('returns a function that can generate a single data object', () => {
|
|
22
|
+
const generator = (overrides) => ({
|
|
23
|
+
foo: 'bar',
|
|
24
|
+
bar: 'baz',
|
|
25
|
+
...overrides,
|
|
26
|
+
});
|
|
27
|
+
expect(createFixtureGenerator(generator)()).toEqual({
|
|
28
|
+
foo: 'bar',
|
|
29
|
+
bar: 'baz',
|
|
30
|
+
});
|
|
31
|
+
expect(createFixtureGenerator(generator)({ bar: 'yak' })).toEqual({
|
|
32
|
+
foo: 'bar',
|
|
33
|
+
bar: 'yak',
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
//# sourceMappingURL=createFixtureGenerator.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFixtureGenerator.spec.js","sourceRoot":"src/","sources":["utils/__tests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B,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC;QAClD,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;IAEH,MAAM,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC;QAChE,GAAG,EAAE,KAAK;QACV,GAAG,EAAE,KAAK;KACX,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import getAllByDescriptionTerm from '../getAllByDescriptionTerm';
|
|
3
|
+
it.each `
|
|
4
|
+
term | type
|
|
5
|
+
${'foo'} | ${'string'}
|
|
6
|
+
${/foo/i} | ${'regex'}
|
|
7
|
+
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
8
|
+
`('should return the description details for a given $type term', ({ term }) => {
|
|
9
|
+
render({
|
|
10
|
+
template: `<dl><dt>foo</dt><dd>bar1</dd></dl><dl><dt>foo</dt><dd>bar2</dd></dl>`,
|
|
11
|
+
});
|
|
12
|
+
const details = getAllByDescriptionTerm(term);
|
|
13
|
+
expect(details).toHaveLength(2);
|
|
14
|
+
expect(details[0]).toHaveTextContent('bar1');
|
|
15
|
+
expect(details[1]).toHaveTextContent('bar2');
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=getAllByDescriptionTerm.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllByDescriptionTerm.spec.js","sourceRoot":"src/","sources":["utils/__tests__/getAllByDescriptionTerm.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,uBAAuB,MAAM,4BAA4B,CAAC;AAEjE,EAAE,CAAC,IAAI,CAAA;;IAEH,KAAK,uBAAuB,QAAQ;IACpC,MAAM,sBAAsB,OAAO;IACnC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,QAAQ;CACvC,CAAC,8DAA8D,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC7E,MAAM,CAAC;QACL,QAAQ,EAAE,sEAAsE;KACjF,CAAC,CAAC;IAEH,MAAM,OAAO,GAAG,uBAAuB,CAAC,IAAI,CAAC,CAAC;IAC9C,MAAM,CAAC,OAAO,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;IAChC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC7C,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAC/C,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { render } from '@testing-library/vue';
|
|
2
|
+
import getByDescriptionTerm from '../getByDescriptionTerm';
|
|
3
|
+
it.each `
|
|
4
|
+
term | type
|
|
5
|
+
${'foo'} | ${'string'}
|
|
6
|
+
${/foo/i} | ${'regex'}
|
|
7
|
+
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
8
|
+
`('should return the description detail for a given $type term', ({ term }) => {
|
|
9
|
+
render({ template: `<dl><dt>foo</dt><dd>bar</dd></dl>` });
|
|
10
|
+
expect(getByDescriptionTerm(term)).toHaveTextContent('bar');
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=getByDescriptionTerm.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getByDescriptionTerm.spec.js","sourceRoot":"src/","sources":["utils/__tests__/getByDescriptionTerm.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,EAAE,CAAC,IAAI,CAAA;;IAEH,KAAK,uBAAuB,QAAQ;IACpC,MAAM,sBAAsB,OAAO;IACnC,IAAI,MAAM,CAAC,KAAK,EAAE,GAAG,CAAC,MAAM,QAAQ;CACvC,CAAC,6DAA6D,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE;IAC5E,MAAM,CAAC,EAAE,QAAQ,EAAE,mCAAmC,EAAE,CAAC,CAAC;IAE1D,MAAM,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC;AAC9D,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper to assert and manually dismiss a notification. This is useful in scenarios where
|
|
3
|
+
* cleanupNoty() does not work as expected, such as when validating error messages in test suites
|
|
4
|
+
*
|
|
5
|
+
* @param {string | RegExp} text - Expected notification text. Can be a string or a regular expression.
|
|
6
|
+
* @returns void
|
|
7
|
+
*/
|
|
8
|
+
export default function assertAndDismissNoty(text: string | RegExp): Promise<void>;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import userEvent from '@testing-library/user-event';
|
|
2
|
+
import { screen } from '@testing-library/vue';
|
|
3
|
+
/**
|
|
4
|
+
* Helper to assert and manually dismiss a notification. This is useful in scenarios where
|
|
5
|
+
* cleanupNoty() does not work as expected, such as when validating error messages in test suites
|
|
6
|
+
*
|
|
7
|
+
* @param {string | RegExp} text - Expected notification text. Can be a string or a regular expression.
|
|
8
|
+
* @returns void
|
|
9
|
+
*/
|
|
10
|
+
export default async function assertAndDismissNoty(text) {
|
|
11
|
+
const noty = await screen.findByText(text);
|
|
12
|
+
expect(noty).toBeInTheDocument();
|
|
13
|
+
await userEvent.click(noty);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=assertAndDismissNoty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertAndDismissNoty.js","sourceRoot":"src/","sources":["utils/assertAndDismissNoty.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,6BAA6B,CAAC;AACpD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,CAAC,KAAK,UAAU,oBAAoB,CAAC,IAAqB;IACtE,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC3C,MAAM,CAAC,IAAI,CAAC,CAAC,iBAAiB,EAAE,CAAC;IAEjC,MAAM,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC9B,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper method to remove all Stash dropdowns from the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupDropdowns() {
|
|
7
|
+
document.querySelectorAll('.mount-point-container').forEach((elem) => elem.parentNode?.removeChild(elem));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=cleanupDropdowns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupDropdowns.js","sourceRoot":"src/","sources":["utils/cleanupDropdowns.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,gBAAgB;IACtC,QAAQ,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AAC5G,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper method to remove all Stash modals from the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupModals() {
|
|
7
|
+
document.querySelectorAll('.stash-modal-wrapper').forEach((elem) => elem.parentNode?.removeChild(elem));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=cleanupModals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupModals.js","sourceRoot":"src/","sources":["utils/cleanupModals.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa;IACnC,QAAQ,CAAC,gBAAgB,CAAC,sBAAsB,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AAC1G,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper method to remove all noty alerts from the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupNoty() {
|
|
7
|
+
document.querySelectorAll('.noty_bar').forEach((elem) => elem.parentNode?.removeChild(elem));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=cleanupNoty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupNoty.js","sourceRoot":"src/","sources":["utils/cleanupNoty.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,WAAW;IACjC,QAAQ,CAAC,gBAAgB,CAAC,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/F,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper method to remove all Stash toasts from the DOM.
|
|
3
|
+
*
|
|
4
|
+
* @returns void
|
|
5
|
+
*/
|
|
6
|
+
export default function cleanupToasts() {
|
|
7
|
+
document.querySelectorAll('.stash-toast').forEach((elem) => elem.parentNode?.removeChild(elem));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=cleanupToasts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cleanupToasts.js","sourceRoot":"src/","sources":["utils/cleanupToasts.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa;IACnC,QAAQ,CAAC,gBAAgB,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,EAAE,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC;AAClG,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher order function that takes a method whose responsibility is to create a
|
|
3
|
+
* **single** data fixture object and returns a new generator function that
|
|
4
|
+
* allows you to create 1 or many of those fixtures. Fixture generator function
|
|
5
|
+
* that's returned supports passing optional `num` and `overrides` params.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* const generateInvoice = (overrides) => ({ id: uuid(), balance: 15799, classification: "Adult Use", ...overrides});
|
|
10
|
+
* const generateInvoices = createFixtureGenerator(generateInvoice);
|
|
11
|
+
*
|
|
12
|
+
* generateInvoices() // => Single invoice object
|
|
13
|
+
* generateInvoices(1) // => Single invoice object
|
|
14
|
+
* generateInvoices(1, { foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
15
|
+
* generateInvoices({ foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
16
|
+
* generateInvoices(10) // => Array of 10 invoice objects
|
|
17
|
+
* generateInvoices(10, { foo: 'bar' }) // => Array of 10 invoice objects, override `foo` to equal `'bar'` in each
|
|
18
|
+
*
|
|
19
|
+
* @param fixtureFn - Method that generates a JSON data fixture.
|
|
20
|
+
* @returns A fixture generator that return an array of fixture objects or single object if n = 1.
|
|
21
|
+
*/
|
|
22
|
+
export default function createFixtureGenerator<T>(fixtureFn: (overrides?: Partial<T>) => T): {
|
|
23
|
+
(): T;
|
|
24
|
+
<TNum extends 1>(num: TNum, overrides?: Partial<T>): T;
|
|
25
|
+
(num: Partial<T>): T;
|
|
26
|
+
<TNum_1 extends number>(num: TNum_1, overrides?: Partial<T>): T[];
|
|
27
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Higher order function that takes a method whose responsibility is to create a
|
|
3
|
+
* **single** data fixture object and returns a new generator function that
|
|
4
|
+
* allows you to create 1 or many of those fixtures. Fixture generator function
|
|
5
|
+
* that's returned supports passing optional `num` and `overrides` params.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
*
|
|
9
|
+
* const generateInvoice = (overrides) => ({ id: uuid(), balance: 15799, classification: "Adult Use", ...overrides});
|
|
10
|
+
* const generateInvoices = createFixtureGenerator(generateInvoice);
|
|
11
|
+
*
|
|
12
|
+
* generateInvoices() // => Single invoice object
|
|
13
|
+
* generateInvoices(1) // => Single invoice object
|
|
14
|
+
* generateInvoices(1, { foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
15
|
+
* generateInvoices({ foo: 'bar' }) // => Single invoice object, override `foo` to equal `'bar'`
|
|
16
|
+
* generateInvoices(10) // => Array of 10 invoice objects
|
|
17
|
+
* generateInvoices(10, { foo: 'bar' }) // => Array of 10 invoice objects, override `foo` to equal `'bar'` in each
|
|
18
|
+
*
|
|
19
|
+
* @param fixtureFn - Method that generates a JSON data fixture.
|
|
20
|
+
* @returns A fixture generator that return an array of fixture objects or single object if n = 1.
|
|
21
|
+
*/
|
|
22
|
+
export default function createFixtureGenerator(fixtureFn) {
|
|
23
|
+
function _generator(num = 1, overrides = {}) {
|
|
24
|
+
// if the first param is not a number, it must be the overrides
|
|
25
|
+
if (typeof num !== 'number') {
|
|
26
|
+
return fixtureFn(num);
|
|
27
|
+
}
|
|
28
|
+
else if (num === 1) {
|
|
29
|
+
// If num is 1, then we don't want to return an array, so just generate one with any potential overrides
|
|
30
|
+
return fixtureFn(overrides);
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Otherwise, let's generate however many requested data objects
|
|
34
|
+
// eslint-disable-next-line prefer-spread
|
|
35
|
+
return Array.apply(null, Array(num)).map(() => fixtureFn(overrides));
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return _generator;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=createFixtureGenerator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createFixtureGenerator.js","sourceRoot":"src/","sources":["utils/createFixtureGenerator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAI,SAAwC;IAKxF,SAAS,UAAU,CAAC,MAA2B,CAAC,EAAE,SAAS,GAAG,EAAE;QAC9D,+DAA+D;QAC/D,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE;YAC3B,OAAO,SAAS,CAAC,GAAG,CAAC,CAAC;SACvB;aAAM,IAAI,GAAG,KAAK,CAAC,EAAE;YACpB,wGAAwG;YACxG,OAAO,SAAS,CAAC,SAAS,CAAC,CAAC;SAC7B;aAAM;YACL,gEAAgE;YAChE,yCAAyC;YACzC,OAAO,KAAK,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC;SACtE;IACH,CAAC;IAED,OAAO,UAAU,CAAC;AACpB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Queries and returns an array of HTML elements with the role "definition" (DD)
|
|
3
|
+
* that matches the specified text.
|
|
4
|
+
*
|
|
5
|
+
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
6
|
+
* @returns An array of HTML elements that match the given text.
|
|
7
|
+
*/
|
|
8
|
+
export default function getAllByDescriptionTerm(textMatch: string | RegExp): HTMLElement[];
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { screen } from '@testing-library/vue';
|
|
2
|
+
import hasText from './hasText';
|
|
3
|
+
import isHTMLElement from './isHTMLElement';
|
|
4
|
+
/**
|
|
5
|
+
* Queries and returns an array of HTML elements with the role "definition" (DD)
|
|
6
|
+
* that matches the specified text.
|
|
7
|
+
*
|
|
8
|
+
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
9
|
+
* @returns An array of HTML elements that match the given text.
|
|
10
|
+
*/
|
|
11
|
+
export default function getAllByDescriptionTerm(textMatch) {
|
|
12
|
+
return screen
|
|
13
|
+
.getAllByRole('definition')
|
|
14
|
+
.filter((term) => term.tagName === 'DD' &&
|
|
15
|
+
isHTMLElement(term.previousElementSibling) &&
|
|
16
|
+
hasText(term?.previousElementSibling, textMatch));
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=getAllByDescriptionTerm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getAllByDescriptionTerm.js","sourceRoot":"src/","sources":["utils/getAllByDescriptionTerm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,uBAAuB,CAAC,SAA0B;IACxE,OAAO,MAAM;SACV,YAAY,CAAC,YAAY,CAAC;SAC1B,MAAM,CACL,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,OAAO,KAAK,IAAI;QACrB,aAAa,CAAC,IAAI,CAAC,sBAAsB,CAAC;QAC1C,OAAO,CAAC,IAAI,EAAE,sBAAsB,EAAE,SAAS,CAAC,CACnD,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the first HTML element with the role "definition" (DD) that matches the specified text.
|
|
3
|
+
*
|
|
4
|
+
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
5
|
+
* @returns The matched element, or undefined if no match is found.
|
|
6
|
+
*/
|
|
7
|
+
export default function getByDescriptionTerm(textMatch: string | RegExp): HTMLElement | undefined;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { screen } from '@testing-library/vue';
|
|
2
|
+
import hasText from './hasText';
|
|
3
|
+
import isHTMLElement from './isHTMLElement';
|
|
4
|
+
/**
|
|
5
|
+
* Finds the first HTML element with the role "definition" (DD) that matches the specified text.
|
|
6
|
+
*
|
|
7
|
+
* @param textMatch - The text to match within the HTML elements. It can be a string or a regular expression.
|
|
8
|
+
* @returns The matched element, or undefined if no match is found.
|
|
9
|
+
*/
|
|
10
|
+
export default function getByDescriptionTerm(textMatch) {
|
|
11
|
+
return screen
|
|
12
|
+
.getAllByRole('definition')
|
|
13
|
+
.find((term) => term.tagName === 'DD' &&
|
|
14
|
+
isHTMLElement(term.previousElementSibling) &&
|
|
15
|
+
hasText(term?.previousElementSibling, textMatch));
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=getByDescriptionTerm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getByDescriptionTerm.js","sourceRoot":"src/","sources":["utils/getByDescriptionTerm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,OAAO,MAAM,WAAW,CAAC;AAChC,OAAO,aAAa,MAAM,iBAAiB,CAAC;AAE5C;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,oBAAoB,CAAC,SAA0B;IACrE,OAAO,MAAM;SACV,YAAY,CAAC,YAAY,CAAC;SAC1B,IAAI,CACH,CAAC,IAAI,EAAE,EAAE,CACP,IAAI,CAAC,OAAO,KAAK,IAAI;QACrB,aAAa,CAAC,IAAI,CAAC,sBAAsB,CAAC;QAC1C,OAAO,CAAC,IAAI,EAAE,sBAAsB,EAAE,SAAS,CAAC,CACnD,CAAC;AACN,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if the given HTML element contains the specified text or matches the regular expression.
|
|
3
|
+
*
|
|
4
|
+
* @param node - The HTML element to check for the presence of text.
|
|
5
|
+
* @param textMatch - The text or regular expression to match within the HTML element.
|
|
6
|
+
* @returns Returns one of the following:
|
|
7
|
+
* - true, if the element contains the exact text match;
|
|
8
|
+
* - RegExpMatchArray, if the element's text matches the regular expression;
|
|
9
|
+
* - null, if there is no match.
|
|
10
|
+
*/
|
|
11
|
+
export default function hasText(node: HTMLElement, textMatch: string | RegExp): true | RegExpMatchArray | null;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getNodeText } from '@testing-library/vue';
|
|
2
|
+
/**
|
|
3
|
+
* Checks if the given HTML element contains the specified text or matches the regular expression.
|
|
4
|
+
*
|
|
5
|
+
* @param node - The HTML element to check for the presence of text.
|
|
6
|
+
* @param textMatch - The text or regular expression to match within the HTML element.
|
|
7
|
+
* @returns Returns one of the following:
|
|
8
|
+
* - true, if the element contains the exact text match;
|
|
9
|
+
* - RegExpMatchArray, if the element's text matches the regular expression;
|
|
10
|
+
* - null, if there is no match.
|
|
11
|
+
*/
|
|
12
|
+
export default function hasText(node, textMatch) {
|
|
13
|
+
const nodeText = getNodeText(node);
|
|
14
|
+
return nodeText === textMatch || nodeText.match(textMatch);
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=hasText.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hasText.js","sourceRoot":"src/","sources":["utils/hasText.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAEnD;;;;;;;;;GASG;AACH,MAAM,CAAC,OAAO,UAAU,OAAO,CAAC,IAAiB,EAAE,SAA0B;IAC3E,MAAM,QAAQ,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC;IACnC,OAAO,QAAQ,KAAK,SAAS,IAAI,QAAQ,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard function to check if the provided value is an instance of HTMLElement.
|
|
3
|
+
*
|
|
4
|
+
* @param element - The value to check if it is an HTMLElement.
|
|
5
|
+
* @returns Returns true if the value is an HTMLElement, otherwise false.
|
|
6
|
+
*/
|
|
7
|
+
export default function isHTMLElement(element: any): element is HTMLElement;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard function to check if the provided value is an instance of HTMLElement.
|
|
3
|
+
*
|
|
4
|
+
* @param element - The value to check if it is an HTMLElement.
|
|
5
|
+
* @returns Returns true if the value is an HTMLElement, otherwise false.
|
|
6
|
+
*/
|
|
7
|
+
export default function isHTMLElement(element) {
|
|
8
|
+
return element instanceof HTMLElement;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=isHTMLElement.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"isHTMLElement.js","sourceRoot":"src/","sources":["utils/isHTMLElement.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,OAAY;IAChD,OAAO,OAAO,YAAY,WAAW,CAAC;AACxC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DefaultRequestBody, RequestParams, ResponseResolver, rest, RestContext, RestRequest } from 'msw';
|
|
2
2
|
import { SetupServerApi } from 'msw/node';
|
|
3
3
|
export type RestMethod = keyof typeof rest;
|
|
4
|
-
export
|
|
4
|
+
export default function createMockApiUtils(server: SetupServerApi): {
|
|
5
5
|
mockEndpointData: <ResponseBody extends DefaultRequestBody = any>(relativeUrl: string, responseData: ResponseBody, method: RestMethod) => void;
|
|
6
6
|
mockEndpoint: <RequestBodyType extends DefaultRequestBody = DefaultRequestBody, ResponseBody_1 extends DefaultRequestBody = any, Params extends RequestParams = RequestParams>(relativeUrl: string, responseCallback: ResponseResolver<RestRequest<RequestBodyType, Params>, RestContext, ResponseBody_1>, method: RestMethod) => void;
|
|
7
7
|
mockGetData: <ResponseBody_2 extends DefaultRequestBody = any>(relativeUrl: string, responseData: ResponseBody_2) => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { rest
|
|
2
|
-
export
|
|
1
|
+
import { rest } from 'msw';
|
|
2
|
+
export default function createMockApiUtils(server) {
|
|
3
3
|
/**
|
|
4
4
|
* Mock endpoint with data
|
|
5
5
|
*/
|
|
@@ -54,5 +54,5 @@ export const createMockApiUtils = (server) => {
|
|
|
54
54
|
mockDeleteEndpoint,
|
|
55
55
|
mockPatchEndpoint,
|
|
56
56
|
};
|
|
57
|
-
}
|
|
57
|
+
}
|
|
58
58
|
//# sourceMappingURL=mockEndpoints.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mockEndpoints.js","sourceRoot":"src/","sources":["utils/mockEndpoints.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuD,IAAI,EAA4B,MAAM,KAAK,CAAC;AAK1G,MAAM,CAAC,OAAO,UAAU,kBAAkB,CAAC,MAAsB;IAC/D;;OAEG;IACH,MAAM,gBAAgB,GAAG,CACvB,WAAmB,EACnB,YAA0B,EAC1B,MAAkB,EAClB,EAAE;QACF,MAAM,CAAC,GAAG,CACR,IAAI,CAAC,MAAM,CAAC,CAAC,WAAW,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE;YAC3C,OAAO,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC;QACrC,CAAC,CAAC,CACH,CAAC;IACJ,CAAC,CAAC;IAEF;;OAEG;IACH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Y;QACZ,WAAW;QACX,YAAY;QACZ,WAAW;QACX,cAAc;QACd,aAAa;QACb,eAAe;QACf,gBAAgB;QAChB,eAAe;QACf,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Utility to wait for loading to complete. Need to add a `data-test` to any
|
|
3
|
+
* loading elements. Defaults to `ll-loading` OR `loading-spinner` if test ID is not specified.
|
|
4
|
+
*
|
|
5
|
+
* @param {string} testId - The data test ID to target
|
|
6
|
+
* @returns {Promise<boolean>} - Will resolve or throw if the loaders stay in the DOM.
|
|
7
|
+
*/
|
|
8
|
+
export default function waitForLoadingToFinish(textMatch?: RegExp): Promise<void>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { screen, waitForElementToBeRemoved } from '@testing-library/vue';
|
|
2
|
+
/**
|
|
3
|
+
* Utility to wait for loading to complete. Need to add a `data-test` to any
|
|
4
|
+
* loading elements. Defaults to `ll-loading` OR `loading-spinner` if test ID is not specified.
|
|
5
|
+
*
|
|
6
|
+
* @param {string} testId - The data test ID to target
|
|
7
|
+
* @returns {Promise<boolean>} - Will resolve or throw if the loaders stay in the DOM.
|
|
8
|
+
*/
|
|
9
|
+
export default function waitForLoadingToFinish(textMatch = /ll-loading|loading-spinner/) {
|
|
10
|
+
return waitForElementToBeRemoved(() => [...screen.queryAllByTestId(textMatch)], { timeout: 2000 });
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=waitForLoadingToFinish.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"waitForLoadingToFinish.js","sourceRoot":"src/","sources":["utils/waitForLoadingToFinish.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEzE;;;;;;GAMG;AACH,MAAM,CAAC,OAAO,UAAU,sBAAsB,CAAC,SAAS,GAAG,4BAA4B;IACrF,OAAO,yBAAyB,CAAC,GAAG,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,gBAAgB,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC;AACrG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@leaflink/dom-testing-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Frontend DOM testing utilities",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16",
|
|
@@ -40,26 +40,21 @@
|
|
|
40
40
|
},
|
|
41
41
|
"license": "MIT",
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@testing-library/
|
|
44
|
-
"@testing-library/
|
|
45
|
-
"@testing-library/user-event": "^14.4.3",
|
|
43
|
+
"@testing-library/jest-dom": "^6.1.3",
|
|
44
|
+
"@testing-library/user-event": "^14.5.1",
|
|
46
45
|
"@testing-library/vue": "^7.0.0",
|
|
47
46
|
"@types/segment-analytics": "^0.0.34",
|
|
48
47
|
"eslint-plugin-testing-library": "^5.10.2",
|
|
49
48
|
"msw": "^0.27.2"
|
|
50
49
|
},
|
|
51
50
|
"devDependencies": {
|
|
52
|
-
"@vitest/coverage-
|
|
51
|
+
"@vitest/coverage-v8": "^0.34.5",
|
|
53
52
|
"eslint": "^8.49.0",
|
|
54
53
|
"eslint-config-leaflink": "^1.17.0",
|
|
55
|
-
"jsdom": "^
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"stylelint-config-standard-vue": "^1.0.0",
|
|
60
|
-
"typescript": "^4.9.5",
|
|
61
|
-
"vite": "^4.1.4",
|
|
62
|
-
"vitest": "^0.29.3"
|
|
54
|
+
"jsdom": "^22.1.0",
|
|
55
|
+
"typescript": "^5.2.2",
|
|
56
|
+
"vite": "^4.4.9",
|
|
57
|
+
"vitest": "^0.34.5"
|
|
63
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,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,YAAY,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAC5C,MAAM,cAAc,GAAG,gBAAgB,CAAC,QAAQ,CAAC,CAAC;IAClD,MAAM,aAAa,GAAG,gBAAgB,CAAC,OAAO,CAAC,CAAC;IAEhD,MAAM,eAAe,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,gBAAgB,GAAG,oBAAoB,CAAC,MAAM,CAAC,CAAC;IACtD,MAAM,eAAe,GAAG,oBAAoB,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,QAAQ,CAAC,CAAC;IAC1D,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,OAAO,CAAC,CAAC;IACxD,aAAa;IAEb,OAAO;QACL,gBAAgB;QAChB,YAAY;QACZ,WAAW;QACX,YAAY;QACZ,WAAW;QACX,cAAc;QACd,aAAa;QACb,eAAe;QACf,gBAAgB;QAChB,eAAe;QACf,kBAAkB;QAClB,iBAAiB;KAClB,CAAC;AACJ,CAAC,CAAC"}
|
package/dist/index.spec.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { render } from '@testing-library/vue';
|
|
2
|
-
import { createFixtureGenerator, getAllByDescriptionTerm, getByDescriptionTerm, } from './index';
|
|
3
|
-
describe('createFixtureGenerator()', () => {
|
|
4
|
-
it('returns a function that can generate an array of data objects', () => {
|
|
5
|
-
const generator = (overrides) => ({
|
|
6
|
-
foo: 'bar',
|
|
7
|
-
bar: 'baz',
|
|
8
|
-
...overrides,
|
|
9
|
-
});
|
|
10
|
-
expect(createFixtureGenerator(generator)(5)).toEqual([
|
|
11
|
-
{ foo: 'bar', bar: 'baz' },
|
|
12
|
-
{ foo: 'bar', bar: 'baz' },
|
|
13
|
-
{ foo: 'bar', bar: 'baz' },
|
|
14
|
-
{ foo: 'bar', bar: 'baz' },
|
|
15
|
-
{ foo: 'bar', bar: 'baz' },
|
|
16
|
-
]);
|
|
17
|
-
expect(createFixtureGenerator(generator)(3, { bar: 'yak' })).toEqual([
|
|
18
|
-
{ foo: 'bar', bar: 'yak' },
|
|
19
|
-
{ foo: 'bar', bar: 'yak' },
|
|
20
|
-
{ foo: 'bar', bar: 'yak' },
|
|
21
|
-
]);
|
|
22
|
-
});
|
|
23
|
-
it('returns a function that can generate a single data object', () => {
|
|
24
|
-
const generator = (overrides) => ({
|
|
25
|
-
foo: 'bar',
|
|
26
|
-
bar: 'baz',
|
|
27
|
-
...overrides,
|
|
28
|
-
});
|
|
29
|
-
expect(createFixtureGenerator(generator)()).toEqual({
|
|
30
|
-
foo: 'bar',
|
|
31
|
-
bar: 'baz',
|
|
32
|
-
});
|
|
33
|
-
expect(createFixtureGenerator(generator)({ bar: 'yak' })).toEqual({
|
|
34
|
-
foo: 'bar',
|
|
35
|
-
bar: 'yak',
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
});
|
|
39
|
-
describe('getByDescriptionTerm', () => {
|
|
40
|
-
it.each `
|
|
41
|
-
term | type
|
|
42
|
-
${'foo'} | ${'string'}
|
|
43
|
-
${/foo/i} | ${'regex'}
|
|
44
|
-
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
45
|
-
`('should return the description detail for a given $type term', ({ term }) => {
|
|
46
|
-
render({ template: `<dl><dt>foo</dt><dd>bar</dd></dl>` });
|
|
47
|
-
expect(getByDescriptionTerm(term)).toHaveTextContent('bar');
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
describe('getAllByDescriptionTerm', () => {
|
|
51
|
-
it.each `
|
|
52
|
-
term | type
|
|
53
|
-
${'foo'} | ${'string'}
|
|
54
|
-
${/foo/i} | ${'regex'}
|
|
55
|
-
${new RegExp('foo', 'i')} | ${'RegExp'}
|
|
56
|
-
`('should return the description details for a given $type term', ({ term }) => {
|
|
57
|
-
render({
|
|
58
|
-
template: `<dl><dt>foo</dt><dd>bar1</dd></dl><dl><dt>foo</dt><dd>bar2</dd></dl>`,
|
|
59
|
-
});
|
|
60
|
-
const details = getAllByDescriptionTerm(term);
|
|
61
|
-
expect(details).toHaveLength(2);
|
|
62
|
-
expect(details[0]).toHaveTextContent('bar1');
|
|
63
|
-
expect(details[1]).toHaveTextContent('bar2');
|
|
64
|
-
});
|
|
65
|
-
});
|
|
66
|
-
//# sourceMappingURL=index.spec.js.map
|
package/dist/index.spec.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.spec.js","sourceRoot":"src/","sources":["index.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAE9C,OAAO,EACL,sBAAsB,EACtB,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,SAAS,CAAC;AAEjB,QAAQ,CAAC,0BAA0B,EAAE,GAAG,EAAE;IACxC,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;QACvE,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;YAChC,GAAG,EAAE,KAAK;YACV,GAAG,EAAE,KAAK;YACV,GAAG,SAAS;SACb,CAAC,CAAC;QAEH,MAAM,CAAC,sBAAsB,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC;YACnD,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;YAC1B,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;YAC1B,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;YAC1B,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;YAC1B,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;SAC3B,CAAC,CAAC;QAEH,MAAM,CAAC,sBAA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