Skip to content

Map list generator · E2E tests

1 module · 3 exports · 0 repositories · 5 e2e tests · 1 route

  • Arrange data setup
  • Act what the user does
  • Assert what is expected

Map List Generator

generates a map list from a custom map pool

Renders/maps

LOLogged out
Map list generator page
Act
  1. Open the map list generator page
    await mapListPage.goto();
  2. Clear map pool
    await mapListPage.clearMapPool();
Assert
  1. create map list button is disabled
    await expect(mapListPage.locators.createMapListButton).toBeDisabled();
Act
  1. Toggle mode “Museum d'Alfonsino”, “Splat Zones”
    await mapListPage.toggleMode("Museum d'Alfonsino", "Splat Zones");
  2. Toggle mode “Hagglefish Market”, “Splat Zones”
    await mapListPage.toggleMode("Hagglefish Market", "Splat Zones");
  3. Toggle mode “Manta Maria”, “Tower Control”
    await mapListPage.toggleMode("Manta Maria", "Tower Control");
Assert
  1. stage checkbox “Manta Maria” is checked
    await expect(mapListPage.stageCheckbox("Manta Maria")).toBeChecked();
Act
  1. Reload with persisted pool
    await mapListPage.reloadWithPersistedPool();
Assert
  1. the picker opens on the first mode that has stages

    stage checkbox “Museum d'Alfonsino” is checked
    await expect(mapListPage.stageCheckbox("Museum d'Alfonsino")).toBeChecked();
Act
  1. Create map list
    await mapListPage.createMapList();
Arrange
  1. items = generated map list items
    const items = mapListPage.locators.generatedMapListItems;
