Modules are classic-script factories RC.Game<Part>(G); G gives live access to the shared state. Guarded by new browser tests for every moved page and workshop tool (tests/e2e/screens.spec.js).
30 lines
1.4 KiB
JavaScript
30 lines
1.4 KiB
JavaScript
// The offline campaign must keep working without any server (double-click on game/index.html = file://).
|
|
'use strict';
|
|
const { test, expect } = require('@playwright/test');
|
|
const path = require('path');
|
|
const { pathToFileURL } = require('url');
|
|
const { credits } = require('./helpers');
|
|
|
|
const file = pathToFileURL(path.join(__dirname, '..', '..', 'game', 'index.html')).href;
|
|
|
|
test('campaign runs from file:// : training fight with the AI pilot, layout check passes', async ({ page }) => {
|
|
const errors = [];
|
|
page.on('pageerror', e => errors.push(e.message));
|
|
await page.goto(file + '?play&fight=2&auto&ff=20&uicheck');
|
|
await expect(page.locator('body')).toHaveAttribute('data-gmode', 'campaign');
|
|
await expect(page.locator('body')).toHaveAttribute('data-mode', /fight|result/);
|
|
await expect(page.locator('#uicheck')).toContainText('UI ok');
|
|
expect(errors).toEqual([]);
|
|
});
|
|
|
|
test('campaign workshop: buying a part works offline', async ({ page }) => {
|
|
await page.goto(file + '?play');
|
|
await expect(page.locator('body')).toHaveAttribute('data-mode', 'garage');
|
|
const money = () => credits(page);
|
|
const before = await money();
|
|
await page.locator('.tab[data-slot="armour"]').click();
|
|
await page.locator('#cards .item:not(:has(.badge)):not(:has(.pr.no))').first().click();
|
|
await page.locator('#detail button[data-act="buy"]').click();
|
|
expect(await money()).toBeLessThan(before);
|
|
});
|