Add another integration test; document debugging integration tests

This commit is contained in:
2024-04-18 15:11:04 -07:00
parent 25172dafed
commit ac71447aee
2 changed files with 125 additions and 4 deletions

View File

@@ -1,4 +1,4 @@
const { Builder } = require('selenium-webdriver'),
const { Builder, By } = require('selenium-webdriver'),
chrome = require('selenium-webdriver/chrome.js'),
{ expect, it } = require('@jest/globals'),
chromeOptions = new chrome.Options();
@@ -7,12 +7,25 @@ let driver;
chromeOptions.addArguments('--headless', '--disable-gpu', '--no-sandbox');
beforeAll(async () => {
beforeEach(async () => {
driver = new Builder().forBrowser('chrome').setChromeOptions(chromeOptions).build();
await driver.get("http://localhost:3005");
});
it('loads the page', async () => {
await driver.get("http://localhost:3005");
expect(await driver.getTitle()).toEqual('Infantry Combat Solo Basic');
});
it('selects a trooper by clicking on their counter', async () => {
await driver.switchTo().frame(driver.findElement(By.css('object')));
const selector = 'use.counter[data-allegiance="liao"][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'));
});
afterEach(async () => await driver.quit());