Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(wdio): porting the scoped-basic test suite to wdio #5512

Merged
merged 1 commit into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions test/karma/test-app/components.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,6 @@ export namespace Components {
}
interface ReparentStyleWithVars {
}
interface ScopedBasic {
}
interface ScopedBasicRoot {
}
interface ScopedConditional {
"renderHello": boolean;
}
Expand Down Expand Up @@ -474,18 +470,6 @@ declare global {
prototype: HTMLReparentStyleWithVarsElement;
new (): HTMLReparentStyleWithVarsElement;
};
interface HTMLScopedBasicElement extends Components.ScopedBasic, HTMLStencilElement {
}
var HTMLScopedBasicElement: {
prototype: HTMLScopedBasicElement;
new (): HTMLScopedBasicElement;
};
interface HTMLScopedBasicRootElement extends Components.ScopedBasicRoot, HTMLStencilElement {
}
var HTMLScopedBasicRootElement: {
prototype: HTMLScopedBasicRootElement;
new (): HTMLScopedBasicRootElement;
};
interface HTMLScopedConditionalElement extends Components.ScopedConditional, HTMLStencilElement {
}
var HTMLScopedConditionalElement: {
Expand Down Expand Up @@ -927,8 +911,6 @@ declare global {
"remove-child-patch": HTMLRemoveChildPatchElement;
"reparent-style-no-vars": HTMLReparentStyleNoVarsElement;
"reparent-style-with-vars": HTMLReparentStyleWithVarsElement;
"scoped-basic": HTMLScopedBasicElement;
"scoped-basic-root": HTMLScopedBasicRootElement;
"scoped-conditional": HTMLScopedConditionalElement;
"scoped-slot-append-and-prepend": HTMLScopedSlotAppendAndPrependElement;
"scoped-slot-child-insert-adjacent": HTMLScopedSlotChildInsertAdjacentElement;
Expand Down Expand Up @@ -1081,10 +1063,6 @@ declare namespace LocalJSX {
}
interface ReparentStyleWithVars {
}
interface ScopedBasic {
}
interface ScopedBasicRoot {
}
interface ScopedConditional {
"renderHello"?: boolean;
}
Expand Down Expand Up @@ -1277,8 +1255,6 @@ declare namespace LocalJSX {
"remove-child-patch": RemoveChildPatch;
"reparent-style-no-vars": ReparentStyleNoVars;
"reparent-style-with-vars": ReparentStyleWithVars;
"scoped-basic": ScopedBasic;
"scoped-basic-root": ScopedBasicRoot;
"scoped-conditional": ScopedConditional;
"scoped-slot-append-and-prepend": ScopedSlotAppendAndPrepend;
"scoped-slot-child-insert-adjacent": ScopedSlotChildInsertAdjacent;
Expand Down Expand Up @@ -1385,8 +1361,6 @@ declare module "@stencil/core" {
"remove-child-patch": LocalJSX.RemoveChildPatch & JSXBase.HTMLAttributes<HTMLRemoveChildPatchElement>;
"reparent-style-no-vars": LocalJSX.ReparentStyleNoVars & JSXBase.HTMLAttributes<HTMLReparentStyleNoVarsElement>;
"reparent-style-with-vars": LocalJSX.ReparentStyleWithVars & JSXBase.HTMLAttributes<HTMLReparentStyleWithVarsElement>;
"scoped-basic": LocalJSX.ScopedBasic & JSXBase.HTMLAttributes<HTMLScopedBasicElement>;
"scoped-basic-root": LocalJSX.ScopedBasicRoot & JSXBase.HTMLAttributes<HTMLScopedBasicRootElement>;
"scoped-conditional": LocalJSX.ScopedConditional & JSXBase.HTMLAttributes<HTMLScopedConditionalElement>;
"scoped-slot-append-and-prepend": LocalJSX.ScopedSlotAppendAndPrepend & JSXBase.HTMLAttributes<HTMLScopedSlotAppendAndPrependElement>;
"scoped-slot-child-insert-adjacent": LocalJSX.ScopedSlotChildInsertAdjacent & JSXBase.HTMLAttributes<HTMLScopedSlotChildInsertAdjacentElement>;
Expand Down
6 changes: 0 additions & 6 deletions test/karma/test-app/scoped-basic/index.html

This file was deleted.

39 changes: 0 additions & 39 deletions test/karma/test-app/scoped-basic/karma.spec.ts

This file was deleted.

9 changes: 9 additions & 0 deletions test/wdio/global.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { setMode } from '@stencil/core';

const globalScript = () => {
setMode((elm) => {
return (elm as any).colormode || elm.getAttribute('colormode');
});
};

export default globalScript;
50 changes: 50 additions & 0 deletions test/wdio/scoped-basic/cmp.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { h } from '@stencil/core';
import { render } from '@wdio/browser-runner/stencil';

describe('scoped-basic', function () {
beforeEach(() => {
render({
template: () => <scoped-basic-root colormode="md"></scoped-basic-root>,
});
});

it('render', async () => {
const doc = await $('scoped-basic-root');
await doc.waitForStable();

await expect(doc).toHaveElementClass(expect.stringContaining('sc-scoped-basic-root-md-h'));
await expect(doc).toHaveElementClass(expect.stringContaining('sc-scoped-basic-root-md-s'));
await expect(doc).toHaveElementClass(expect.stringContaining('hydrated'));

const scopedEl = await $('scoped-basic');
await scopedEl.waitForStable();

await expect(scopedEl).toHaveElementClass(expect.stringContaining('sc-scoped-basic-root-md'));
await expect(scopedEl).toHaveElementClass(expect.stringContaining('sc-scoped-basic-h'));
await expect(scopedEl).toHaveElementClass(expect.stringContaining('sc-scoped-basic-s'));
await expect(scopedEl).toHaveElementClass(expect.stringContaining('hydrated'));

await expect(scopedEl).toHaveStyle({
backgroundColor: browser.isChromium ? 'rgba(0,0,0,1)' : 'rgb(0,0,0)',
color: browser.isChromium ? 'rgba(128,128,128,1)' : 'rgb(128,128,128)',
});

const scopedDiv = await $('scoped-basic div');
await expect(scopedDiv).toHaveElementClass(expect.stringContaining('sc-scoped-basic'));
expect(scopedDiv).toHaveStyle({
color: browser.isChromium ? 'rgba(255,0,0,1)' : 'rgb(255, 0, 0)',
});

const scopedP = await $('scoped-basic p');
await expect(scopedP).toHaveElementClass(expect.stringContaining('sc-scoped-basic'));
await expect(scopedP).toHaveElementClass(expect.stringContaining('sc-scoped-basic-s'));

const scopedSlot = await scopedP.$('span');
await expect(scopedSlot).toHaveElementClass(expect.stringContaining('sc-scoped-basic-root-md'));
await expect(scopedSlot).toHaveText('light');

await expect(scopedSlot).toHaveStyle({
color: browser.isChromium ? 'rgba(255,255,0,1)' : 'rgb(255, 255, 0)',
});
});
});
1 change: 1 addition & 0 deletions test/wdio/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const config: Config = {
plugins: [sass()],
buildDist: true,
globalStyle: './style-plugin/global-sass-entry.scss',
globalScript: './global.ts',
extras: {
lifecycleDOMEvents: true,
scriptDataOpts: true,
Expand Down
Loading