test(e2e): playwright - two browsers play online, server shop, offline campaign (P4-2)
This commit is contained in:
28
tests/e2e/offline.spec.js
Normal file
28
tests/e2e/offline.spec.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// 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 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 = async () => Number((await page.locator('#hMoney').textContent()).replace(/[^\d]/g, ''));
|
||||
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);
|
||||
});
|
||||
Reference in New Issue
Block a user