Skip to content

Playwright test - Initial commit #217

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 27 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
a2b17f1
wip: vin scanner sample
felixindrawan Jul 2, 2024
277f963
fix parameters
felixindrawan Jul 4, 2024
0441116
feat: minimum element for vin scan
felixindrawan Jul 4, 2024
18a09e1
feat: add scan modes button
felixindrawan Jul 8, 2024
929ecd9
fix: change license
felixindrawan Jul 9, 2024
e1d20b3
feat: add default option and page title
felixindrawan Jul 9, 2024
dd5ecd0
feat: updated vin sample code and design
felixindrawan Jul 9, 2024
2fe7565
feat: Added copy code, and settings for the official VIN scanning sample
felixindrawan Jul 9, 2024
695e1c4
feat: added image on scan
felixindrawan Jul 9, 2024
c99e054
feat: Add image result to minimum-elements
felixindrawan Jul 10, 2024
ad8b643
fix: Add image download and notification for camera switch
felixindrawan Jul 10, 2024
cc0d928
fix: css for minimum elements and index.html
felixindrawan Jul 10, 2024
232bd6e
First check-in on playwright script. The 'helloworld.spec.ts' script …
eugene-dynamsoft Jul 16, 2024
21490db
Added Intermediate Result image download for read-an-image sample to …
eugene-dynamsoft Aug 15, 2024
ba9fd47
Merge branch 'main' of https://github.com/Dynamsoft/barcode-reader-ja…
Aug 16, 2024
60b357a
Adding generic playwright test to the root html page.
eugene-dynamsoft Oct 10, 2024
e624af1
added base index page validation for the text and URL (href) links
eugene-dynamsoft Oct 10, 2024
63c45bf
Added package.json file to the root
eugene-dynamsoft Oct 10, 2024
ebeea1b
added package-lock.json
eugene-dynamsoft Oct 10, 2024
d5833b9
Merge branch 'main' of https://github.com/Dynamsoft/barcode-reader-ja…
eugene-dynamsoft Oct 15, 2024
6696990
Added blazor project to the index list.
eugene-dynamsoft Oct 15, 2024
3e35141
Adding unittest for hello-world and read-an-image pages.
eugene-dynamsoft Oct 15, 2024
4da59cb
Added read-a-drivers-license-test to the project
eugene-dynamsoft Oct 15, 2024
efa582a
Added unittests for ES6, PWA, and requireJS pages
eugene-dynamsoft Oct 15, 2024
bc29668
Added tests for show result text on the video overlay.
eugene-dynamsoft Oct 16, 2024
931fa5b
Added test for find item via barcode test
eugene-dynamsoft Oct 16, 2024
2021192
Removed firefox config and added force headless mode
eugene-dynamsoft Oct 16, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/playwright.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Playwright Tests
on:
push:
branches:
- main
pull_request:
branches:
- main
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:

jobs:
test:
env:
HOME: /root
name: 'Playwright Tests'
runs-on: ubuntu-latest
container:
image: mcr.microsoft.com/playwright:v1.46.1-jammy
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: lts/*
- name: Install dependencies (clean install)
run: npm ci
- name: Install Playwright Browsers
run: npx playwright install --with-deps
- name: Run Playwright tests
run: npm test
- name: Upload test results
uses: actions/upload-artifact@v4
if: always()
with:
name: playwright-report
path: playwright-report
retention-days: 30
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,8 @@ yarn.lock

!bower.json
!composer.json
!package.js
!package.js
/test-results/
/playwright-report/
/blob-report/
/playwright/.cache/
147 changes: 147 additions & 0 deletions hello-world/read-an-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,152 @@ <h1>Hello World (Read an Image)</h1>
try {
cvRouter = cvRouter || (await (pCvRouter = pCvRouter || Dynamsoft.CVR.CaptureVisionRouter.createInstance()));

console.info("========== Initiating IRReceiver ");
IRReceiver = new Dynamsoft.CVR.IntermediateResultReceiver();

/** ISSUE:
* only triggered on the first task of many in a CaptureVisionTemplate??
* fixed in CVR 2.0.32
*/
IRReceiver.onTaskResultsReceived = (result, info) => {
console.log(`Task name: ${info.taskName}`);
console.log(
`Task result units count: ${result.intermediateResultUnits.length}`
);
};


