mirror of
https://github.com/Sosokker/HomieCare.git
synced 2025-12-19 02:04:03 +01:00
Add end-to-end test using playwright
This commit is contained in:
parent
9738a61c1e
commit
84d17066ac
@ -93,7 +93,7 @@ const Statistic: React.FC = () => {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
{/* Recommendation Card */}
|
{/* Recommendation Card */}
|
||||||
<div className="mt-6">
|
<div className="mt-6" id="alert-container">
|
||||||
<Alert
|
<Alert
|
||||||
indoor_temp={indoorWeatherData?.avg_indoor_temp}
|
indoor_temp={indoorWeatherData?.avg_indoor_temp}
|
||||||
outdoor_temp={outdoorWeatherData?.avg_outdoor_temp}
|
outdoor_temp={outdoorWeatherData?.avg_outdoor_temp}
|
||||||
|
|||||||
19
frontend/tests/test-camera.spec.ts
Normal file
19
frontend/tests/test-camera.spec.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('test', async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:5173/');
|
||||||
|
await page.getByRole('link', { name: 'Camera' }).click();
|
||||||
|
await page.getByRole('combobox').selectOption('2');
|
||||||
|
await page.getByRole('button', { name: 'Start Connection' }).click();
|
||||||
|
await page.waitForSelector('text=Loading...');
|
||||||
|
const loadingText = await page.$('text=Loading...');
|
||||||
|
expect(loadingText).not.toBeNull();
|
||||||
|
|
||||||
|
// await page.waitForSelector('text=Loading...', { state: 'hidden' });
|
||||||
|
// const hiddenLoadingText = await page.$('text=Loading...');
|
||||||
|
// expect(hiddenLoadingText).toBeNull();
|
||||||
|
|
||||||
|
await page.waitForSelector('canvas');
|
||||||
|
const canvas = await page.$('canvas');
|
||||||
|
expect(canvas).not.toBeNull();
|
||||||
|
});
|
||||||
38
frontend/tests/test-prediction.spec.ts
Normal file
38
frontend/tests/test-prediction.spec.ts
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('test', async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:5173/');
|
||||||
|
|
||||||
|
// Check if elements with specific text exist on the page
|
||||||
|
const outdoorTempElement = await page
|
||||||
|
.locator('span')
|
||||||
|
.getByText(/^Outdoor Temperature$/)
|
||||||
|
.first();
|
||||||
|
const outdoorHumidityElement = await page
|
||||||
|
.locator('span')
|
||||||
|
.getByText(/^Outdoor Humidity$/)
|
||||||
|
.first();
|
||||||
|
const outdoorPM25Element = await page
|
||||||
|
.locator('span')
|
||||||
|
.getByText(/^Outdoor PM2.5$/)
|
||||||
|
.first();
|
||||||
|
const outdoorPM10Element = await page
|
||||||
|
.locator('span')
|
||||||
|
.getByText(/^Outdoor PM10$/)
|
||||||
|
.first();
|
||||||
|
const indoorTempElement = await page
|
||||||
|
.locator('span')
|
||||||
|
.getByText(/^Indoor Temperature$/)
|
||||||
|
.first();
|
||||||
|
const indoorLightElement = await page
|
||||||
|
.locator('span')
|
||||||
|
.getByText(/^Indoor Light$/)
|
||||||
|
.first();
|
||||||
|
|
||||||
|
expect(outdoorTempElement).not.toBeNull();
|
||||||
|
expect(outdoorHumidityElement).not.toBeNull();
|
||||||
|
expect(outdoorPM25Element).not.toBeNull();
|
||||||
|
expect(outdoorPM10Element).not.toBeNull();
|
||||||
|
expect(indoorTempElement).not.toBeNull();
|
||||||
|
expect(indoorLightElement).not.toBeNull();
|
||||||
|
});
|
||||||
8
frontend/tests/test-recommend.spec.ts
Normal file
8
frontend/tests/test-recommend.spec.ts
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('test', async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:5173/');
|
||||||
|
|
||||||
|
const alertContainer = await page.waitForSelector('#alert-container');
|
||||||
|
expect(alertContainer).not.toBeNull();
|
||||||
|
});
|
||||||
10
frontend/tests/test-snapshot.spec.ts
Normal file
10
frontend/tests/test-snapshot.spec.ts
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
import { test, expect } from '@playwright/test';
|
||||||
|
|
||||||
|
test('test', async ({ page }) => {
|
||||||
|
await page.goto('http://localhost:5173/');
|
||||||
|
await page.getByRole('link', { name: 'Snapshot' }).click();
|
||||||
|
await page.getByRole('button', { name: 'Today' }).click();
|
||||||
|
const image = await page.waitForSelector('img');
|
||||||
|
|
||||||
|
expect(image).not.toBeNull();
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user