Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions game/tests/avatarEditor.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import {test} from "./libs/enhanced_test";
import {userLogin, navigateToAvatarEditor, userLogout} from "./libs/welcomeScreen_helper"
import {expect} from "@playwright/test";
import {enrollInMoodleCourse} from "./libs/moodle_helpers";
import {viewPorts} from "./libs/viewPorts";

test.describe.serial(`avatar editor`, () => {

test.beforeAll(async ({ request, resetEnvironment, uploadWorld }) => {
await resetEnvironment();
const uploadedWorld = await uploadWorld('testwelt');
await enrollInMoodleCourse(
request,
process.env._PLAYWRIGHT_USER_STUDENT_USERNAME!,
process.env._USER_STUDENT_PW!,
uploadedWorld.worldNameInLms
);
Comment on lines +11 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unnötig hier?!

});

viewPorts.forEach(({width, height}) => {

test(`user navigates from avatar editor to welcome screen (${width}x${height})`, async ({page}) => {
await page.setViewportSize({width: width, height: height});
await userLogin(page);
const welcomScreenURL = page.url();
await navigateToAvatarEditor(page);
await page.getByRole('button', { name: 'Home Icon' }).click();
await expect(page.url()).toEqual(welcomScreenURL);
Comment on lines +25 to +28
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'welcomScreenURL' to 'welcomeScreenURL'.

Suggested change
const welcomScreenURL = page.url();
await navigateToAvatarEditor(page);
await page.getByRole('button', { name: 'Home Icon' }).click();
await expect(page.url()).toEqual(welcomScreenURL);
const welcomeScreenURL = page.url();
await navigateToAvatarEditor(page);
await page.getByRole('button', { name: 'Home Icon' }).click();
await expect(page.url()).toEqual(welcomeScreenURL);

Copilot uses AI. Check for mistakes.
})

test(`user selects avatar editor categories (${width}x${height})`, async ({page}) =>{
//TODO: Replace getByRole-Query with getByTestId-Query when button has testid
await page.setViewportSize({width: width, height: height});
await userLogin(page);
await navigateToAvatarEditor(page);
await page.getByTestId('avatar-editor-category-tab-0').click();
await expect(await page.getByRole('button', { name: /Frisur/i })).toBeVisible();
await page.getByTestId('avatar-editor-category-tab-1').click();
await expect(await page.getByRole('button', { name: /Augenbrauen/i })).toBeVisible();
await page.getByTestId('avatar-editor-category-tab-2').click();
await expect(await page.getByRole('button', { name: /Kopfbedeckung/i })).toBeVisible();
await page.getByTestId('avatar-editor-category-tab-3').click();
await expect(await page.getByRole('button', { name: /Oberteil/i })).toBeVisible();
await page.getByTestId('avatar-editor-category-tab-4').click();
await expect(await page.getByRole('heading', { name: /Hautfarbe/i })).toBeVisible();
})
})
})
10 changes: 10 additions & 0 deletions game/tests/libs/viewPorts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const viewPorts: {width: number, height: number}[] = [
{width: 844, height: 331},
{width: 390, height: 695},
{width: 1080, height: 688},
{width: 810, height: 918},
{width: 1280, height: 612},
{width: 1920, height: 918},
{width: 2560, height: 1224},
{width: 3840, height: 1836},
]
30 changes: 30 additions & 0 deletions game/tests/libs/welcomeScreen_helper.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import {Page} from "@playwright/test";

export async function userLogin(
page: Page,
username: string = process.env._PLAYWRIGHT_USER_STUDENT_USERNAME!,
password: string = process.env._USER_STUDENT_PW!,
) {
await page.goto('/');
await page.getByTestId('userName').click();
await page.getByTestId('userName').fill(username);
await page.getByTestId('userName').press('Tab');
await page.getByTestId('password').fill(password);
await page.getByTestId('loginButton').click();
}
Comment on lines +3 to +14
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wenn öfters benötigt wäre der besser in der enhanced_test.ts untergebracht. der wäre dann so erreichbar