// Modify each receiver to save the result
IRReceiver.onPredetectedRegionsReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'PredetectedRegions');
};

IRReceiver.onColourImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'ColourImage');
};

IRReceiver.onScaledDownColourImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
// showImageOnCanvas(result, 'ScaledDownColourImage');
saveIntermediateResult(result, 'ScaledDownColourImage');
};


IRReceiver.onGrayscaleImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
// showImageOnCanvas(result, 'GrayscaleImage');
saveIntermediateResult(result, 'GrayscaleImage');
};

IRReceiver.onTransformedGrayscaleImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'TransformedGrayscaleImage');
};

IRReceiver.onEnhancedGrayscaleImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'EnhancedGrayscaleImage');
};

IRReceiver.onBinaryImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'BinaryImage');
};

IRReceiver.onTextureDetectionResultUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'TextureDetectionResult');
};

IRReceiver.onTextureRemovedGrayscaleImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'TextureRemovedGrayscaleImage');
};

IRReceiver.onTextureRemovedBinaryImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'TextureRemovedBinaryImage');
};

IRReceiver.onContoursUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'Contours');
};

IRReceiver.onLineSegmentsUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'LineSegments');
};

IRReceiver.onTextZonesUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'TextZones');
};

IRReceiver.onTextRemovedBinaryImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'TextRemovedBinaryImage');
};

IRReceiver.onLongLinesUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'LongLines');
};

IRReceiver.onCornersUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'Corners');
};

IRReceiver.onCandidateQuadEdgesUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'CandidateQuadEdges');
};

IRReceiver.onCandidateBarcodeZonesUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'CandidateBarcodeZones');
};

IRReceiver.onScaledUpBarcodeImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'ScaledUpBarcodeImage');
};

IRReceiver.onDeformationResistedBarcodeImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'DeformationResistedBarcodeImage');
};

IRReceiver.onComplementedBarcodeImageUnitReceived = (result, info) => {
console.log(`type: ${Dynamsoft.Core.EnumIntermediateResultUnitType[result.unitType]}`);
saveIntermediateResult(result, 'ComplementedBarcodeImage');
};

IRManager = cvRouter.getIntermediateResultManager();
IRManager.addResultReceiver(IRReceiver);
console.log("========== IRReceiver ready");

// Function to save intermediate results to local storage
const imgManager = new Dynamsoft.Utility.ImageManager();
const saveIntermediateResult = (result, type) => {
try {
if (result.imageData === undefined || type === "BinaryImage" || type === "TextureRemovedBinaryImage") {
console.log(`ImageData for ${type} is either undefined or not of type "ImageDataSettings"`);
return;
}
console.log(`ImageData for ${type}:`, result.imageData);
imgManager.saveToFile(result.imageData, `intermediate_result_${type}_${Date.now()}.png`, true);

} catch (ex) {
console.error(`Error saving intermediate result for ${type}:`, ex);
}

};


for (let file of files) {
// Decode selected image with 'ReadBarcodes_SpeedFirst' template.
const result = await cvRouter.capture(file, "ReadBarcodes_SpeedFirst");
Expand All @@ -59,6 +205,7 @@ <h1>Hello World (Read an Image)</h1>
console.log(item.text);
}
if (!result.items.length) resultsContainer.innerText += "No barcode found\n";
console.log(`Total number of barcodes found: ${result.items.length}`);
}
} catch (ex) {
let errMsg = ex.message || ex;
Expand Down
Loading
Loading