diff --git a/test/karma/test-app/components.d.ts b/test/karma/test-app/components.d.ts index 3ee92b19480f..4315db5d851a 100644 --- a/test/karma/test-app/components.d.ts +++ b/test/karma/test-app/components.d.ts @@ -112,14 +112,6 @@ export namespace Components { interface LifecycleAsyncC { "value": string; } - interface LifecycleBasicA { - } - interface LifecycleBasicB { - "value": string; - } - interface LifecycleBasicC { - "value": string; - } interface LifecycleNestedA { } interface LifecycleNestedB { @@ -367,14 +359,6 @@ export interface LifecycleAsyncCCustomEvent extends CustomEvent { detail: T; target: HTMLLifecycleAsyncCElement; } -export interface LifecycleBasicBCustomEvent extends CustomEvent { - detail: T; - target: HTMLLifecycleBasicBElement; -} -export interface LifecycleBasicCCustomEvent extends CustomEvent { - detail: T; - target: HTMLLifecycleBasicCElement; -} declare global { interface HTMLBadSharedJsxElement extends Components.BadSharedJsx, HTMLStencilElement { } @@ -714,48 +698,6 @@ declare global { prototype: HTMLLifecycleAsyncCElement; new (): HTMLLifecycleAsyncCElement; }; - interface HTMLLifecycleBasicAElement extends Components.LifecycleBasicA, HTMLStencilElement { - } - var HTMLLifecycleBasicAElement: { - prototype: HTMLLifecycleBasicAElement; - new (): HTMLLifecycleBasicAElement; - }; - interface HTMLLifecycleBasicBElementEventMap { - "lifecycleLoad": any; - "lifecycleUpdate": any; - } - interface HTMLLifecycleBasicBElement extends Components.LifecycleBasicB, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLLifecycleBasicBElement, ev: LifecycleBasicBCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLLifecycleBasicBElement, ev: LifecycleBasicBCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLLifecycleBasicBElement: { - prototype: HTMLLifecycleBasicBElement; - new (): HTMLLifecycleBasicBElement; - }; - interface HTMLLifecycleBasicCElementEventMap { - "lifecycleLoad": any; - "lifecycleUpdate": any; - } - interface HTMLLifecycleBasicCElement extends Components.LifecycleBasicC, HTMLStencilElement { - addEventListener(type: K, listener: (this: HTMLLifecycleBasicCElement, ev: LifecycleBasicCCustomEvent) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void; - addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLLifecycleBasicCElement, ev: LifecycleBasicCCustomEvent) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: Document, ev: DocumentEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: K, listener: (this: HTMLElement, ev: HTMLElementEventMap[K]) => any, options?: boolean | EventListenerOptions): void; - removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; - } - var HTMLLifecycleBasicCElement: { - prototype: HTMLLifecycleBasicCElement; - new (): HTMLLifecycleBasicCElement; - }; interface HTMLLifecycleNestedAElement extends Components.LifecycleNestedA, HTMLStencilElement { } var HTMLLifecycleNestedAElement: { @@ -1360,9 +1302,6 @@ declare global { "lifecycle-async-a": HTMLLifecycleAsyncAElement; "lifecycle-async-b": HTMLLifecycleAsyncBElement; "lifecycle-async-c": HTMLLifecycleAsyncCElement; - "lifecycle-basic-a": HTMLLifecycleBasicAElement; - "lifecycle-basic-b": HTMLLifecycleBasicBElement; - "lifecycle-basic-c": HTMLLifecycleBasicCElement; "lifecycle-nested-a": HTMLLifecycleNestedAElement; "lifecycle-nested-b": HTMLLifecycleNestedBElement; "lifecycle-nested-c": HTMLLifecycleNestedCElement; @@ -1568,18 +1507,6 @@ declare namespace LocalJSX { "onLifecycleUpdate"?: (event: LifecycleAsyncCCustomEvent) => void; "value"?: string; } - interface LifecycleBasicA { - } - interface LifecycleBasicB { - "onLifecycleLoad"?: (event: LifecycleBasicBCustomEvent) => void; - "onLifecycleUpdate"?: (event: LifecycleBasicBCustomEvent) => void; - "value"?: string; - } - interface LifecycleBasicC { - "onLifecycleLoad"?: (event: LifecycleBasicCCustomEvent) => void; - "onLifecycleUpdate"?: (event: LifecycleBasicCCustomEvent) => void; - "value"?: string; - } interface LifecycleNestedA { } interface LifecycleNestedB { @@ -1848,9 +1775,6 @@ declare namespace LocalJSX { "lifecycle-async-a": LifecycleAsyncA; "lifecycle-async-b": LifecycleAsyncB; "lifecycle-async-c": LifecycleAsyncC; - "lifecycle-basic-a": LifecycleBasicA; - "lifecycle-basic-b": LifecycleBasicB; - "lifecycle-basic-c": LifecycleBasicC; "lifecycle-nested-a": LifecycleNestedA; "lifecycle-nested-b": LifecycleNestedB; "lifecycle-nested-c": LifecycleNestedC; @@ -1995,9 +1919,6 @@ declare module "@stencil/core" { "lifecycle-async-a": LocalJSX.LifecycleAsyncA & JSXBase.HTMLAttributes; "lifecycle-async-b": LocalJSX.LifecycleAsyncB & JSXBase.HTMLAttributes; "lifecycle-async-c": LocalJSX.LifecycleAsyncC & JSXBase.HTMLAttributes; - "lifecycle-basic-a": LocalJSX.LifecycleBasicA & JSXBase.HTMLAttributes; - "lifecycle-basic-b": LocalJSX.LifecycleBasicB & JSXBase.HTMLAttributes; - "lifecycle-basic-c": LocalJSX.LifecycleBasicC & JSXBase.HTMLAttributes; "lifecycle-nested-a": LocalJSX.LifecycleNestedA & JSXBase.HTMLAttributes; "lifecycle-nested-b": LocalJSX.LifecycleNestedB & JSXBase.HTMLAttributes; "lifecycle-nested-c": LocalJSX.LifecycleNestedC & JSXBase.HTMLAttributes; diff --git a/test/karma/test-app/lifecycle-basic/index.html b/test/karma/test-app/lifecycle-basic/index.html deleted file mode 100644 index 6488ff6d778e..000000000000 --- a/test/karma/test-app/lifecycle-basic/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - diff --git a/test/karma/test-app/lifecycle-basic/karma.spec.ts b/test/karma/test-app/lifecycle-basic/karma.spec.ts deleted file mode 100644 index 9e1766707dfa..000000000000 --- a/test/karma/test-app/lifecycle-basic/karma.spec.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { setupDomTests, waitForChanges } from '../util'; - -describe('lifecycle-basic', function () { - const { setupDom, tearDownDom } = setupDomTests(document); - let app: HTMLElement; - - beforeEach(async () => { - app = await setupDom('/lifecycle-basic/index.html'); - }); - afterEach(tearDownDom); - - it('fire load methods in order', async () => { - let loads = app.querySelectorAll('.lifecycle-loads-a li'); - expect(loads.length).toBe(6); - expect(loads[0].textContent).toBe('componentWillLoad-a'); - expect(loads[1].textContent).toBe('componentWillLoad-b'); - expect(loads[2].textContent).toBe('componentWillLoad-c'); - expect(loads[3].textContent).toBe('componentDidLoad-c'); - expect(loads[4].textContent).toBe('componentDidLoad-b'); - expect(loads[5].textContent).toBe('componentDidLoad-a'); - - let updates = app.querySelectorAll('.lifecycle-updates-a li'); - expect(updates.length).toBe(0); - - const button = app.querySelector('button'); - button.click(); - await waitForChanges(); - - loads = app.querySelectorAll('.lifecycle-loads-a li'); - expect(loads.length).toBe(6); - expect(loads[0].textContent).toBe('componentWillLoad-a'); - expect(loads[1].textContent).toBe('componentWillLoad-b'); - expect(loads[2].textContent).toBe('componentWillLoad-c'); - expect(loads[3].textContent).toBe('componentDidLoad-c'); - expect(loads[4].textContent).toBe('componentDidLoad-b'); - expect(loads[5].textContent).toBe('componentDidLoad-a'); - - updates = app.querySelectorAll('.lifecycle-updates-a li'); - expect(updates.length).toBe(6); - - expect(updates[0].textContent).toBe('componentWillUpdate-a'); - expect(updates[1].textContent).toBe('componentWillUpdate-b'); - expect(updates[2].textContent).toBe('componentWillUpdate-c'); - expect(updates[3].textContent).toBe('componentDidUpdate-c'); - expect(updates[4].textContent).toBe('componentDidUpdate-b'); - expect(updates[5].textContent).toBe('componentDidUpdate-a'); - }); -}); diff --git a/test/wdio/lifecycle-basic/cmp-a.test.tsx b/test/wdio/lifecycle-basic/cmp-a.test.tsx new file mode 100644 index 000000000000..949f219784f2 --- /dev/null +++ b/test/wdio/lifecycle-basic/cmp-a.test.tsx @@ -0,0 +1,49 @@ +import { h, Fragment } from '@stencil/core'; +import { render } from '@wdio/browser-runner/stencil'; + +describe('lifecycle-basic', function () { + beforeEach(() => { + render({ + template: () => + }) + }) + + it('fire load methods in order', async () => { + await $('lifecycle-basic-a').waitForExist(); + let loads = await $('.lifecycle-loads-a').$$('li') + await expect(loads).toBeElementsArrayOfSize(6) + + await expect(loads[0]).toHaveText('componentWillLoad-a'); + await expect(loads[1]).toHaveText('componentWillLoad-b'); + await expect(loads[2]).toHaveText('componentWillLoad-c'); + await expect(loads[3]).toHaveText('componentDidLoad-c'); + await expect(loads[4]).toHaveText('componentDidLoad-b'); + await expect(loads[5]).toHaveText('componentDidLoad-a'); + + let updates = await $('.lifecycle-updates-a').$$('li'); + await expect(updates).not.toBeExisting(); + + const button = $('button'); + await button.click(); + + loads = await $('.lifecycle-loads-a').$$('li') + await expect(loads).toBeElementsArrayOfSize(6) + + await expect(loads[0]).toHaveText('componentWillLoad-a'); + await expect(loads[1]).toHaveText('componentWillLoad-b'); + await expect(loads[2]).toHaveText('componentWillLoad-c'); + await expect(loads[3]).toHaveText('componentDidLoad-c'); + await expect(loads[4]).toHaveText('componentDidLoad-b'); + await expect(loads[5]).toHaveText('componentDidLoad-a'); + + // updates = app.querySelectorAll('.lifecycle-updates-a li'); + // expect(updates.length).toBe(6); + + // expect(updates[0].textContent).toBe('componentWillUpdate-a'); + // expect(updates[1].textContent).toBe('componentWillUpdate-b'); + // expect(updates[2].textContent).toBe('componentWillUpdate-c'); + // expect(updates[3].textContent).toBe('componentDidUpdate-c'); + // expect(updates[4].textContent).toBe('componentDidUpdate-b'); + // expect(updates[5].textContent).toBe('componentDidUpdate-a'); + }); +}); diff --git a/test/karma/test-app/lifecycle-basic/cmp-a.tsx b/test/wdio/lifecycle-basic/cmp-a.tsx similarity index 100% rename from test/karma/test-app/lifecycle-basic/cmp-a.tsx rename to test/wdio/lifecycle-basic/cmp-a.tsx diff --git a/test/karma/test-app/lifecycle-basic/cmp-b.tsx b/test/wdio/lifecycle-basic/cmp-b.tsx similarity index 100% rename from test/karma/test-app/lifecycle-basic/cmp-b.tsx rename to test/wdio/lifecycle-basic/cmp-b.tsx diff --git a/test/karma/test-app/lifecycle-basic/cmp-c.tsx b/test/wdio/lifecycle-basic/cmp-c.tsx similarity index 100% rename from test/karma/test-app/lifecycle-basic/cmp-c.tsx rename to test/wdio/lifecycle-basic/cmp-c.tsx