Assert
  1. items count is GENERATED_MAP_LIST_LENGTH
    await expect(items).toHaveCount(GENERATED_MAP_LIST_LENGTH);
  2. items reads Array.from( { length: GENERATED_MAP_LIST_LENGTH }, () => /^(SZ (Museum d'Alfo…
    await expect(items).toHaveText(
    	Array.from(
    		{ length: GENERATED_MAP_LIST_LENGTH },
    		() => /^(SZ (Museum d'Alfonsino|Hagglefish Market)|TC Manta Maria)$/,
    	),
    );
  3. items.filter({ hasText: "Manta Maria" }).first() is visible
    await expect(
    	items.filter({ hasText: "Manta Maria" }).first(),
    ).toBeVisible();
Source
test("generates a map list from a custom map pool", async ({ page }) => {
	const mapListPage = new MapListGeneratorPage(page);
	await mapListPage.goto();

	await mapListPage.clearMapPool();
	await expect(mapListPage.locators.createMapListButton).toBeDisabled();

	await mapListPage.toggleMode("Museum d'Alfonsino", "Splat Zones");
	await mapListPage.toggleMode("Hagglefish Market", "Splat Zones");
	await mapListPage.toggleMode("Manta Maria", "Tower Control");
	await expect(mapListPage.stageCheckbox("Manta Maria")).toBeChecked();

	await mapListPage.reloadWithPersistedPool();
	// the picker opens on the first mode that has stages
	await expect(mapListPage.stageCheckbox("Museum d'Alfonsino")).toBeChecked();

	await mapListPage.createMapList();

	const items = mapListPage.locators.generatedMapListItems;
	await expect(items).toHaveCount(GENERATED_MAP_LIST_LENGTH);
	await expect(items).toHaveText(
		Array.from(
			{ length: GENERATED_MAP_LIST_LENGTH },
			() => /^(SZ (Museum d'Alfonsino|Hagglefish Market)|TC Manta Maria)$/,
		),
	);
	await expect(
		items.filter({ hasText: "Manta Maria" }).first(),
	).toBeVisible();
})

Map Planner

sets a stage background and adds a weapon to the canvas

Renders/plans

LOLogged out
Map planner page
Act
  1. Open the map planner page
    await planner.goto();
Assert
  1. no error page
    await expectNoErrorPage(page);
  2. image shapes count is 0
    await expect(planner.locators.imageShapes).toHaveCount(0);
Act
  1. Set background “Museum d'Alfonsino”
    await planner.setBackground("Museum d'Alfonsino");
Assert
  1. image shapes count is 1
    await expect(planner.locators.imageShapes).toHaveCount(1);
Act
  1. Open weapon category “Shooters”
    await planner.openWeaponCategory("Shooters");
  2. Drag weapon to canvas “Splattershot”
    await planner.dragWeaponToCanvas("Splattershot");
Assert
  1. image shapes count is 2
    await expect(planner.locators.imageShapes).toHaveCount(2);
Source
test("sets a stage background and adds a weapon to the canvas", async ({
	page,
}) => {
	const planner = new MapPlannerPage(page);
	await planner.goto();
	await expectNoErrorPage(page);

	await expect(planner.locators.imageShapes).toHaveCount(0);

	await planner.setBackground("Museum d'Alfonsino");
	await expect(planner.locators.imageShapes).toHaveCount(1);

	await planner.openWeaponCategory("Shooters");
	await planner.dragWeaponToCanvas("Splattershot");
	await expect(planner.locators.imageShapes).toHaveCount(2);
})

restores the plan and the selected stage after a reload

Renders/plans

LOLogged out
Map planner page
Act
  1. Open the map planner page
    await planner.goto();
  2. Set background “Museum d'Alfonsino”
    await planner.setBackground("Museum d'Alfonsino");
Assert
  1. the page URL is /stage=/
    await expect(page).toHaveURL(/stage=/);
Act
  1. Open weapon category “Shooters”
    await planner.openWeaponCategory("Shooters");
  2. Drag weapon to canvas “Splattershot”
    await planner.dragWeaponToCanvas("Splattershot");
Assert
  1. image shapes count is 2
    await expect(planner.locators.imageShapes).toHaveCount(2);
Act
  1. Reload with persisted plan 2
    await planner.reloadWithPersistedPlan(2);
Assert
  1. image shapes count is 2
    await expect(planner.locators.imageShapes).toHaveCount(2);
  2. stage select has value String(stagesObj.MUSEUM_D_ALFONSINO)
    await expect(planner.locators.stageSelect).toHaveValue(
    	String(stagesObj.MUSEUM_D_ALFONSINO),
    );
Source
test("restores the plan and the selected stage after a reload", async ({
	page,
}) => {
	const planner = new MapPlannerPage(page);
	await planner.goto();

	await planner.setBackground("Museum d'Alfonsino");
	await expect(page).toHaveURL(/stage=/);

	await planner.openWeaponCategory("Shooters");
	await planner.dragWeaponToCanvas("Splattershot");
	await expect(planner.locators.imageShapes).toHaveCount(2);

	await planner.reloadWithPersistedPlan(2);

	await expect(planner.locators.imageShapes).toHaveCount(2);
	await expect(planner.locators.stageSelect).toHaveValue(
		String(stagesObj.MUSEUM_D_ALFONSINO),
	);
})

restores a downloaded plan file when it is opened

Renders/plans

LOLogged out
Map planner page
Act
  1. Open the map planner page
    await planner.goto();
  2. Set background “Museum d'Alfonsino”
    await planner.setBackground("Museum d'Alfonsino");
  3. Open weapon category “Shooters”
    await planner.openWeaponCategory("Shooters");
  4. Drag weapon to canvas “Splattershot”
    await planner.dragWeaponToCanvas("Splattershot");
Assert
  1. image shapes count is 2
    await expect(planner.locators.imageShapes).toHaveCount(2);
Act
  1. Download plan file → download
    const download = await planner.downloadPlanFile();
Assert
  1. download.suggestedFilename() is “plan.tldr”
    expect(download.suggestedFilename()).toBe("plan.tldr");
Act
  1. Drag weapon to canvas “Splattershot”
    await planner.dragWeaponToCanvas("Splattershot");
Assert
  1. image shapes count is 3
    await expect(planner.locators.imageShapes).toHaveCount(3);
Act
  1. Open plan file download.path()
    await planner.openPlanFile(await download.path());
Assert
  1. image shapes count is 2
    await expect(planner.locators.imageShapes).toHaveCount(2);
  2. open file error toast count is 0
    await expect(planner.locators.openFileErrorToast).toHaveCount(0);
Source
test("restores a downloaded plan file when it is opened", async ({
	page,
}) => {
	const planner = new MapPlannerPage(page);
	await planner.goto();

	await planner.setBackground("Museum d'Alfonsino");
	await planner.openWeaponCategory("Shooters");
	await planner.dragWeaponToCanvas("Splattershot");
	await expect(planner.locators.imageShapes).toHaveCount(2);

	const download = await planner.downloadPlanFile();
	expect(download.suggestedFilename()).toBe("plan.tldr");

	await planner.dragWeaponToCanvas("Splattershot");
	await expect(planner.locators.imageShapes).toHaveCount(3);

	await planner.openPlanFile(await download.path());

	await expect(planner.locators.imageShapes).toHaveCount(2);
	await expect(planner.locators.openFileErrorToast).toHaveCount(0);
})

shows an error when the opened plan file is invalid

Renders/plans

LOLogged out
Map planner page
Act
  1. Open the map planner page
    await planner.goto();
  2. Set background “Museum d'Alfonsino”
    await planner.setBackground("Museum d'Alfonsino");
Assert
  1. image shapes count is 1
    await expect(planner.locators.imageShapes).toHaveCount(1);
Act
  1. Open plan file name “plan.tldr” mime type “application/json” buffer Buffer.from("not a plan")
    await planner.openPlanFile({
    	name: "plan.tldr",
    	mimeType: "application/json",
    	buffer: Buffer.from("not a plan"),
    });
Assert
  1. toasts render hidden in e2e runs

    open file error toast is in the page
    await expect(planner.locators.openFileErrorToast).toBeAttached();
  2. image shapes count is 1
    await expect(planner.locators.imageShapes).toHaveCount(1);
Source
test("shows an error when the opened plan file is invalid", async ({
	page,
}) => {
	const planner = new MapPlannerPage(page);
	await planner.goto();

	await planner.setBackground("Museum d'Alfonsino");
	await expect(planner.locators.imageShapes).toHaveCount(1);

	await planner.openPlanFile({
		name: "plan.tldr",
		mimeType: "application/json",
		buffer: Buffer.from("not a plan"),
	});

	// toasts render hidden in e2e runs
	await expect(planner.locators.openFileErrorToast).toBeAttached();
	await expect(planner.locators.imageShapes).toHaveCount(1);
})