test(`user navigates from avatar editor to welcome screen (${width}x${height})`, async ({page, userlogin}) => {..}

und das naming der methode sollte eine klarere differenzierung von den in dieser datei bereits bestehenden methoden haben (generell, unabhängig davon ob du es dort rein packst oder nicht)


export async function userLogout(
page: Page
) {
await page.getByTestId("logout").click();
}

export async function navigateToLearningWorldMenu(page: Page) {
//TODO: Replace with getByTestId-Query when button has testid
await page.getByRole('button').filter({ hasText: /^$/ }).nth(1).click();
Comment on lines +23 to +24
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The selector uses an empty text filter with nth(1) which is fragile and could break if button order changes. Consider using a more specific selector or add test IDs to the buttons as suggested in the TODO comment.

Suggested change
//TODO: Replace with getByTestId-Query when button has testid
await page.getByRole('button').filter({ hasText: /^$/ }).nth(1).click();
// Requires: Add data-testid="learningWorldMenuButton" to the target button in the application code.
await page.getByTestId('learningWorldMenuButton').click();

Copilot uses AI. Check for mistakes.
}

export async function navigateToAvatarEditor(page: Page) {
//TODO: Replace with getByTestId-Query when button has testid
await page.getByRole('button').filter({ hasText: /^$/ }).nth(2).click();
Comment on lines +28 to +29
Copy link

Copilot AI Oct 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar to the previous selector, this uses an empty text filter with nth(2) which is brittle. The reliance on button position makes tests fragile to UI changes.

Suggested change
//TODO: Replace with getByTestId-Query when button has testid
await page.getByRole('button').filter({ hasText: /^$/ }).nth(2).click();
// TODO: The button for navigating to the Avatar Editor must have data-testid="avatarEditorButton" in the application code.
await page.getByTestId('avatarEditorButton').click();

Copilot uses AI. Check for mistakes.
}
17 changes: 0 additions & 17 deletions game/tests/login.spec.ts

This file was deleted.

52 changes: 52 additions & 0 deletions game/tests/welcomeScreen.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import {test} from "./libs/enhanced_test";
import {userLogin, userLogout, navigateToAvatarEditor, navigateToLearningWorldMenu} from "./libs/welcomeScreen_helper"
import {expect} from "@playwright/test";
import {enrollInMoodleCourse} from "./libs/moodle_helpers";
import {viewPorts} from "./libs/viewPorts";

test.describe.serial(`welcome screen`, () => {

test.beforeAll(async ({ request, resetEnvironment, uploadWorld }) => {
await resetEnvironment();
const uploadedWorld = await uploadWorld('testwelt');
await enrollInMoodleCourse(
request,
process.env._PLAYWRIGHT_USER_STUDENT_USERNAME!,
process.env._USER_STUDENT_PW!,
uploadedWorld.worldNameInLms
);
Comment on lines +11 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

});

viewPorts.forEach(({width, height}) => {

test(`user logs in (${width}x${height})`, async ({page}) => {
await page.setViewportSize({width: width, height: height});
await userLogin(page);
await expect(page.getByTestId("login-button")).toBeVisible();
})

test(`user logs out (${width}x${height})`, async ({page}) => {
await page.setViewportSize({width: width, height: height});
await userLogin(page);
await userLogout(page);
await expect(page.getByTestId("userName")).toBeVisible()
await expect(page.getByTestId("password")).toBeVisible()
})

test(`user navigates from welcome screen to learning world menu (${width}x${height})`, async ({page}) => {
await page.setViewportSize({width: width, height: height});
await userLogin(page);
await navigateToLearningWorldMenu(page);
await expect(page.url()).toContain("worldmenu");
await expect(page.getByRole('button', { name: 'testwelt' })).toBeVisible();
})

test(`user navigates from welcome screen to avatar-editor (${width}x${height})`, async ({page}) => {
await page.setViewportSize({width: width, height: height});
await userLogin(page);
await navigateToAvatarEditor(page);
await expect(page.url()).toContain("avatarEditor");
await expect(page.locator("canvas")).toBeVisible();
})
})
})
Loading