Skip to content

Params · E2E tests

1 module · 11 exports · 0 repositories · 2 e2e tests · 1 route

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

Weapon parameters

table filtering, comparison bar graph and history rows (via Analyzer)

Renders/analyzer/params/:slug

LOLogged out
Analyzer page
Act
  1. Open the analyzer page
    await analyzer.goto();
  2. Pick weapon “Splattershot”
    await analyzer.pickWeapon("Splattershot");
  3. Open raw parameters “splattershot” → weaponParams
    const weaponParams = await analyzer.openRawParameters("splattershot");
Assert
  1. the page URL is /\/params\/splattershot/
    await expect(page).toHaveURL(/\/params\/splattershot/);
Arrange
  1. a sibling column has to render after the client-side navigation first, or the count is taken mid-hydration

    { weaponHeaders, showAllWeaponsButton } = locators
    const { weaponHeaders, showAllWeaponsButton } = weaponParams.locators;
Assert
  1. weaponHeaders.nth(1) is visible
    await expect(weaponHeaders.nth(1)).toBeVisible();
Act
  1. Count → initialColumnCount
    const initialColumnCount = await weaponHeaders.count();
Assert
  1. initialColumnCount is more than 1
    expect(initialColumnCount).toBeGreaterThan(1);
Weapon params page
Act
  1. Hide weapon
    await weaponParams.hideWeapon();
Assert
  1. showAllWeaponsButton is visible
    await expect(showAllWeaponsButton).toBeVisible();
  2. weaponHeaders count is initialColumnCount - 1
    await expect(weaponHeaders).toHaveCount(initialColumnCount - 1);
  3. the page URL is /hidden=\d/
    await expect(page).toHaveURL(/hidden=\d/);
Act
  1. Reload
    await weaponParams.reload();
Assert
  1. the page URL is /hidden=\d/
    await expect(page).toHaveURL(/hidden=\d/);
  2. showAllWeaponsButton is visible
    await expect(showAllWeaponsButton).toBeVisible();
  3. weaponHeaders count is initialColumnCount - 1
    await expect(weaponHeaders).toHaveCount(initialColumnCount - 1);
Act
  1. Show all weapons
    await weaponParams.showAllWeapons();
Assert
  1. showAllWeaponsButton is not visible
    await expect(showAllWeaponsButton).not.toBeVisible();
  2. weaponHeaders count is initialColumnCount
    await expect(weaponHeaders).toHaveCount(initialColumnCount);
  3. the page URL is not /hidden=\d/
    await expect(page).not.toHaveURL(/hidden=\d/);
Act
  1. Open param comparison
    await weaponParams.openParamComparison();
Assert
  1. comparison dialog is visible
    await expect(weaponParams.locators.comparisonDialog).toBeVisible();
  2. count be greater than or equal 2
    expect(
    	await weaponParams.locators.comparisonBars.count(),
    ).toBeGreaterThanOrEqual(2);
Act
  1. Close param comparison
    await weaponParams.closeParamComparison();
Assert
  1. comparison dialog is not visible
    await expect(weaponParams.locators.comparisonDialog).not.toBeVisible();
Act
  1. the patch-count badge shows only while the row is collapsed, signalling the toggle state

    History row 0 → historyRow
    const historyRow = weaponParams.historyRow(0);
Param history row
Assert
  1. root is visible
    await expect(historyRow.root).toBeVisible();
  2. history badge is visible
    await expect(historyRow.historyBadge).toBeVisible();
Act
  1. Toggle
    await historyRow.toggle();
Assert
  1. history badge is not visible
    await expect(historyRow.historyBadge).not.toBeVisible();
Act
  1. Toggle
    await historyRow.toggle();
Assert
  1. history badge is visible
    await expect(historyRow.historyBadge).toBeVisible();
