Skip to content

Commit

Permalink
use github action for test
Browse files Browse the repository at this point in the history
  • Loading branch information
bbbbx committed Nov 6, 2024
1 parent 8da6d86 commit 27c00f3
Show file tree
Hide file tree
Showing 4 changed files with 77 additions and 28 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Node.js CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [18.x, 20.x, 22.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v4
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test

- uses: actions/[email protected]
with:
name: test-report
path: playwright-report
overwrite: true
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"doc": "docs"
},
"scripts": {
"test": "npx playwright install && npx playwright test && npx playwright show-report"
"test": "npx playwright install && npx playwright test",
"show-test-report": "npx playwright show-report"
},
"keywords": [],
"author": "",
Expand Down
29 changes: 17 additions & 12 deletions playwright.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,24 +49,24 @@ module.exports = defineConfig({
// },

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
{
name: 'Microsoft Edge',
use: { ...devices['Desktop Edge'], channel: 'msedge' },
},
{
name: 'Google Chrome',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
},
],

/* Run your local dev server before starting the tests */
Expand All @@ -75,5 +75,10 @@ module.exports = defineConfig({
// url: 'http://127.0.0.1:3000',
// reuseExistingServer: !process.env.CI,
// },

expect: {
timeout: 3e4,
},

});

36 changes: 21 additions & 15 deletions tests/app.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,16 @@ test('can inspect pnts by choosing file', async ({ page }) => {
await expect(page.locator("[id='jsonViewer']")).toContainText(/"magic"\s*:\s*"pnts"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"batchTableJson"\s*:\s*{/);
await expect(page.locator("[id='hexViewer']")).toContainText(/pnts/);

});

test('can inspect big pnts file by choosing file', async ({ page }) => {
const fileChooserPromise = page.waitForEvent('filechooser');
await page.getByText('choose a file').click();
const fileChooser = await fileChooserPromise;

await fileChooser.setFiles(path.join(__dirname, 'Cesium3DTiles/PointCloud/44.pnts'));
await expect(page.locator("[id='jsonViewer']")).toContainText(/"magic"\s*:\s*"pnts"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"Classification"\s*:\s*{/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"magic"\s*:\s*"pnts"/, { timeout: 3e4 });
await expect(page.locator("[id='jsonViewer']")).toContainText(/"Classification"\s*:\s*{/, { timeout: 3e4 });
await expect(page.locator("[id='hexViewer']")).toContainText(/pnts/);
});

Expand All @@ -103,8 +109,8 @@ test('can inspect pnts with Draco by choosing file', async ({ page }) => {
await page.getByText('choose a file').click();
const fileChooser = await fileChooserPromise;
await fileChooser.setFiles(path.join(__dirname, 'Cesium3DTiles/PointCloud/PointCloudDraco/pointCloudDraco.pnts'));
await expect(page.locator("[id='jsonViewer']")).toContainText(/"magic"\s*:\s*"pnts"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"3DTILES_draco_point_compression"\s*:\s*{/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"magic"\s*:\s*"pnts"/, { timeout: 3e4 });
await expect(page.locator("[id='jsonViewer']")).toContainText(/"3DTILES_draco_point_compression"\s*:\s*{/, { timeout: 3e4 });
});

test('can inspect cmpt by choosing file', async ({ page }) => {
Expand Down Expand Up @@ -146,18 +152,18 @@ test('can inspect triangular mesh draco by choosing file', async ({ page }) => {
const fileChooser = await fileChooserPromise;

await fileChooser.setFiles(path.join(__dirname, 'draco/bunny.drc'));
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"TRIANGULAR_MESH"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"TRIANGULAR_MESH"/, { timeout: 3e4 });
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/, { timeout: 3e4 });
await expect(page.locator("[id='hexViewer']")).toContainText(/DRACO/);

await fileChooser.setFiles(path.join(__dirname, 'draco/bone.drc'));
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"TRIANGULAR_MESH"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"TRIANGULAR_MESH"/, { timeout: 3e4 });
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/, { timeout: 3e4 });
await expect(page.locator("[id='hexViewer']")).toContainText(/DRACO/);

await fileChooser.setFiles(path.join(__dirname, 'draco/throw_14.drc'));
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"TRIANGULAR_MESH"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"TRIANGULAR_MESH"/, { timeout: 3e4 });
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/, { timeout: 3e4 });
await expect(page.locator("[id='hexViewer']")).toContainText(/DRACO/);
});

Expand All @@ -167,12 +173,12 @@ test('can inspect point cloud draco by choosing file', async ({ page }) => {
const fileChooser = await fileChooserPromise;

await fileChooser.setFiles(path.join(__dirname, 'draco/pc_color.drc'));
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"POINT_CLOUD"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"POINT_CLOUD"/, { timeout: 3e4 });
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/, { timeout: 3e4 });
await expect(page.locator("[id='hexViewer']")).toContainText(/DRACO/);

await fileChooser.setFiles(path.join(__dirname, 'draco/point_cloud_no_qp.drc'));
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"POINT_CLOUD"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/);
await expect(page.locator("[id='jsonViewer']")).toContainText(/"geometryType"\s*:\s*"POINT_CLOUD"/, { timeout: 3e4 });
await expect(page.locator("[id='jsonViewer']")).toContainText(/"POSITION"/, { timeout: 3e4 });
await expect(page.locator("[id='hexViewer']")).toContainText(/DRACO/);
});

0 comments on commit 27c00f3

Please sign in to comment.