Added more tests
This commit is contained in:
parent
51366f27e8
commit
655c2764e8
4
.github/workflows/workflow.yml
vendored
4
.github/workflows/workflow.yml
vendored
@ -74,6 +74,10 @@ jobs:
|
|||||||
- name: Get current block
|
- name: Get current block
|
||||||
id: getBlockHeight
|
id: getBlockHeight
|
||||||
run: echo "blockHeight=$(curl -s https://mempool.space/api/blocks/tip/height)" >> $GITHUB_OUTPUT
|
run: echo "blockHeight=$(curl -s https://mempool.space/api/blocks/tip/height)" >> $GITHUB_OUTPUT
|
||||||
|
- name: Write block height to file
|
||||||
|
env:
|
||||||
|
BLOCK_HEIGHT: ${{ steps.getBlockHeight.outputs.blockHeight }}
|
||||||
|
run: echo "$BLOCK_HEIGHT" > output/version.txt
|
||||||
- name: gzip build for LittleFS
|
- name: gzip build for LittleFS
|
||||||
run: find dist -type f ! -name ".*" -exec sh -c 'mkdir -p "build_gz/$(dirname "${1#dist/}")" && gzip -k "$1" -c > "build_gz/${1#dist/}".gz' _ {} \;
|
run: find dist -type f ! -name ".*" -exec sh -c 'mkdir -p "build_gz/$(dirname "${1#dist/}")" && gzip -k "$1" -c > "build_gz/${1#dist/}".gz' _ {} \;
|
||||||
- name: Check GZipped directory size
|
- name: Check GZipped directory size
|
||||||
|
@ -19,12 +19,7 @@ const statusJson = {
|
|||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
test.beforeEach(async ({ page }) => {
|
const settingsJson = {
|
||||||
await page.route('*/**/api/status', async (route) => {
|
|
||||||
await route.fulfill({ json: statusJson });
|
|
||||||
});
|
|
||||||
await page.route('*/**/api/settings', async (route) => {
|
|
||||||
const json = {
|
|
||||||
numScreens: 7,
|
numScreens: 7,
|
||||||
fgColor: 415029,
|
fgColor: 415029,
|
||||||
bgColor: 0,
|
bgColor: 0,
|
||||||
@ -58,18 +53,52 @@ test.beforeEach(async ({ page }) => {
|
|||||||
{ id: 4, name: 'Halving countdown', enabled: true },
|
{ id: 4, name: 'Halving countdown', enabled: true },
|
||||||
{ id: 5, name: 'Market Cap', enabled: true }
|
{ id: 5, name: 'Market Cap', enabled: true }
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
await route.fulfill({ json });
|
|
||||||
|
test.beforeEach(async ({ page }) => {
|
||||||
|
await page.route('*/**/api/status', async (route) => {
|
||||||
|
await route.fulfill({ json: statusJson });
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route('*/**/api/show/screen/1', async (route) => {
|
||||||
|
//if (route.request().url().includes('*/**/api/show/screen/1')) {
|
||||||
|
statusJson.currentScreen = 1;
|
||||||
|
statusJson.data = ['MSCW/TIME', ' ', ' ', '2', '6', '4', '4'];
|
||||||
|
statusJson.rendered = statusJson.data;
|
||||||
|
//}
|
||||||
|
|
||||||
|
await route.fulfill({ json: statusJson });
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route('*/**/api/show/screen/2', async (route) => {
|
||||||
|
statusJson.currentScreen = 2;
|
||||||
|
(statusJson.data = ['BTC/USD', '$', '3', '7', '8', '2', '4']),
|
||||||
|
(statusJson.rendered = statusJson.data);
|
||||||
|
|
||||||
|
await route.fulfill({ json: statusJson });
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route('*/**/api/show/screen/4', async (route) => {
|
||||||
|
statusJson.currentScreen = 4;
|
||||||
|
(statusJson.data = ['BIT/COIN', 'HALV/ING', '0/YRS', '149/DAYS', '8/HRS', '30/MINS', 'TO/GO']),
|
||||||
|
(statusJson.rendered = statusJson.data);
|
||||||
|
|
||||||
|
await route.fulfill({ json: statusJson });
|
||||||
|
});
|
||||||
|
|
||||||
|
await page.route('*/**/api/settings', async (route) => {
|
||||||
|
await route.fulfill({ json: settingsJson });
|
||||||
});
|
});
|
||||||
|
|
||||||
await page.route('**/events', (route) => {
|
await page.route('**/events', (route) => {
|
||||||
//statusJson.data = ['S', 'S', 'E', 'V', 'E', 'N', 'T'];
|
const newStatus = statusJson;
|
||||||
|
newStatus.data = ['BLOCK/HEIGHT', '8', '0', '0', '8', '1', '5'];
|
||||||
|
|
||||||
// Respond with a custom SSE message
|
// Respond with a custom SSE message
|
||||||
route.fulfill({
|
route.fulfill({
|
||||||
status: 200,
|
status: 200,
|
||||||
contentType: 'text/event-stream',
|
contentType: 'text/event-stream',
|
||||||
body: `data: ${JSON.stringify(statusJson)}\n\n`
|
json: `${JSON.stringify(newStatus)}\n\n`
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
@ -158,9 +187,31 @@ test('info message when fetch eur price is enabled', async ({ page }) => {
|
|||||||
await expect(page.getByText('the WS Price connection will show')).toBeVisible();
|
await expect(page.getByText('the WS Price connection will show')).toBeVisible();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('screens should be able to change', async ({ page }) => {
|
||||||
|
await page.goto('/');
|
||||||
|
await expect(page.getByRole('button', { name: 'Sats per Dollar' })).toBeVisible();
|
||||||
|
const responsePromise = page.waitForRequest('*/**/api/show/screen/*');
|
||||||
|
|
||||||
|
await page.getByRole('button', { name: 'Sats per Dollar' }).click();
|
||||||
|
const response = await responsePromise;
|
||||||
|
expect(response.url()).toContain('api/show/screen/1');
|
||||||
|
});
|
||||||
|
|
||||||
test('parse all types of EPD content correctly', async ({ page }) => {
|
test('parse all types of EPD content correctly', async ({ page }) => {
|
||||||
statusJson.data[2] = '123';
|
statusJson.data[2] = '123';
|
||||||
|
|
||||||
|
await page.route('**/events', (route) => {
|
||||||
|
const newStatus = statusJson;
|
||||||
|
newStatus.data = ['BLOCK/HEIGHT', '8', '123', '0', '8', '1', '5'];
|
||||||
|
|
||||||
|
// Respond with a custom SSE message
|
||||||
|
route.fulfill({
|
||||||
|
status: 200,
|
||||||
|
contentType: 'text/event-stream',
|
||||||
|
json: `${JSON.stringify(newStatus)}\n\n`
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
await page.goto('/');
|
await page.goto('/');
|
||||||
|
|
||||||
await expect(page.getByRole('heading', { name: 'Status' })).toBeVisible();
|
await expect(page.getByRole('heading', { name: 'Status' })).toBeVisible();
|
||||||
@ -175,3 +226,21 @@ test('parse all types of EPD content correctly', async ({ page }) => {
|
|||||||
expect(statusJson.data[2]).toHaveLength(3);
|
expect(statusJson.data[2]).toHaveLength(3);
|
||||||
await expect(page.locator('#btclock-wrapper > div > div:nth-child(3)')).toHaveClass('mediumText');
|
await expect(page.locator('#btclock-wrapper > div > div:nth-child(3)')).toHaveClass('mediumText');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('should work with more than 7 screens', async ({ page }) => {
|
||||||
|
statusJson.data[2] = '1';
|
||||||
|
statusJson.numScreens = 9;
|
||||||
|
settingsJson.numScreens = 9;
|
||||||
|
statusJson.data.splice(1, 0, ' ', ' ');
|
||||||
|
|
||||||
|
await page.goto('/');
|
||||||
|
|
||||||
|
await expect(page.getByRole('heading', { name: 'Status' })).toBeVisible();
|
||||||
|
await page.waitForSelector('#timerStatusText:has-text("running")');
|
||||||
|
await expect(page.locator('#btclock-wrapper > div > div:nth-child(9)')).toBeTruthy();
|
||||||
|
|
||||||
|
await expect(page.locator('#customText')).toHaveAttribute(
|
||||||
|
'maxlength',
|
||||||
|
statusJson.numScreens.toString()
|
||||||
|
);
|
||||||
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user