2024-01-27 09:58:50 +01:00
|
|
|
import { BrowserContext, ElectronApplication, Page, _electron as electron } from 'playwright';
|
|
|
|
import { test, expect } from '@playwright/test';
|
|
|
|
import * as PATH from 'path';
|
2024-03-22 08:10:22 +01:00
|
|
|
import {GameModel} from "../../../src/app/project/game-model/GameModel";
|
|
|
|
import {Gamesystem} from "../../src/app/project/game-model/gamesystems/Gamesystem";
|
|
|
|
import {ScriptAccount} from "../../../src/app/project/game-model/scriptAccounts/ScriptAccount";
|
|
|
|
import {ModelComponentType} from "../../../src/app/project/game-model/ModelComponentType";
|
2024-01-27 09:58:50 +01:00
|
|
|
|
|
|
|
test.describe('Test ScriptAccounts', () => {
|
|
|
|
|
|
|
|
test("Test ScriptAccount Creation", async () => {
|
|
|
|
const scriptAccunt = new ScriptAccount("ScriptAccount", "Description");
|
|
|
|
|
|
|
|
expect(scriptAccunt.componentName).toEqual("ScriptAccount");
|
|
|
|
expect(scriptAccunt.componentDescription).toEqual("Description");
|
|
|
|
expect(scriptAccunt.type).toEqual(ModelComponentType.SCRIPTACCOUNT);
|
|
|
|
expect(scriptAccunt.minValue).toEqual(0);
|
|
|
|
expect(scriptAccunt.maxValue).toEqual(100);
|
|
|
|
})
|
|
|
|
|
|
|
|
test("Test Adding ScriptAccounts", async () => {
|
|
|
|
const gameModel: GameModel = new GameModel("GameModel");
|
|
|
|
|
2024-02-10 10:11:07 +01:00
|
|
|
let scriptAccount =gameModel.createScriptAccount("ScriptAccount");
|
2024-01-27 13:19:46 +01:00
|
|
|
expect(scriptAccount).toBeDefined();
|
2024-01-27 09:58:50 +01:00
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
|
|
expect(gameModel.scriptAccounts.includes(scriptAccount)).toBeTruthy();
|
|
|
|
|
2024-01-27 13:19:46 +01:00
|
|
|
//Test adding scriptAccount with already existing name
|
2024-02-10 10:11:07 +01:00
|
|
|
const scriptAccount2 = gameModel.createScriptAccount("ScriptAccount")
|
2024-01-27 13:19:46 +01:00
|
|
|
expect(scriptAccount2).toBeUndefined();
|
2024-01-27 09:58:50 +01:00
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
|
|
|
2024-01-27 13:19:46 +01:00
|
|
|
//Test for adding invalid names as scriptaccount names (null/undefined/empty)
|
2024-02-10 10:11:07 +01:00
|
|
|
let result = gameModel.createScriptAccount(null);
|
2024-01-27 13:19:46 +01:00
|
|
|
expect(result).toBeUndefined();
|
2024-01-27 09:58:50 +01:00
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
2024-02-10 10:11:07 +01:00
|
|
|
result = gameModel.createScriptAccount(undefined);
|
2024-01-27 13:19:46 +01:00
|
|
|
expect(result).toBeUndefined();
|
2024-01-27 09:58:50 +01:00
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
2024-02-10 10:11:07 +01:00
|
|
|
result = gameModel.createScriptAccount("");
|
2024-01-27 13:19:46 +01:00
|
|
|
expect(result).toBeUndefined();
|
2024-01-27 09:58:50 +01:00
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
|
|
})
|
|
|
|
|
|
|
|
test("test Removing ScriptAccounts", async () => {
|
|
|
|
const gameModel: GameModel = new GameModel("GameModel");
|
2024-01-27 13:19:46 +01:00
|
|
|
let scriptAccount = new ScriptAccount("test", "")
|
2024-01-27 09:58:50 +01:00
|
|
|
|
|
|
|
gameModel.removeScriptAccount(scriptAccount);
|
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
|
2024-02-10 10:11:07 +01:00
|
|
|
scriptAccount = gameModel.createScriptAccount("ScriptAccount");
|
2024-01-27 09:58:50 +01:00
|
|
|
gameModel.removeScriptAccount(scriptAccount);
|
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
|
|
|
|
gameModel.removeScriptAccount(undefined);
|
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
|
|
|
|
gameModel.removeScriptAccount(null);
|
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(0);
|
|
|
|
|
2024-02-10 10:11:07 +01:00
|
|
|
scriptAccount = gameModel.createScriptAccount(scriptAccount);
|
|
|
|
let scriptAccount2 = gameModel.createScriptAccount("ScriptAccount 2");
|
2024-01-27 09:58:50 +01:00
|
|
|
|
|
|
|
gameModel.removeScriptAccount(scriptAccount);
|
|
|
|
expect(gameModel.scriptAccounts.length).toEqual(1);
|
|
|
|
expect(gameModel.scriptAccounts.includes(scriptAccount2)).toBeTruthy();
|
|
|
|
})
|
|
|
|
|
|
|
|
});
|