Skip to content

Commit

Permalink
test: add slot test for changing projected text (QwikDev#3681)
Browse files Browse the repository at this point in the history
  • Loading branch information
manucorporat authored Apr 6, 2023
1 parent e52d997 commit afcb125
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 0 deletions.
26 changes: 26 additions & 0 deletions starters/apps/e2e/src/components/slot/slot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export const SlotParent = component$(() => {
<Issue2751 />

<Issue3565 model={Issue3565Model} />

<Issue3607 />
</>
)}
<div>
Expand Down Expand Up @@ -262,3 +264,27 @@ export const Issue3565 = component$(({ model: Model }: any) => {
</>
);
});

export const Issue3607 = component$(() => {
const show = useSignal(false);
return (
<Issue3607Button
loading={show.value}
onClick$={() => {
show.value = !show.value;
}}
>
{show.value ? 'Loading...' : 'Load more'}
</Issue3607Button>
);
});

export const Issue3607Button = component$(({ onClick$ }: any) => {
return (
<>
<button id="issue-3607-result" onClick$={onClick$} class="btn">
<Slot />
</button>
</>
);
});
11 changes: 11 additions & 0 deletions starters/e2e/e2e.slot.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,17 @@ test.describe('slot', () => {
const result = page.locator('#issue-3565-result');
await expect(result).toHaveText('Own contentcontent projected');
});

test('issue 3607', async ({ page }) => {
const button = page.locator('#issue-3607-result');
await expect(button).toHaveText('Load more');
await button.click();
await expect(button).toHaveText('Loading...');
await button.click();
await expect(button).toHaveText('Load more');
await button.click();
await expect(button).toHaveText('Loading...');
});
}

test.beforeEach(async ({ page }) => {
Expand Down

0 comments on commit afcb125

Please sign in to comment.