chore(deps-dev): update to @tsconfig/svelte v5.0.1

fixes https://github.com/containers/podman-desktop/pull/3624
Signed-off-by: Florent Benoit <fbenoit@redhat.com>
This commit is contained in:
Florent Benoit 2023-08-22 18:35:17 +02:00 committed by Florent BENOIT
parent 374d54758c
commit 05188f9cd9
46 changed files with 185 additions and 153 deletions

View file

@ -18,7 +18,7 @@
"@testing-library/jest-dom": "^6.1.2",
"@testing-library/svelte": "^4.0.3",
"@testing-library/user-event": "^14.4.3",
"@tsconfig/svelte": "^4.0.1",
"@tsconfig/svelte": "^5.0.1",
"@types/js-yaml": "^4.0.5",
"@types/validator": "^13.11.1",
"@typescript-eslint/eslint-plugin": "5.62.0",

View file

@ -30,7 +30,7 @@ export class TelemetryService {
return TelemetryService.instance;
}
private handlerFlusher;
private handlerFlusher: NodeJS.Timeout | undefined;
public handlePageOpen(pagePath: string) {
if (this.handlerFlusher !== undefined) {

View file

@ -32,19 +32,19 @@ const listContainersMock = vi.fn();
const myContainer: ContainerInfo = {
Id: 'myContainer',
Labels: undefined,
Labels: {},
Status: 'running',
engineId: 'engine0',
engineName: 'podman',
engineType: 'podman',
StartedAt: undefined,
StartedAt: '',
Names: ['name0'],
Image: '',
ImageID: undefined,
Command: undefined,
ImageID: '',
Command: '',
Created: 0,
Ports: undefined,
State: undefined,
Ports: [],
State: '',
};
const deleteContainerMock = vi.fn();

View file

@ -205,7 +205,7 @@ export class ContainerUtils {
containers: [],
});
}
groups.get(group.name).containers.push(containerInfo);
groups.get(group.name)?.containers.push(containerInfo);
}
});

View file

@ -75,6 +75,8 @@ export class ContextUI implements IContext {
}
for (let i = 1; i < bits.length; i++) {
if (contextValue) {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
contextValue = contextValue[bits[i]];
}
}

View file

