/* Shared steps for the browser tests: log in through the real UI, get from the workshop into the lobby. */ 'use strict'; const { expect } = require('@playwright/test'); const mode = page => page.locator('body').getAttribute('data-mode'); // open the game in online mode and log in with name + password through the login card async function login(page, name, pass) { await page.goto('/?online'); await page.locator('#oLogin').fill(name); await page.locator('#oPass').fill(pass); await page.locator('#oGo').click(); await chooseCountry(page); await expect(page.locator('body')).toHaveAttribute('data-mode', 'garage'); await expect(page.locator('#hUser')).toContainText(name); } // first start asks for a country - take the default async function chooseCountry(page) { const go = page.locator('#cfGo'); try { await go.waitFor({ timeout: 4000 }); await go.click(); } catch (e) { /* already chosen */ } } async function toLobby(page) { await page.locator('#bLeague').click(); await expect(page.locator('body')).toHaveAttribute('data-mode', 'lobby'); } const credits = async page => Number((await page.locator('#hMoney').textContent()).replace(/[^\d]/g, '')); module.exports = { mode, login, chooseCountry, toLobby, credits };