Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCatalin Mititiuc <webdevcat@proton.me>2024-05-04 10:25:22 -0700
committerCatalin Mititiuc <webdevcat@proton.me>2024-05-04 10:25:22 -0700
commitf021368a6697c6b064aa8da208cdf60265f4bfe0 (patch)
tree57a4f8aa011d893004accc1a5043c5e154780d8f /test/integration/page.test.js
parent3049acbe1599e6665fd6ee48496048493349bf97 (diff)
WIP: add fullscreen and download save abilities
Diffstat (limited to 'test/integration/page.test.js')
-rw-r--r--test/integration/page.test.js32
1 files changed, 30 insertions, 2 deletions
diff --git a/test/integration/page.test.js b/test/integration/page.test.js
index 9dfe828..e888b6d 100644
--- a/test/integration/page.test.js
+++ b/test/integration/page.test.js
@@ -2,20 +2,44 @@ const { Builder, By } = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome.js'),
{ expect, it } = require('@jest/globals'),
chromeOptions = new chrome.Options(),
- { mkdir, writeFile } = require('node:fs/promises'),
+ { mkdir, writeFile, symlink, unlink } = require('node:fs/promises'),
path = require('path');
chromeOptions.addArguments('--headless', '--disable-gpu', '--no-sandbox');
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());
+
await driver.get('http://localhost:3005');
});
-it('loads the page', async () => {
+it.only('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('selects an off-board soldier', async () => {
@@ -34,6 +58,10 @@ 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`;