Skip to content

Commit 5734cca

Browse files
committed
e2e: add sandbox auto-complete inital tests
1 parent fbb6f61 commit 5734cca

File tree

1 file changed

+132
-0
lines changed

1 file changed

+132
-0
lines changed
Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
import { test, expect } from '@playwright/test';
2+
3+
test.describe('Sandbox Auto-complete Example', () => {
4+
test.beforeEach(async ({ page }) => {
5+
await page.goto('/examples/reactivity/auto-complete/');
6+
});
7+
8+
test('Sandbox Auto-complete page loads', async ({ page }) => {
9+
await expect(page).toHaveTitle('Auto-complete 📚 Qwik Documentation');
10+
const tabButtonsTop = page.getByText('app.tsxentry.server.tsxroot.');
11+
12+
await expect(tabButtonsTop.getByRole('button')).toHaveCount(3);
13+
await expect(page.getByRole('button', { name: 'app.tsx' })).toBeVisible();
14+
await expect(page.getByRole('button', { name: 'entry.server.tsx' })).toBeVisible();
15+
await expect(page.getByRole('button', { name: 'root.tsx' })).toBeVisible();
16+
17+
const tabButtonsBottom = page.getByText('AppHTMLSymbolsClient');
18+
await expect(tabButtonsBottom.getByRole('button')).toHaveCount(6);
19+
20+
await expect(tabButtonsBottom.getByRole('button', { name: 'App' })).toBeVisible();
21+
await expect(tabButtonsBottom.getByRole('button', { name: 'HTML' })).toBeVisible();
22+
await expect(tabButtonsBottom.getByRole('button', { name: 'Symbols' })).toBeVisible();
23+
await expect(tabButtonsBottom.getByRole('button', { name: 'Client Bundles' })).toBeVisible();
24+
await expect(tabButtonsBottom.getByRole('button', { name: 'SSR Module' })).toBeVisible();
25+
await expect(tabButtonsBottom.getByRole('button', { name: 'Diagnostics' })).toBeVisible();
26+
27+
const consoleTabBottom = page.getByText('ConsoleOptions');
28+
await expect(consoleTabBottom.getByRole('button')).toHaveCount(2);
29+
await expect(consoleTabBottom.getByRole('button', { name: 'Console' })).toBeVisible();
30+
await expect(consoleTabBottom.getByRole('button', { name: 'Options' })).toBeVisible();
31+
});
32+
33+
test('Auto-complete app.tsx loads', async ({ page }) => {
34+
const replInputAppTsx = page
35+
.getByRole('code')
36+
.locator('div')
37+
.filter({ hasText: 'export default component$' })
38+
.nth(4);
39+
await expect(replInputAppTsx).toBeVisible();
40+
const serverEntryButton = page.getByRole('button', { name: 'entry.server.tsx' });
41+
serverEntryButton.click();
42+
await expect(replInputAppTsx).not.toBeVisible();
43+
const appTsxButton = page.getByRole('button', { name: 'app.tsx' });
44+
appTsxButton.click();
45+
await expect(replInputAppTsx).toBeVisible();
46+
});
47+
48+
test('Auto-complete entry.server.tsx loads', async ({ page }) => {
49+
const root = page
50+
.getByRole('code')
51+
.locator('div')
52+
.filter({ hasText: "import { Root } from './root';" })
53+
.nth(4);
54+
55+
await expect(root).not.toBeVisible();
56+
const button = page.getByRole('button', { name: 'entry.server.tsx' });
57+
button.click();
58+
await expect(root).toBeVisible();
59+
});
60+
61+
test('Auto-complete root.tsx loads', async ({ page }) => {
62+
const importStatement = page
63+
.getByRole('code')
64+
.locator('div')
65+
.filter({ hasText: "import App from './app';" })
66+
.nth(4);
67+
await expect(importStatement).not.toBeVisible();
68+
const button = page.getByRole('button', { name: 'root.tsx' });
69+
await button.click();
70+
await expect(importStatement).toBeVisible();
71+
});
72+
73+
test('Auto-complete HTML Button', async ({ page }) => {
74+
const spinner = page.locator('.repl-spinner');
75+
await expect(spinner).toBeVisible();
76+
await expect(spinner).not.toBeVisible();
77+
const button = page.getByRole('button', { name: 'HTML' });
78+
await button.click();
79+
const htmlCode = page.locator('code.language-html');
80+
await expect(htmlCode).toBeVisible();
81+
await expect(htmlCode).toContainText('<!DOCTYPE html>');
82+
});
83+
84+
test('Auto-complete Symbols Button', async ({ page }) => {
85+
const button = page.getByRole('button', { name: 'Symbols' });
86+
await expect(button).toBeVisible();
87+
await button.click();
88+
89+
const symbolsText = page.getByText('import { _jsxQ } from').first();
90+
await expect(symbolsText).toBeVisible();
91+
});
92+
93+
test('Auto-complete Client Bundles Button', async ({ page }) => {
94+
const button = page.getByRole('button', { name: 'Client Bundles' });
95+
await expect(button).toBeVisible();
96+
await button.click();
97+
const bundles = page.locator('#file-modules-client-modules').getByText('build/app.js');
98+
await expect(bundles).toBeVisible();
99+
});
100+
101+
test('Auto-complete SSR Module Button', async ({ page }) => {
102+
const button = page.getByRole('button', { name: 'SSR Module' });
103+
await expect(button).toBeVisible();
104+
await button.click();
105+
const module = page.locator('#file-modules-client-modules').getByText('entry.server.js');
106+
await expect(module).toBeVisible();
107+
});
108+
109+
test('Auto-complete Diagnostics Button', async ({ page }) => {
110+
const button = page.getByRole('button', { name: 'Diagnostics' });
111+
await expect(button).toBeVisible();
112+
await button.click();
113+
const diagnostics = page.locator('.output-result.output-diagnostics');
114+
await expect(diagnostics).toBeVisible();
115+
await expect(diagnostics).toHaveText('- No Reported Diagnostics -');
116+
});
117+
118+
test('Auto-complete Options Button', async ({ page }) => {
119+
const button = page.getByRole('button', { name: 'Options' });
120+
const serverConsoleText = page.getByText('🔴 Paused in server');
121+
await expect(serverConsoleText).toBeVisible();
122+
await expect(button).toBeVisible();
123+
await button.click();
124+
await expect(serverConsoleText).not.toBeVisible();
125+
const DebugCheckBox = page.locator('label').filter({ hasText: 'Debug' });
126+
await expect(DebugCheckBox).toBeVisible();
127+
await expect(DebugCheckBox).not.toBeChecked();
128+
const consoleButton = page.getByRole('button', { name: 'Console' });
129+
consoleButton.click();
130+
await expect(serverConsoleText).toBeVisible();
131+
});
132+
});

0 commit comments

Comments
 (0)