@ -38,6 +38,8 @@ function createContext(ctx: any) {
function strImplies(p0: string, q0: string): boolean {
const p = ContextKeyExpr.deserialize(p0);
const q = ContextKeyExpr.deserialize(q0);
assert(p);
assert(q);
return implies(p, q);
}
@ -69,7 +71,8 @@ suite('ContextKeyExpr', () => {
ContextKeyExpr.and(ContextKeyExpr.equals('and.a', true)),
ContextKeyExpr.not('d2'),
);
assert(a.equals(b), 'expressions should be equal');
assert(b);
assert(a?.equals(b), 'expressions should be equal');
});
test('issue #134942: Equals in comparator expressions', () => {
@ -106,7 +109,7 @@ suite('ContextKeyExpr', () => {
});
function testExpression(expr: string, expected: boolean): void {
const rules = ContextKeyExpr.deserialize(expr);
assert.strictEqual(rules.evaluate(context), expected, expr);
assert.strictEqual(rules?.evaluate(context), expected, expr);
}
function testBatch(expr: string, value: any): void {
/* eslint-disable eqeqeq */
@ -149,7 +152,7 @@ suite('ContextKeyExpr', () => {
test('negate', () => {
function testNegate(expr: string, expected: string): void {
const actual = ContextKeyExpr.deserialize(expr).negate().serialize();
const actual = ContextKeyExpr.deserialize(expr)?.negate().serialize();
assert.strictEqual(actual, expected);
}
testNegate('true', 'false');
@ -171,7 +174,7 @@ suite('ContextKeyExpr', () => {
await initContextKeysPlatform();
function testNormalize(expr: string, expected: string): void {
const actual = ContextKeyExpr.deserialize(expr).serialize();
const actual = ContextKeyExpr.deserialize(expr)?.serialize();
assert.strictEqual(actual, expected);
}
testNormalize('true', 'true');
@ -203,32 +206,32 @@ suite('ContextKeyExpr', () => {
test('ContextKeyInExpr', () => {
const ainb = ContextKeyExpr.deserialize('a in b');
assert.strictEqual(ainb.evaluate(createContext({ a: 3, b: [3, 2, 1] })), true);
assert.strictEqual(ainb.evaluate(createContext({ a: 3, b: [1, 2, 3] })), true);
assert.strictEqual(ainb.evaluate(createContext({ a: 3, b: [1, 2] })), false);
assert.strictEqual(ainb.evaluate(createContext({ a: 3 })), false);
assert.strictEqual(ainb.evaluate(createContext({ a: 3, b: undefined })), false);
assert.strictEqual(ainb.evaluate(createContext({ a: 'x', b: ['x'] })), true);
assert.strictEqual(ainb.evaluate(createContext({ a: 'x', b: ['y'] })), false);
assert.strictEqual(ainb.evaluate(createContext({ a: 'x', b: {} })), false);
assert.strictEqual(ainb.evaluate(createContext({ a: 'x', b: { x: false } })), true);
assert.strictEqual(ainb.evaluate(createContext({ a: 'x', b: { x: true } })), true);
assert.strictEqual(ainb.evaluate(createContext({ a: 'prototype', b: {} })), false);
assert.strictEqual(ainb?.evaluate(createContext({ a: 3, b: [3, 2, 1] })), true);
assert.strictEqual(ainb?.evaluate(createContext({ a: 3, b: [1, 2, 3] })), true);
assert.strictEqual(ainb?.evaluate(createContext({ a: 3, b: [1, 2] })), false);
assert.strictEqual(ainb?.evaluate(createContext({ a: 3 })), false);
assert.strictEqual(ainb?.evaluate(createContext({ a: 3, b: undefined })), false);
assert.strictEqual(ainb?.evaluate(createContext({ a: 'x', b: ['x'] })), true);
assert.strictEqual(ainb?.evaluate(createContext({ a: 'x', b: ['y'] })), false);
assert.strictEqual(ainb?.evaluate(createContext({ a: 'x', b: {} })), false);
assert.strictEqual(ainb?.evaluate(createContext({ a: 'x', b: { x: false } })), true);
assert.strictEqual(ainb?.evaluate(createContext({ a: 'x', b: { x: true } })), true);
assert.strictEqual(ainb?.evaluate(createContext({ a: 'prototype', b: {} })), false);
});
test('ContextKeyNotInExpr', () => {
const aNotInB = ContextKeyExpr.deserialize('a not in b');
assert.strictEqual(aNotInB.evaluate(createContext({ a: 3, b: [3, 2, 1] })), false);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 3, b: [1, 2, 3] })), false);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 3, b: [1, 2] })), true);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 3 })), true);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 3, b: undefined })), true);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 'x', b: ['x'] })), false);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 'x', b: ['y'] })), true);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 'x', b: {} })), true);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 'x', b: { x: false } })), false);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 'x', b: { x: true } })), false);
assert.strictEqual(aNotInB.evaluate(createContext({ a: 'prototype', b: {} })), true);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 3, b: [3, 2, 1] })), false);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 3, b: [1, 2, 3] })), false);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 3, b: [1, 2] })), true);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 3 })), true);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 3, b: undefined })), true);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 'x', b: ['x'] })), false);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 'x', b: ['y'] })), true);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 'x', b: {} })), true);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 'x', b: { x: false } })), false);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 'x', b: { x: true } })), false);
assert.strictEqual(aNotInB?.evaluate(createContext({ a: 'prototype', b: {} })), true);
});
test('issue #106524: distributing AND should normalize', () => {
@ -240,26 +243,30 @@ suite('ContextKeyExpr', () => {
ContextKeyExpr.and(ContextKeyExpr.has('a'), ContextKeyExpr.has('c')),
ContextKeyExpr.and(ContextKeyExpr.has('b'), ContextKeyExpr.has('c')),
);
assert.strictEqual(actual.equals(expected), true);
assert(expected);
assert.strictEqual(actual?.equals(expected), true);
});
test('issue #129625: Removes duplicated terms in OR expressions', () => {
const expr = ContextKeyExpr.or(ContextKeyExpr.has('A'), ContextKeyExpr.has('B'), ContextKeyExpr.has('A'));
assert.strictEqual(expr.serialize(), 'A || B');
assert.strictEqual(expr?.serialize(), 'A || B');
});
test('Resolves true constant OR expressions', () => {
const expr = ContextKeyExpr.or(ContextKeyExpr.has('A'), ContextKeyExpr.not('A'));
assert(expr);
assert.strictEqual(expr.serialize(), 'true');
});
test('Resolves false constant AND expressions', () => {
const expr = ContextKeyExpr.and(ContextKeyExpr.has('A'), ContextKeyExpr.not('A'));
assert(expr);
assert.strictEqual(expr.serialize(), 'false');
});
test('issue #129625: Removes duplicated terms in AND expressions', () => {
const expr = ContextKeyExpr.and(ContextKeyExpr.has('A'), ContextKeyExpr.has('B'), ContextKeyExpr.has('A'));
assert(expr);
assert.strictEqual(expr.serialize(), 'A && B');
});
@ -268,6 +275,7 @@ suite('ContextKeyExpr', () => {
ContextKeyExpr.has('A'),
ContextKeyExpr.or(ContextKeyExpr.has('B1'), ContextKeyExpr.has('B2')),
);
assert(expr);
assert.strictEqual(expr.serialize(), 'A && B1 || A && B2');
assert.strictEqual(expr.negate().serialize(), '!A || !A && !B1 || !A && !B2 || !B1 && !B2');
assert.strictEqual(expr.negate().negate().serialize(), 'A && B1 || A && B2');
@ -297,6 +305,7 @@ suite('ContextKeyExpr', () => {
test('Greater, GreaterEquals, Smaller, SmallerEquals evaluate', () => {
function checkEvaluate(expr: string, ctx: any, expected: any): void {
const _expr = ContextKeyExpr.deserialize(expr);
assert(_expr);
assert.strictEqual(_expr.evaluate(createContext(ctx)), expected);
}
@ -342,6 +351,7 @@ suite('ContextKeyExpr', () => {
test('Greater, GreaterEquals, Smaller, SmallerEquals negate', () => {
function checkNegate(expr: string, expected: string): void {
const a = ContextKeyExpr.deserialize(expr);
assert(a);
const b = a.negate();
assert.strictEqual(b.serialize(), expected);
}
@ -365,19 +375,20 @@ suite('ContextKeyExpr', () => {
test('issue #111899: context keys can use `<` or `>` ', () => {
const actual = ContextKeyExpr.deserialize('editorTextFocus && vim.active && vim.use<C-r>');
assert.ok(
actual.equals(
ContextKeyExpr.and(
ContextKeyExpr.has('editorTextFocus'),
ContextKeyExpr.has('vim.active'),
ContextKeyExpr.has('vim.use<C-r>'),
),
),
assert(actual);
const context = ContextKeyExpr.and(
ContextKeyExpr.has('editorTextFocus'),
ContextKeyExpr.has('vim.active'),
ContextKeyExpr.has('vim.use<C-r>'),
);
assert(context);
assert.ok(actual.equals(context));
});
test('ContextKeyEqualsExpr', () => {
const a_cequalsb = ContextKeyExpr.deserialize('a == b');
assert(a_cequalsb);
assert.strictEqual(a_cequalsb.evaluate(createContext({ a: 'b' })), true);
});
});

View file

@ -23,6 +23,7 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
/* eslint-disable sonarjs/no-identical-functions */
/* eslint-disable sonarjs/no-nested-switch */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
import type { LexingError, Token } from './scanner.js';
import { Scanner, TokenType } from './scanner.js';
@ -1840,7 +1841,7 @@ export class ContextKeyAndExpr implements IContextKeyExpression {
for (const expr of this.expr) {
result.push(expr.negate());
}
this.negated = ContextKeyOrExpr.create(result, this, true);
this.negated = ContextKeyOrExpr.create(result, this, true)!;
}
return this.negated;
}
@ -2027,18 +2028,18 @@ export class ContextKeyOrExpr implements IContextKeyExpression {
const RIGHT = result.shift();
const all: ContextKeyExpression[] = [];
for (const left of getTerminals(LEFT)) {
for (const right of getTerminals(RIGHT)) {
all.push(ContextKeyAndExpr.create([left, right], undefined, false));
for (const left of getTerminals(LEFT!)) {
for (const right of getTerminals(RIGHT!)) {
all.push(ContextKeyAndExpr.create([left, right], undefined, false)!);
}
}
result.unshift(ContextKeyOrExpr.create(all, undefined, false));
result.unshift(ContextKeyOrExpr.create(all, undefined, false)!);
}
this.negated = ContextKeyOrExpr.create(result, this, true);
}
return this.negated;
return this.negated!;
}
}

View file

@ -5,7 +5,7 @@ import PreflightChecks from './PreflightChecks.svelte';
import ProviderLinks from './ProviderLinks.svelte';
import ProviderLogo from './ProviderLogo.svelte';
import ProviderUpdateButton from './ProviderUpdateButton.svelte';
import Steps from 'svelte-steps/Steps.svelte';
import { Steps } from 'svelte-steps';
import { onMount } from 'svelte';
import { InitializeAndStartMode, InitializationSteps, type InitializationContext } from './ProviderInitUtils';

View file

@ -11,7 +11,7 @@ import 'xterm/css/xterm.css';
import { TerminalSettings } from '../../../../main/src/plugin/terminal-settings';
import { getPanelDetailColor } from '../color/color';
import { type InitializationContext, InitializationSteps, InitializeAndStartMode } from './ProviderInitUtils';
import Steps from 'svelte-steps/Steps.svelte';
import { Steps } from 'svelte-steps';
import Spinner from '../ui/Spinner.svelte';
export let provider: ProviderInfo;

View file

@ -17,7 +17,7 @@ import {
InitializeAndStartMode,
InitializeOnlyMode,
} from './ProviderInitUtils';
import Steps from 'svelte-steps/Steps.svelte';
import { Steps } from 'svelte-steps';
import Spinner from '../ui/Spinner.svelte';
export let provider: ProviderInfo;

View file

@ -62,11 +62,11 @@ describe('MessageBox', () => {
expect(title).toBeInTheDocument();
const message = await screen.findByText(messageBoxOptions.message);
expect(message).toBeInTheDocument();
const detail = await screen.findByText(messageBoxOptions.detail);
const detail = await screen.findByText(messageBoxOptions.detail || '');
expect(detail).toBeInTheDocument();
const button1 = await screen.findByText(messageBoxOptions.buttons[0]);
const button1 = await screen.findByText(messageBoxOptions.buttons?.[0] || '');
expect(button1).toBeInTheDocument();
const button2 = await screen.findByText(messageBoxOptions.buttons[1]);
const button2 = await screen.findByText(messageBoxOptions.buttons?.[1] || '');
expect(button2).toBeInTheDocument();
});

View file

@ -23,7 +23,7 @@ import { test, expect, vi, beforeAll } from 'vitest';
import { render, screen } from '@testing-library/svelte';
import { providerInfos } from '../../stores/providers';
import type { ProviderStatus } from '@podman-desktop/api';
import type { ProviderContainerConnectionInfo } from '../../../../main/src/plugin/api/provider-info';
import type { ProviderContainerConnectionInfo, ProviderInfo } from '../../../../main/src/plugin/api/provider-info';
import userEvent from '@testing-library/user-event';
import BuildImageFromContainerfile from '/@/lib/image/BuildImageFromContainerfile.svelte';
@ -70,7 +70,7 @@ function setup() {
warnings: undefined,
images: undefined,
installationSupport: undefined,
};
} as unknown as ProviderInfo;
providerInfos.set([providerInfo]);
}

View file

@ -32,10 +32,10 @@ const listImagesMock = vi.fn();
const myImage: ImageInfo = {
Id: 'myImage',
Labels: undefined,
Labels: {},
engineId: 'engine0',
engineName: 'podman',
ParentId: undefined,
ParentId: '',
RepoTags: ['myImageTag'],
Created: 0,
Size: 0,

View file

@ -24,7 +24,7 @@ import { render, screen } from '@testing-library/svelte';
import PullImage from './PullImage.svelte';
import { providerInfos } from '../../stores/providers';
import type { ProviderStatus } from '@podman-desktop/api';
import type { ProviderContainerConnectionInfo } from '../../../../main/src/plugin/api/provider-info';
import type { ProviderContainerConnectionInfo, ProviderInfo } from '../../../../main/src/plugin/api/provider-info';
import userEvent from '@testing-library/user-event';
const pullImageMock = vi.fn();
@ -89,7 +89,7 @@ function setup() {
warnings: undefined,
images: undefined,
installationSupport: undefined,
};
} as unknown as ProviderInfo;
providerInfos.set([providerInfo]);
}

View file

@ -76,7 +76,7 @@ async function createRunImage(entrypoint?: string | string[], cmd?: string[]) {
AttachStderr: false,
AttachStdin: false,
AttachStdout: false,
Cmd: cmd,
Cmd: cmd || [],
Domainname: '',
Entrypoint: entrypoint,
Env: [],

View file

@ -85,7 +85,7 @@ export function clearBuildTask(info: BuildImageInfo): void {
buildOnHolds.delete(info.buildImageKey);
buildReplays.delete(info.buildImageKey);
// remove current build
buildImagesInfo.set(undefined);
buildImagesInfo.set({ buildImageKey: getKey(), buildRunning: false });
// remove the task
const task = allTasks.get(info.buildImageKey);
@ -197,10 +197,10 @@ export function eventCollect(key: symbol, eventName: 'finish' | 'stream' | 'erro
}
}
if (eventName === 'stream') {
callback.onStream(data);
callback?.onStream(data);
} else if (eventName === 'error') {
callback.onError(data);
callback?.onError(data);
} else if (eventName === 'finish') {
callback.onEnd();
callback?.onEnd();
}
}

View file

@ -22,7 +22,7 @@ import { providerInfos } from '../../stores/providers';
import { render, screen } from '@testing-library/svelte';
import KubePlayYAML from './KubePlayYAML.svelte';
import type { ProviderStatus } from '@podman-desktop/api';
import type { ProviderContainerConnectionInfo } from '../../../../main/src/plugin/api/provider-info';
import type { ProviderContainerConnectionInfo, ProviderInfo } from '../../../../main/src/plugin/api/provider-info';
import userEvent from '@testing-library/user-event';
import type { PlayKubeInfo } from '../../../../main/src/plugin/dockerode/libpod-dockerode';
@ -110,7 +110,7 @@ function setup() {
warnings: undefined,
images: undefined,
installationSupport: undefined,
};
} as unknown as ProviderInfo;
providerInfos.set([providerInfo]);
}

View file

@ -16,6 +16,9 @@
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/
/* eslint-disable @typescript-eslint/ban-ts-comment */
// @ts-nocheck
/**
* Allow to generate a custom button markdown directive
* syntax is the following:
@ -26,7 +29,7 @@
* @this {import('micromark-util-types').CompileContext}
* @type {import('micromark-extension-directive').Handle}
*/
export function button(d) {
export function button(d: any) {
if (d.type !== 'textDirective') {
return false;
}

View file

@ -120,7 +120,7 @@ afterEach(() => {
vi.clearAllMocks();
});
async function waitRender(customProperties): Promise<void> {
async function waitRender(customProperties: any): Promise<void> {
const result = render(DeployPodToKube, { resourceId: 'foo', engineId: 'bar', ...customProperties });
// wait that result.component.$$.ctx[0] is set
while (result.component.$$.ctx[0] === undefined) {

View file

@ -32,9 +32,9 @@ const providerInfo: ProviderInfo = {
icon: 'img',
},
status: 'started',
warnings: undefined,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: undefined,
detectionChecks: [],
containerConnections: [
{
name: 'machine',
@ -46,11 +46,11 @@ const providerInfo: ProviderInfo = {
type: 'podman',
},
],
installationSupport: undefined,
installationSupport: false,
internalId: '0',
kubernetesConnections: [],
kubernetesProviderConnectionCreation: true,
links: undefined,
links: [],
containerProviderConnectionInitialization: false,
containerProviderConnectionCreationDisplayName: 'Podman machine',
kubernetesProviderConnectionInitialization: false,

View file

@ -45,7 +45,7 @@ const provider: ProviderInfo = {
containerProviderConnectionInitialization: false,
detectionChecks: [],
id: 'providerid',
images: undefined,
images: {},
installationSupport: false,
internalId: 'providerid',
kubernetesConnections: [],
@ -53,7 +53,7 @@ const provider: ProviderInfo = {
kubernetesProviderConnectionInitialization: false,
links: [],
name: 'MyProvider',
status: undefined,
status: 'started',
warnings: [],
};

View file

@ -35,15 +35,15 @@ const containerProviderInfo: ProviderInfo = {
icon: 'img',
},
status: 'started',
warnings: undefined,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: undefined,
detectionChecks: [],
containerConnections: [],
installationSupport: undefined,
installationSupport: false,
internalId: '0',
kubernetesConnections: [],
kubernetesProviderConnectionCreation: true,
links: undefined,
links: [],
containerProviderConnectionInitialization: false,
kubernetesProviderConnectionInitialization: false,
};

View file

@ -72,7 +72,9 @@ test('Expect that the create button is available', async () => {
});
test('Expect create connection successfully', async () => {
let providedKeyLogger;
let providedKeyLogger:
| ((key: symbol, eventName: 'log' | 'warn' | 'error' | 'finish', args: unknown[]) => void)
| undefined;
const callback = vi.fn();
callback.mockImplementation(async function (
@ -119,22 +121,26 @@ test('Expect create connection successfully', async () => {
expect(providedKeyLogger).toBeDefined();
// simulate end of the create operation
providedKeyLogger(currentConnectionInfo.createKey, 'finish', []);
if (providedKeyLogger) {
providedKeyLogger(currentConnectionInfo.createKey, 'finish', []);
}
// expect it is sucessful
const currentConnectionInfoAfterMap = get(createConnectionsInfo);
expect(currentConnectionInfoAfterMap).toBeDefined();
const currentConnectionInfoAfter = currentConnectionInfoAfterMap.get(2);
expect(currentConnectionInfoAfter.creationInProgress).toBeFalsy();
expect(currentConnectionInfoAfter.creationStarted).toBeTruthy();
expect(currentConnectionInfoAfter.creationSuccessful).toBeTruthy();
expect(currentConnectionInfoAfter?.creationInProgress).toBeFalsy();
expect(currentConnectionInfoAfter?.creationStarted).toBeTruthy();
expect(currentConnectionInfoAfter?.creationSuccessful).toBeTruthy();
const closeButton = screen.getByRole('button', { name: 'Close panel' });
expect(closeButton).toBeInTheDocument();
});
test('Expect cancelling the creation, trigger the cancellation token', async () => {
let providedKeyLogger;
let providedKeyLogger:
| ((key: symbol, eventName: 'log' | 'warn' | 'error' | 'finish', args: unknown[]) => void)
| undefined;
const callback = vi.fn();
callback.mockImplementation(async function (
@ -187,7 +193,9 @@ test('Expect cancelling the creation, trigger the cancellation token', async ()
await fireEvent.click(cancelButton);
// simulate end of the create operation
providedKeyLogger(currentConnectionInfo.createKey, 'finish', []);
if (providedKeyLogger) {
providedKeyLogger(currentConnectionInfo.createKey, 'finish', []);
}
// expect it is sucessful
expect(cancelTokenMock).toBeCalled;

View file

@ -44,9 +44,9 @@ test('Expect that the right machine is displayed', async () => {
icon: 'img',
},
status: 'started',
warnings: undefined,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: undefined,
detectionChecks: [],
containerConnections: [
{
name: podmanMachineName1,
@ -73,11 +73,11 @@ test('Expect that the right machine is displayed', async () => {
type: 'podman',
},
],
installationSupport: undefined,
installationSupport: false,
internalId: '0',
kubernetesConnections: [],
kubernetesProviderConnectionCreation: true,
links: undefined,
links: [],
containerProviderConnectionInitialization: false,
containerProviderConnectionCreationDisplayName: 'Podman machine',
kubernetesProviderConnectionInitialization: false,
@ -120,9 +120,9 @@ test('Expect that removing the connection is going back to the previous page', a
icon: 'img',
},
status: 'started',
warnings: undefined,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: undefined,
detectionChecks: [],
containerConnections: [
{
name: podmanMachineName1,
@ -150,11 +150,11 @@ test('Expect that removing the connection is going back to the previous page', a
type: 'podman',
},
],
installationSupport: undefined,
installationSupport: false,
internalId: '0',
kubernetesConnections: [],
kubernetesProviderConnectionCreation: true,
links: undefined,
links: [],
containerProviderConnectionInitialization: false,
containerProviderConnectionCreationDisplayName: 'Podman machine',
kubernetesProviderConnectionInitialization: false,

View file

@ -30,9 +30,9 @@ const providerInfo: ProviderInfo = {
icon: 'img',
},
status: 'started',
warnings: undefined,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: undefined,
detectionChecks: [],
containerConnections: [
{
name: 'machine',
@ -44,11 +44,11 @@ const providerInfo: ProviderInfo = {
type: 'podman',
},
],
installationSupport: undefined,
installationSupport: false,
internalId: '0',
kubernetesConnections: [],
kubernetesProviderConnectionCreation: true,
links: undefined,
links: [],
containerProviderConnectionInitialization: false,
containerProviderConnectionCreationDisplayName: 'Podman machine',
kubernetesProviderConnectionInitialization: false,

View file

@ -32,9 +32,9 @@ const providerInfo: ProviderInfo = {
icon: 'img',
},
status: 'started',
warnings: undefined,
warnings: [],
containerProviderConnectionCreation: true,
detectionChecks: undefined,
detectionChecks: [],
containerConnections: [
{
name: 'machine',
@ -46,11 +46,11 @@ const providerInfo: ProviderInfo = {
type: 'podman',
},
],
installationSupport: undefined,
installationSupport: false,
internalId: '0',
kubernetesConnections: [],
kubernetesProviderConnectionCreation: true,
links: undefined,
links: [],
containerProviderConnectionInitialization: false,
containerProviderConnectionCreationDisplayName: 'Podman machine',
kubernetesProviderConnectionInitialization: false,

View file

@ -78,9 +78,9 @@ test('Expect section styling', async () => {
const element = screen.getByLabelText(title);
expect(element).toBeInTheDocument();
expect(element.firstChild).toBeInTheDocument();
expect(element.firstChild.childNodes[2]).toBeInTheDocument();
expect(element.firstChild.childNodes[2].firstChild).toBeInTheDocument();
expect(element.firstChild.childNodes[2].firstChild).toHaveClass('fas');
expect(element.firstChild?.childNodes[2]).toBeInTheDocument();
expect(element.firstChild?.childNodes[2].firstChild).toBeInTheDocument();
expect(element.firstChild?.childNodes[2].firstChild).toHaveClass('fas');
});
test('Expect sections expand', async () => {
@ -91,13 +91,13 @@ test('Expect sections expand', async () => {
const element = screen.getByLabelText(title);
expect(element).toBeInTheDocument();
expect(element.firstChild).toBeInTheDocument();
expect(element.firstChild.childNodes[2]).toBeInTheDocument();
expect(element.firstChild.childNodes[2]).toContainHTML('fa-angle-right');
expect(element.firstChild.childNodes[2]).not.toContainHTML('fa-angle-down');
expect(element.firstChild?.childNodes[2]).toBeInTheDocument();
expect(element.firstChild?.childNodes[2]).toContainHTML('fa-angle-right');
expect(element.firstChild?.childNodes[2]).not.toContainHTML('fa-angle-down');
await fireEvent.click(element);
// since it is animated, we'll test that the down angle has appeared (and
// not wait for right angle to disappear)
expect(element.firstChild.childNodes[2]).toContainHTML('fa-angle-down');
expect(element.firstChild?.childNodes[2]).toContainHTML('fa-angle-down');
});

View file

@ -208,12 +208,12 @@ export function eventCollect(key: symbol, eventName: 'log' | 'warn' | 'error' |
}
}
if (eventName === 'log') {
callback.log(args);
callback?.log(args);
} else if (eventName === 'warn') {
callback.warn(args);
callback?.warn(args);
} else if (eventName === 'error') {
callback.error(args);
callback?.error(args);
} else if (eventName === 'finish') {
callback.onEnd();
callback?.onEnd();
}
}

View file

@ -15,7 +15,7 @@
*
* SPDX-License-Identifier: Apache-2.0
***********************************************************************/
export function splitSpacesHandlingDoubleQuotes(inputString): string[] {
export function splitSpacesHandlingDoubleQuotes(inputString: string): string[] {
const tokens = [];
let currentToken = '';
let insideQuotes = false;

View file

@ -72,6 +72,6 @@ test('Check containers button is available and click on it', async () => {
// check content
expect(style).toHaveTextContent(
`.podman-desktop-icon-my-icon-id:before { content: '\\E01'; font-family: '${icon.definition.font.fontId}'; } @font-face { src: url('file://my-font.woff') format('woff2'); font-family: 'my-font-id'; font-display: block; }`,
`.podman-desktop-icon-my-icon-id:before { content: '\\E01'; font-family: '${icon.definition.font?.fontId}'; } @font-face { src: url('file://my-font.woff') format('woff2'); font-family: 'my-font-id'; font-display: block; }`,
);
});

View file

@ -24,7 +24,7 @@ import { render, screen } from '@testing-library/svelte';
import Checkbox from './Checkbox.svelte';
function getPeer(checkbox: HTMLElement) {
return checkbox.parentElement.children[1];
return checkbox.parentElement?.children[1];
}
test('Basic check', async () => {

View file

@ -52,8 +52,8 @@ test('Check icon styling', async () => {
const link = screen.getByRole('link');
expect(link).toBeInTheDocument();
expect(link.firstChild).toBeInTheDocument();
expect(link.firstChild.firstChild).toBeInTheDocument();
expect(link.firstChild.firstChild).toHaveClass('svelte-fa');
expect(link.firstChild?.firstChild).toBeInTheDocument();
expect(link.firstChild?.firstChild).toHaveClass('svelte-fa');
});
test('Check href action', async () => {

View file

@ -36,12 +36,14 @@ export type ActivateFunction = {
(_node: unknown, binding: unknown): UpdateAction;
};
export function createFieldValidator(...validators): [SvelteStore<Validation>, ActivateFunction] {
export function createFieldValidator(
...validators: ((value: string) => [boolean, string])[]
): [SvelteStore<Validation>, ActivateFunction] {
const validation: Validation = { dirty: false, valid: false, message: undefined };
const writableObject = writable<Validation>(validation);
const validator = buildValidator(validators);
function action(_node, binding): UpdateAction {
function action(_node: any, binding: any): UpdateAction {
function validate(value: string, dirty: boolean) {
const result = validator(value, dirty);
writableObject.set(result);

View file

@ -38,16 +38,16 @@ const myVolume: VolumeListInfo = {
Name: 'myVolume',
engineId: 'engine0',
engineName: 'podman',
CreatedAt: undefined,
containersUsage: undefined,
Driver: undefined,
Mountpoint: undefined,
Labels: undefined,
CreatedAt: '',
containersUsage: [],
Driver: '',
Mountpoint: '',
Labels: {},
Scope: 'local',
Options: undefined,
Options: {},
},
],
Warnings: undefined,
Warnings: [],
};
const removeVolumeMock = vi.fn();

View file

@ -74,7 +74,7 @@ export class VolumeUtils {
engineId: volumeInfo.engineId,
engineName: volumeInfo.engineName,
selected: false,
inUse: volumeInfo.UsageData?.RefCount > 0,
inUse: (volumeInfo.UsageData?.RefCount || 0) > 0,
containersUsage: volumeInfo.containersUsage,
};
}

View file

@ -21,7 +21,7 @@ import { TelemetrySettings } from '../../../../main/src/plugin/telemetry/telemet
import { CONFIGURATION_DEFAULT_SCOPE } from '../../../../main/src/plugin/configuration-registry-constants';
export class WelcomeUtils {
async getVersion(): Promise<string> {
async getVersion(): Promise<string | undefined> {
return window.getConfigurationValue<string>(WelcomeSettings.SectionName + '.' + WelcomeSettings.Version);
}
@ -33,7 +33,7 @@ export class WelcomeUtils {
);
}
havePromptedForTelemetry(): Promise<boolean> {
havePromptedForTelemetry(): Promise<boolean | undefined> {
return window.getConfigurationValue<boolean>(TelemetrySettings.SectionName + '.' + TelemetrySettings.Check);
}

View file

@ -1,7 +1,10 @@
import Loader from './Loader.svelte';
const app = new Loader({
target: document.getElementById('app'),
});
const target = document.getElementById('app');
let app;
if (target) {
app = new Loader({
target,
});
}
export default app;

View file

@ -20,7 +20,7 @@ import { writable, type Writable } from 'svelte/store';
import type { CatalogExtension } from '../../../main/src/plugin/extensions-catalog/extensions-catalog-api';
import { EventStore } from './event-store';
const windowEvents = [];
const windowEvents: string[] = [];
const windowListeners = ['system-ready'];
export async function checkForUpdate(): Promise<boolean> {

View file

@ -22,14 +22,14 @@ import { ContextUI } from '../lib/context/context';
export const context: Writable<ContextUI> = writable(new ContextUI());
window.events?.receive('context-value-updated', async value => {
window.events?.receive('context-value-updated', async (value: { key: string; value: string }) => {
context.update(ctx => {
ctx.setValue(value.key, value.value);
return ctx;
});
});
window.events?.receive('context-key-removed', async value => {
window.events?.receive('context-key-removed', async (value: { key: string; value: string }) => {
context.update(ctx => {
ctx.removeValue(value.key);
return ctx;

View file

@ -103,7 +103,7 @@ test('should call fetch method using window event', async () => {
expect(eventStoreInfo.bufferEvents.length).toBe(1);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('name', windowEventName);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('skipped', false);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('args', undefined);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('args', []);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('length', 1);
});
@ -163,7 +163,7 @@ test('should call fetch method using listener event', async () => {
expect(eventStoreInfo.bufferEvents.length).toBe(1);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('name', windowListenerEventName);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('skipped', false);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('args', undefined);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('args', []);
expect(eventStoreInfo.bufferEvents[0]).toHaveProperty('length', 1);
});

View file

@ -134,7 +134,7 @@ export class EventStore<T> {
} finally {
this.updateEvent(eventStoreInfo, {
name: eventName,
args: args,
args: args || [],
date: Date.now(),
skipped: !needUpdate,
length: numberOfResults,
@ -153,7 +153,7 @@ export class EventStore<T> {
}
setup(): EventStoreInfo {
const bufferEvents = [];
const bufferEvents: EventStoreInfoEvent[] = [];
// register the store in the global list
const eventStoreInfo: EventStoreInfo = {
@ -198,7 +198,7 @@ export class EventStore<T> {
this.updateEvent(eventStoreInfo, {
name: `debounce-${eventName}`,
args: args,
args: args || [],
date: Date.now(),
skipped: true,
length: 0,

View file

@ -52,7 +52,7 @@ const eventStore = new EventStore<ProviderInfo[]>(
);
eventStore.setup();
const updateProviderCallbacks = [];
const updateProviderCallbacks: string[] = [];
export async function fetchProviders(): Promise<ProviderInfo[]> {
const result = await window.getProviderInfos();
providerInfos.set(result);

View file

@ -64,12 +64,12 @@ export function createTask(name: string): Task {
return task;
}
window.events?.receive('task-created', task => {
window.events?.receive('task-created', (task: Task) => {
tasksInfo.update(tasks => [...tasks, task]);
});
window.events?.receive('task-updated', task => {
window.events?.receive('task-updated', (task: Task) => {
updateTask(task);
});
window.events?.receive('task-removed', task => {
window.events?.receive('task-removed', (task: Task) => {
removeTask(task.id);
});

View file

@ -3,6 +3,7 @@
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"strict": false,
"resolveJsonModule": true,
"preserveValueImports": false,
"baseUrl": ".",

View file

@ -2,3 +2,4 @@ declare module 'win-ca/api';
declare module 'zip-local';
declare module 'micromark-extension-directive';
declare module 'date.js';
declare module 'humanize-duration';

View file

@ -3115,10 +3115,10 @@
resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.2.tgz#423c77877d0569db20e1fc80885ac4118314010e"
integrity sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==
"@tsconfig/svelte@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@tsconfig/svelte/-/svelte-4.0.1.tgz#f36c1085fbdd868c10fb0426141956483dd4867b"
integrity sha512-B+XlGpmuAQzJqDoBATNCvEPqQg0HkO7S8pM14QDI5NsmtymzRexQ1N+nX2H6RTtFbuFgaZD4I8AAi8voGg0GLg==
"@tsconfig/svelte@^5.0.1":
version "5.0.1"
resolved "https://registry.yarnpkg.com/@tsconfig/svelte/-/svelte-5.0.1.tgz#44652b0d6c7efa9a44f922d381ac68de8d602526"
integrity sha512-MNzMnxEpseWdp1d10RwY+OkHnlEo/hLQ1c8nQvA8r2d22I3tQy2lqGjQTiJAwYLPAt2m4S3FKqXlQno9v7cG4A==
"@types/analytics-node@^3.1.11":
version "3.1.11"