Source
test("table filtering, comparison bar graph and history rows (via Analyzer)", async ({
	page,
}) => {
	const analyzer = new AnalyzerPage(page);
	await analyzer.goto();

	await analyzer.pickWeapon("Splattershot");

	const weaponParams = await analyzer.openRawParameters("splattershot");
	await expect(page).toHaveURL(/\/params\/splattershot/);

	// a sibling column has to render after the client-side navigation first, or the count is taken mid-hydration
	const { weaponHeaders, showAllWeaponsButton } = weaponParams.locators;
	await expect(weaponHeaders.nth(1)).toBeVisible();
	const initialColumnCount = await weaponHeaders.count();
	expect(initialColumnCount).toBeGreaterThan(1);

	await weaponParams.hideWeapon();

	await expect(showAllWeaponsButton).toBeVisible();
	await expect(weaponHeaders).toHaveCount(initialColumnCount - 1);
	await expect(page).toHaveURL(/hidden=\d/);

	await weaponParams.reload();
	await expect(page).toHaveURL(/hidden=\d/);
	await expect(showAllWeaponsButton).toBeVisible();
	await expect(weaponHeaders).toHaveCount(initialColumnCount - 1);

	await weaponParams.showAllWeapons();
	await expect(showAllWeaponsButton).not.toBeVisible();
	await expect(weaponHeaders).toHaveCount(initialColumnCount);
	await expect(page).not.toHaveURL(/hidden=\d/);

	await weaponParams.openParamComparison();
	await expect(weaponParams.locators.comparisonDialog).toBeVisible();
	expect(
		await weaponParams.locators.comparisonBars.count(),
	).toBeGreaterThanOrEqual(2);
	await weaponParams.closeParamComparison();
	await expect(weaponParams.locators.comparisonDialog).not.toBeVisible();

	// the patch-count badge shows only while the row is collapsed, signalling the toggle state
	const historyRow = weaponParams.historyRow(0);
	await expect(historyRow.root).toBeVisible();
	await expect(historyRow.historyBadge).toBeVisible();

	await historyRow.toggle();
	await expect(historyRow.historyBadge).not.toBeVisible();

	await historyRow.toggle();
	await expect(historyRow.historyBadge).toBeVisible();
})

Renders//params/:slug

NN-ZAP
Act
  1. Go to “/”
    await navigate({ page, url: "/" });
Global search dialog
Act
  1. Open
    await search.open();
  2. Search “splattershot”
    await search.search("splattershot");
  3. Select option “Splattershot”
    await search.selectOption("Splattershot");
  4. Select option “Parameters”
    await search.selectOption("Parameters");
Assert
  1. the page URL is /\/params\/splattershot/
    await expect(page).toHaveURL(/\/params\/splattershot/);
Act
  1. { patchHistoryTab, subAndSpecialChangesSwitch } = locators
    const { patchHistoryTab, subAndSpecialChangesSwitch } =
    	weaponParams.locators;
Weapon params page
Act
  1. Open patch history tab
    await weaponParams.openPatchHistoryTab();
Assert
  1. the page URL is /tab=patches/
    await expect(page).toHaveURL(/tab=patches/);
Act
  1. Reload
    await weaponParams.reload();
Assert
  1. the page URL is /tab=patches/
    await expect(page).toHaveURL(/tab=patches/);
  2. patchHistoryTab has “aria-selected” = “true”
    await expect(patchHistoryTab).toHaveAttribute("aria-selected", "true");
  3. Either patch columns are shown or the empty state

    first patch columns is visible
    await expect(weaponParams.locators.patchColumns.first()).toBeVisible();
  4. subAndSpecialChangesSwitch is checked
    await expect(subAndSpecialChangesSwitch).toBeChecked();
Act
  1. Toggle sub and special changes
    await weaponParams.toggleSubAndSpecialChanges();
Assert
  1. the page URL is /kitExtras=false/
    await expect(page).toHaveURL(/kitExtras=false/);
Act
  1. Reload
    await weaponParams.reload();
Assert
  1. the page URL is /kitExtras=false/
    await expect(page).toHaveURL(/kitExtras=false/);
  2. subAndSpecialChangesSwitch is not checked
    await expect(subAndSpecialChangesSwitch).not.toBeChecked();
Source
test("patch history tab persists across refresh (via weapon search)", async ({
	page,
}) => {
	await impersonate(page, NZAP_TEST_ID);
	await navigate({ page, url: "/" });

	const search = new GlobalSearchDialog(page);
	await search.open();
	await search.search("splattershot");
	await search.selectOption("Splattershot");
	await search.selectOption("Parameters");
	await expect(page).toHaveURL(/\/params\/splattershot/);

	const weaponParams = new WeaponParamsPage(page);
	const { patchHistoryTab, subAndSpecialChangesSwitch } =
		weaponParams.locators;

	await weaponParams.openPatchHistoryTab();
	await expect(page).toHaveURL(/tab=patches/);

	await weaponParams.reload();
	await expect(page).toHaveURL(/tab=patches/);
	await expect(patchHistoryTab).toHaveAttribute("aria-selected", "true");

	// Either patch columns are shown or the empty state
	await expect(weaponParams.locators.patchColumns.first()).toBeVisible();

	await expect(subAndSpecialChangesSwitch).toBeChecked();
	await weaponParams.toggleSubAndSpecialChanges();
	await expect(page).toHaveURL(/kitExtras=false/);

	await weaponParams.reload();
	await expect(page).toHaveURL(/kitExtras=false/);
	await expect(subAndSpecialChangesSwitch).not.toBeChecked();
})