Playwright start

This commit is contained in:
2026-05-30 10:04:12 -04:00
parent 73f29cea08
commit 1f7a0819fc
108 changed files with 37445 additions and 62 deletions
+125
View File
@@ -0,0 +1,125 @@
const { test, expect } = require('@playwright/test');
const BuildCalculatorPage = require('../pages/buildCalculatorPage');
const { Website } = require('../helpers/website');
test.describe('Build Calculator', () => {
let website;
test.beforeEach(({ page }) => {
website = new Website(page);
});
test('Add entities via keyboard Q, W, E with Q\'Rath/Orzum', async ({ page }) => {
const calc = website.buildCalculatorPage;
await calc.goto();
await calc.filter.selectFaction("Q'Rath");
await calc.filter.selectImmortal('Orzum');
await calc.hotkeys.clickKey('TAB');
const keyNames = { Q: 'q', W: 'w', E: 'e', TAB: 'Tab' };
for (const key of ['Q', 'W', 'E', 'TAB']) {
const entityNames = await calc.hotkeys.getEntityNamesOnKey(key);
if (entityNames.length === 0) continue;
await page.keyboard.press(keyNames[key]);
const viewName = await calc.entityView.getEntityName();
expect(viewName).toBeTruthy();
expect(entityNames).toContain(viewName);
}
});
test('Add entities via hotkeys TAB, Q, W, E with Q\'Rath/Orzum', async ({ page }) => {
const calc = website.buildCalculatorPage;
await calc.goto();
await calc.filter.selectFaction("Q'Rath");
await calc.filter.selectImmortal('Orzum');
for (const key of ['TAB', 'Q', 'W', 'E']) {
const entityNames = await calc.hotkeys.getEntityNamesOnKey(key);
if (entityNames.length === 0) continue;
await calc.hotkeys.clickKey(key);
const viewName = await calc.entityView.getEntityName();
expect(viewName).toBeTruthy();
expect(entityNames).toContain(viewName);
}
});
test('Add Acropolis via Q, verify entity view and timeline, then clear', async ({ page }) => {
const calc = website.buildCalculatorPage;
await calc.goto();
const buttons = page.locator('.keyContainer > div > div');
console.log('Initial Q button text:', await buttons.filter({ hasText: /^Q/ }).first().textContent());
// Wait for Blazor re-render to complete by waiting for the button text to stabilize
// (it goes from QAcropolis → empty during re-render → back to QAcropolis)
let tries = 0;
let text = '';
while (tries < 20) {
await page.waitForTimeout(500);
try {
text = (await buttons.filter({ hasText: /^Q/ }).first().textContent() || '').trim();
if (text && text.length > 1) break;
} catch { }
tries++;
}
console.log(`After Blazor render (${(tries+1)*0.5}s): Q button text: ${JSON.stringify(text)}`);
await calc.filter.selectFaction("Q'Rath");
await calc.filter.selectImmortal('Orzum');
await page.waitForTimeout(1000);
console.log('After filter Q button text:', await buttons.filter({ hasText: /^Q/ }).first().textContent());
expect(await calc.timeline.containsEntity('Acropolis')).toBe(false);
await calc.hotkeys.clickKey('Q');
await page.waitForTimeout(1000);
expect(await calc.entityView.getEntityName()).toBe('Acropolis');
expect(await calc.timeline.containsEntity('Acropolis')).toBe(true);
await calc.clickClearBuildOrder();
await page.waitForTimeout(1000);
expect(await calc.timeline.containsEntity('Acropolis')).toBe(false);
expect(await calc.entityView.getEntityName()).toBeNull();
});
test('Missing Requirements toast when building Soul Foundry without Legion Hall', async ({ page }) => {
const calc = website.buildCalculatorPage;
await calc.goto();
await calc.filter.selectFaction("Q'Rath");
await calc.filter.selectImmortal('Orzum');
await calc.hotkeys.clickKey('E');
const hasToast = await calc.toast.hasToastContaining('Missing Requirements');
expect(hasToast).toBe(true);
});
test('Not Enough Ether toast when building Soul Foundry after Legion Hall', async ({ page }) => {
const calc = website.buildCalculatorPage;
await calc.goto();
await calc.filter.selectFaction("Q'Rath");
await calc.filter.selectImmortal('Orzum');
await calc.hotkeys.clickKey('W');
await calc.hotkeys.clickKey('E');
const hasToast = await calc.toast.hasToastContaining('Not Enough Ether');
expect(hasToast).toBe(true);
});
});
+32
View File
@@ -0,0 +1,32 @@
const { test, expect } = require('@playwright/test');
const { Website } = require('../helpers/website');
test.describe('Harass Calculator', () => {
let website;
test.beforeEach(({ page }) => {
website = new Website(page);
});
test('CalculatorInput', async () => {
const page = website.harassCalculatorPage;
await page.goto();
await page.setWorkersLostToHarass(3);
await page.setNumberOfTownHallsExisting(2);
await page.setTownHallTravelTime(0, 30);
const result = await page.getTotalAlloyHarassment();
expect(result).toBe(240);
});
test('CalculatedExampleInformation', async () => {
const page = website.harassCalculatorPage;
await page.goto();
expect(await page.getExampleTotalAlloyLoss()).toBe(720);
expect(await page.getExampleWorkerCost()).toBe(300);
expect(await page.getExampleMiningTimeCost()).toBe(420);
expect(await page.getExampleTotalAlloyLossAccurate()).toBe(450);
expect(await page.getExampleTotalAlloyLossDifference()).toBe(300);
expect(await page.getExampleTotalAlloyLossAccurateDifference()).toBe(270);
});
});
+28
View File
@@ -0,0 +1,28 @@
const { test } = require('@playwright/test');
const { Website } = require('../helpers/website');
const TestReport = require('../utils/testReport');
test.describe('Link Verification', () => {
let website;
let testReport;
test.beforeEach(() => {
testReport = new TestReport();
});
test('VerifyPageLinks', async ({ page }) => {
website = new Website(page);
testReport.createTest(test.info().title);
await website.harassCalculatorPage.goto();
await testReport.verifyLinks(website.harassCalculatorPage);
await website.databasePage.goto();
await testReport.verifyLinks(website.databasePage);
await website.databaseSinglePage.goto('throne');
await testReport.verifyLinks(website.databaseSinglePage);
testReport.throwErrors();
});
});
+54
View File
@@ -0,0 +1,54 @@
const { test, expect } = require('@playwright/test');
const { Website } = require('../helpers/website');
test.describe('Search Features', () => {
let website;
test.beforeEach(({ page }) => {
website = new Website(page);
});
test('DesktopOpenCloseSearchDialog', async () => {
await website.goto();
await website.navigationBar.clickSearchButton();
await website.websiteSearchDialog.closeDialog();
await website.navigationBar.clickHomeLink();
});
test('DesktopSearchForThrone', async () => {
await website.goto();
await website.navigationBar.clickSearchButton();
await website.websiteSearchDialog.search('Throne');
const page = await website.websiteSearchDialog.selectSearchEntity('Throne');
const name = await page.getEntityName();
const health = await page.getEntityHealth();
expect(name).toBe('Throne');
expect(health.trim()).not.toBe('');
});
test('DesktopFilterForThrone', async () => {
const page = website.databasePage;
await page.goto();
await page.filterName('Throne');
const name = await page.getEntityNameByIndex(0);
expect(name).toBe('Throne');
});
test('SeeThroneByDefault', async () => {
const page = website.databasePage;
await page.goto();
const name = await page.getEntityName('army', 'throne');
expect(name).toBe('Throne');
});
test('DirectLinkNotThroneFailure', async () => {
const page = website.databaseSinglePage;
await page.goto('not throne');
const invalidSearch = await page.getInvalidSearch();
const validSearch = await page.getValidSearch();
expect(invalidSearch).toBe('not throne');
expect(validSearch).toBe('Throne');
});
});