Files

105 lines
3.2 KiB
JavaScript

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();
await calc.filter.selectFaction("Q'Rath");
await calc.filter.selectImmortal('Orzum');
expect(await calc.timeline.containsEntity('Acropolis')).toBe(false);
await calc.hotkeys.clickKey('Q');
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);
});
});