index : btroops | |
Virtual board game-aid for BattleTroops, an infantry combat simulator wargame published by FASA in 1989. |
aboutsummaryrefslogtreecommitdiff |
diff options
author | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-28 17:13:56 -0700 |
---|---|---|
committer | Catalin Mititiuc <webdevcat@proton.me> | 2024-05-28 17:13:56 -0700 |
commit | 2df718998a89cb622bb9a76655abdeafc33d9aa5 (patch) | |
tree | 9e86622f87cb598de55c1ec4c21c6b722fc3ab30 /test/integration/page.test.js | |
parent | abc8b02a9c73e68f435d8971b2ef0e1970f42212 (diff) |
Add some select tests
Diffstat (limited to 'test/integration/page.test.js')
-rw-r--r-- | test/integration/page.test.js | 82 |
1 files changed, 5 insertions, 77 deletions
diff --git a/test/integration/page.test.js b/test/integration/page.test.js index 7046ef0..db0bf0d 100644 --- a/test/integration/page.test.js +++ b/test/integration/page.test.js @@ -1,100 +1,28 @@ -const { ProvideResponseParameters } = require('selenium-webdriver/bidi/provideResponseParameters'); - -const { Builder, By, until } = require('selenium-webdriver'), +const { Builder } = require('selenium-webdriver'), chrome = require('selenium-webdriver/chrome.js'), - getNetworkInstance = require('selenium-webdriver/bidi/network.js'), - { AddInterceptParameters } = require('selenium-webdriver/bidi/addInterceptParameters'), - { InterceptPhase } = require('selenium-webdriver/bidi/interceptPhase'), - { expect, it } = require('@jest/globals'), chromeOptions = new chrome.Options(), - { mkdir, writeFile, symlink, unlink } = require('node:fs/promises'), - path = require('path'), - { tmpdir } = require('os'), - puppeteer = require('puppeteer'); - -const { HttpResponse } = require('selenium-webdriver/devtools/networkinterceptor'); - -const fs = require('node:fs/promises'); -const DIR = path.resolve(tmpdir(), 'test-dir'); + { expect, it } = require('@jest/globals'), + { mkdir, writeFile } = require('node:fs/promises'), + path = require('path'); chromeOptions.addArguments('--headless', '--disable-gpu', '--no-sandbox'); chromeOptions.enableBidi(); let driver; -// beforeAll(async () => { -// await symlink('../../../test/map1.svg', 'public/assets/images/test_map.svg'); -// }); - beforeEach(async () => { driver = new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build(); - - // console.log('manage', await driver.manage()); - }); it('loads the page', async () => { - expect(await driver.getTitle()).toEqual('Infantry Combat Solo Basic'); - - // console.log('window', window); - - // takeScreenshot(driver); - - // var start = new Date().getTime(); - // await driver.executeAsyncScript( - // 'window.setTimeout(arguments[arguments.length - 1], 500);'). - // then(function() { - // console.log( - // 'Elapsed time: ' + (new Date().getTime() - start) + ' ms'); - // }); - - // await driver.executeScript(`return __dirname`).then(function (e) { - // console.log('e', e); - // }); - // console.log('client', await driver.executeScript(`return document.querySelect('object');`)); -}); - -it.only('selects an off-board soldier', async () => { - const connection = await driver.createCDPConnection('page') - const url = 'http://localhost:3005/assets/images/scenario-side_show.svg'; - const httpResponse = new HttpResponse(url); - httpResponse.body = await fs.readFile('./test/integration/fixtures/scenario-test.svg', 'utf8'); - httpResponse.addHeaders('Content-Type', 'image/svg+xml'); - - await driver.onIntercept(connection, httpResponse, async function () { - console.log('intercepted'); - }); - await driver.get('http://localhost:3005'); - await driver.wait(until.elementLocated(By.css('#dice')), 1000); - await driver.switchTo().frame(await driver.findElement(By.css('object'))); - - const selector = '.counter[data-allegiance="attacker"][data-number="1"]', - svg = await driver.findElement(By.css('svg')), - counter = await driver.findElement(By.css(selector), svg); - - await counter.click(); - - expect(await counter.getAttribute('class')).toEqual(expect.stringContaining('selected')); - await driver.switchTo().defaultContent(); - expect(await driver.findElement(By.css('.soldier-record')).getAttribute('class')).toEqual(expect.stringContaining('selected')); - - await driver.switchTo().frame(await driver.findElement(By.css('object'))); - await counter.click(); - - expect(await counter.getAttribute('class')).toEqual(expect.not.stringContaining('selected')); - await driver.switchTo().defaultContent(); - expect(await driver.findElement(By.css('.soldier-record')).getAttribute('class')).toEqual(expect.not.stringContaining('selected')); + expect(await driver.getTitle()).toEqual('Infantry Combat Solo Basic'); }); afterEach(async () => { await driver.quit(); }); -// afterAll(async () => { -// await unlink('public/assets/images/test_map.svg'); -// }); - async function takeScreenshot(driver) { const dir = './test/screenshots'; const fileName = path.relative(process.cwd(), __filename) + ' "' + expect.getState().currentTestName + `" ${new Date().toISOString()}.png`; |