mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-25 04:34:06 -08:00
fix(editor): Fix ts errors in PersonalizationModal.spec.ts (no-changelog) (#9562)
This commit is contained in:
parent
020bd36354
commit
6ce18ccda1
|
@ -4,10 +4,15 @@ import type { ISettingsState } from '@/Interface';
|
||||||
import { UserManagementAuthenticationMethod } from '@/Interface';
|
import { UserManagementAuthenticationMethod } from '@/Interface';
|
||||||
import { defaultSettings } from './defaults';
|
import { defaultSettings } from './defaults';
|
||||||
|
|
||||||
export const retry = async (
|
/**
|
||||||
assertion: () => ReturnType<typeof expect>,
|
* Retries the given assertion until it passes or the timeout is reached
|
||||||
{ interval = 20, timeout = 1000 } = {},
|
*
|
||||||
) => {
|
* @example
|
||||||
|
* await retry(
|
||||||
|
* () => expect(screen.getByText('Hello')).toBeInTheDocument()
|
||||||
|
* );
|
||||||
|
*/
|
||||||
|
export const retry = async (assertion: () => void, { interval = 20, timeout = 1000 } = {}) => {
|
||||||
return await new Promise((resolve, reject) => {
|
return await new Promise((resolve, reject) => {
|
||||||
const startTime = Date.now();
|
const startTime = Date.now();
|
||||||
|
|
||||||
|
@ -15,9 +20,9 @@ export const retry = async (
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
try {
|
try {
|
||||||
resolve(assertion());
|
resolve(assertion());
|
||||||
} catch (err) {
|
} catch (error) {
|
||||||
if (Date.now() - startTime > timeout) {
|
if (Date.now() - startTime > timeout) {
|
||||||
reject(err);
|
reject(error);
|
||||||
} else {
|
} else {
|
||||||
tryAgain();
|
tryAgain();
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,6 +73,7 @@ describe('PersonalizationModal.vue', () => {
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const index of [3, 4, 5, 6]) {
|
for (const index of [3, 4, 5, 6]) {
|
||||||
|
const expectFn = expect; // So we don't break @typescript-eslint/no-loop-func
|
||||||
const select = wrapper.container.querySelectorAll('.n8n-select')[1];
|
const select = wrapper.container.querySelectorAll('.n8n-select')[1];
|
||||||
|
|
||||||
await fireEvent.click(select);
|
await fireEvent.click(select);
|
||||||
|
@ -82,8 +83,8 @@ describe('PersonalizationModal.vue', () => {
|
||||||
await fireEvent.click(item);
|
await fireEvent.click(item);
|
||||||
|
|
||||||
await retry(() => {
|
await retry(() => {
|
||||||
expect(wrapper.container.querySelectorAll('.n8n-select').length).toEqual(6);
|
expectFn(wrapper.container.querySelectorAll('.n8n-select').length).toEqual(6);
|
||||||
expect(wrapper.container.querySelector('[name^="automationGoal"]')).toBeInTheDocument();
|
expectFn(wrapper.container.querySelector('[name^="automationGoal"]')).toBeInTheDocument();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -125,7 +126,8 @@ describe('PersonalizationModal.vue', () => {
|
||||||
const item = select.querySelectorAll('.el-select-dropdown__item')[3];
|
const item = select.querySelectorAll('.el-select-dropdown__item')[3];
|
||||||
await fireEvent.click(item);
|
await fireEvent.click(item);
|
||||||
|
|
||||||
const agreeCheckbox = wrapper.container.querySelector('.n8n-checkbox')!;
|
const agreeCheckbox = wrapper.container.querySelector('.n8n-checkbox');
|
||||||
|
assert(agreeCheckbox);
|
||||||
await fireEvent.click(agreeCheckbox);
|
await fireEvent.click(agreeCheckbox);
|
||||||
|
|
||||||
const submitButton = wrapper.getByRole('button');
|
const submitButton = wrapper.getByRole('button');
|
||||||
|
|
Loading…
Reference in a new issue