Skip to content

Commit

Permalink
let see if tests work at all
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Nov 14, 2024
1 parent d485de3 commit 6440845
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 13 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/check-installation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -159,3 +159,8 @@ jobs:
fi
- run: echo "File check status is ${{ job.status }}."

# Tests
- name: Test packaged application
run: npm test


1 change: 1 addition & 0 deletions js/worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,7 @@ async function spawnListWorker() {

if (message === 'list-model-ready') {
return resolve(worker);

} else if (message === "tfjs-node") {
STATE.hasNode = true;
if (!event.data.available) {
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default defineConfig({
//channel: 'chrome',

// Run browser in headless mode.
headless: false,
headless: true,

// Change the default data-testid attribute.
//testIdAttribute: 'pw-test-id',
Expand Down
51 changes: 39 additions & 12 deletions test/menu.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ import {
import { ElectronApplication, Page } from 'playwright';
import jimp from 'jimp';

let electronApp: ElectronApplication = null;
let page: Page = null;
let worker: Page
let electronApp: ElectronApplication;
let page: Page;
let worker: Page;
let example_file: any

test.beforeAll(async () => {
Expand Down Expand Up @@ -49,7 +49,7 @@ test.beforeAll(async () => {
},
},
])
worker = electronApp.firstWindow()
worker = await electronApp.firstWindow()

electronApp.on('window', async (window) => {
const filename = window.url()?.split('/').pop()
Expand All @@ -63,14 +63,15 @@ test.beforeAll(async () => {
console.log(msg.text())
})
})
await new Promise((resolve) => { const checkPage = setInterval(() => { if (page) { clearInterval(checkPage); resolve(); } }, 100); });
await new Promise((resolve) => { const checkPage = setInterval(() => { if (page) { clearInterval(checkPage); resolve(); } }, 1000); });
})

test.afterAll(async () => {
//await page.pause()
await electronApp.close()
})

test.describe.configure({ mode: 'parallel' });

test('Page title is correct', async () => {
const title = await page.title()
Expand All @@ -80,23 +81,51 @@ test('Page title is correct', async () => {
expect(title).toBe('Chirpity Bird Call Detection')
})


test(`Analyse works`, async () => {
async function openExampleFile(){
await page.locator('#navBarFile').click()
await page.locator('#open-file').click()
page.locator('wave').first().waitFor({state: 'visible'})
await page.locator('wave').first().waitFor({state: 'visible'})
}

async function changeSettings(elementID, value, timeout){
await page.locator('#navbarSettings').click()
await page.selectOption('#' + elementID, value);
await page.locator('#close-settings').click();
// Wait ?
if (timeout) await page.waitForTimeout(timeout);
}

test(`Nocmig analyse works and second result is 61%`, async () => {
await openExampleFile();
await changeSettings('model-to-use', 'chirpity', 5000)
await page.locator('#navbarAnalysis').click();
await page.locator('#analyse').click()
await page.locator('#resultTableContainer').waitFor({state: 'visible'})
const callID = page.locator('#speciesFilter').getByText('Redwing (call)');
expect(callID).not.toBe(undefined)
const secondResult = await (await page.waitForSelector('#result2 span.confidence-row > span')).textContent()
// console.log(secondResult, 'second result');
expect(secondResult).toBe('61%');
})

test(`BirdNET analyse works and second result is 34%`, async () => {
await openExampleFile()
await changeSettings('model-to-use', 'birdnet', 5000)

await page.locator('#navbarAnalysis').click()
await page.locator('#analyse').click()
await page.locator('#resultTableContainer').waitFor({state: 'visible'})
const callID = page.locator('#speciesFilter').getByText('Redwing (call)');
expect(callID).not.toBe(undefined)
const secondResult = await (await page.waitForSelector('#result2 span.confidence-row > span')).textContent()
// console.log(secondResult, 'second result');
expect(secondResult).toBe('34%');
})

//test.describe.configure({ mode: 'parallel' });


test(`Audacity labels work`, async () => {

page = await electronApp.waitForEvent('window')
// Everything shows 8 rows @ 45%
await page.getByRole('button', { name: 'Settings' }).click();
await page.getByLabel('Show:').selectOption('everything');
Expand All @@ -117,8 +146,6 @@ test(`Audacity labels work`, async () => {
})

test("Amend file start dialog contains date", async () =>{

page = await electronApp.waitForEvent('window')
await page.getByRole('button', { name: 'example.mp3' }).click({
button: 'right'
});
Expand Down

0 comments on commit 6440845

Please sign in to comment.