Skip to content

Comp analyzer · E2E tests

3 modules · 19 exports · 0 repositories · 4 e2e tests · 1 route

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

Composition Analyzer

weapon selection, removal, and URL persistence

Renders/comp-analyzer

LOLogged out
Comp analyzer page
Act
  1. Open the comp analyzer page
    await compAnalyzer.goto();
Assert
  1. selected weapons is visible
    await expect(compAnalyzer.locators.selectedWeapons).toBeVisible();
  2. empty weapon slots count is 4
    await expect(compAnalyzer.locators.emptyWeaponSlots).toHaveCount(4);
Act
  1. Select weapon 40
    await compAnalyzer.selectWeapon(40);
Assert
  1. selected weapon 0 is visible
    await expect(compAnalyzer.selectedWeapon(0)).toBeVisible();
  2. empty weapon slots count is 3
    await expect(compAnalyzer.locators.emptyWeaponSlots).toHaveCount(3);
Act
  1. Remove weapon 0
    await compAnalyzer.removeWeapon(0);
Assert
  1. empty weapon slots count is 4
    await expect(compAnalyzer.locators.emptyWeaponSlots).toHaveCount(4);
  2. a full four weapons auto-collapse the grid

    categorization toggle is visible
    await expect(compAnalyzer.locators.categorizationToggle).toBeVisible();
Act
  1. Select weapon 40
    await compAnalyzer.selectWeapon(40);
  2. Select weapon 50
    await compAnalyzer.selectWeapon(50);
  3. Select weapon 60
    await compAnalyzer.selectWeapon(60);
  4. Select weapon 70
    await compAnalyzer.selectWeapon(70);
Assert
  1. categorization toggle is not visible
    await expect(compAnalyzer.locators.categorizationToggle).not.toBeVisible();
  2. the page URL is /weapons=/
    await expect(page).toHaveURL(/weapons=/);
Act
  1. Reload the page
    await page.reload();
Assert
  1. selected weapon 0 is visible
    await expect(compAnalyzer.selectedWeapon(0)).toBeVisible();
  2. selected weapon 1 is visible
    await expect(compAnalyzer.selectedWeapon(1)).toBeVisible();
  3. selected weapon 2 is visible
    await expect(compAnalyzer.selectedWeapon(2)).toBeVisible();
  4. selected weapon 3 is visible
    await expect(compAnalyzer.selectedWeapon(3)).toBeVisible();
Source
test("weapon selection, removal, and URL persistence", async ({ page }) => {
	const compAnalyzer = new CompAnalyzerPage(page);
	await compAnalyzer.goto();

	await expect(compAnalyzer.locators.selectedWeapons).toBeVisible();

	await expect(compAnalyzer.locators.emptyWeaponSlots).toHaveCount(4);

	await compAnalyzer.selectWeapon(40);

	await expect(compAnalyzer.selectedWeapon(0)).toBeVisible();
	await expect(compAnalyzer.locators.emptyWeaponSlots).toHaveCount(3);

	await compAnalyzer.removeWeapon(0);
	await expect(compAnalyzer.locators.emptyWeaponSlots).toHaveCount(4);

	// a full four weapons auto-collapse the grid
	await expect(compAnalyzer.locators.categorizationToggle).toBeVisible();

	await compAnalyzer.selectWeapon(40);
	await compAnalyzer.selectWeapon(50);
	await compAnalyzer.selectWeapon(60);
	await compAnalyzer.selectWeapon(70);

	await expect(compAnalyzer.locators.categorizationToggle).not.toBeVisible();

	await expect(page).toHaveURL(/weapons=/);

	await page.reload();

	await expect(compAnalyzer.selectedWeapon(0)).toBeVisible();
	await expect(compAnalyzer.selectedWeapon(1)).toBeVisible();
	await expect(compAnalyzer.selectedWeapon(2)).toBeVisible();
	await expect(compAnalyzer.selectedWeapon(3)).toBeVisible();
})

weapon grid controls and categorization

Renders/comp-analyzer

LOLogged out
Comp analyzer page
Act
  1. Open the comp analyzer page
    await compAnalyzer.goto();
Assert
  1. categorization radio “category” is checked
    await expect(compAnalyzer.categorizationRadio("category")).toBeChecked();
Act
  1. Select categorization “sub”
    await compAnalyzer.selectCategorization("sub");
Assert
  1. categorization radio “sub” is checked
    await expect(compAnalyzer.categorizationRadio("sub")).toBeChecked();
Act
  1. Select categorization “special”
    await compAnalyzer.selectCategorization("special");
Assert
  1. categorization radio “special” is checked
    await expect(compAnalyzer.categorizationRadio("special")).toBeChecked();
  2. categorization toggle is visible
    await expect(compAnalyzer.locators.categorizationToggle).toBeVisible();
Act
  1. Toggle weapon grid
    await compAnalyzer.toggleWeaponGrid();
Assert
  1. categorization toggle is not visible
    await expect(compAnalyzer.locators.categorizationToggle).not.toBeVisible();
Act
  1. Toggle weapon grid
    await compAnalyzer.toggleWeaponGrid();
Assert
  1. categorization toggle is visible
    await expect(compAnalyzer.locators.categorizationToggle).toBeVisible();
Act
  1. Select categorization “sub”
    await compAnalyzer.selectCategorization("sub");
Assert
  1. the page URL is /categorization=sub/
    await expect(page).toHaveURL(/categorization=sub/);
Act
  1. Reload the page
    await page.reload();
Assert
  1. categorization radio “sub” is checked
    await expect(compAnalyzer.categorizationRadio("sub")).toBeChecked();
Source
test("weapon grid controls and categorization", async ({ page }) => {
	const compAnalyzer = new CompAnalyzerPage(page);
	await compAnalyzer.goto();

	await expect(compAnalyzer.categorizationRadio("category")).toBeChecked();

	await compAnalyzer.selectCategorization("sub");
	await expect(compAnalyzer.categorizationRadio("sub")).toBeChecked();

	await compAnalyzer.selectCategorization("special");
	await expect(compAnalyzer.categorizationRadio("special")).toBeChecked();

	await expect(compAnalyzer.locators.categorizationToggle).toBeVisible();

	await compAnalyzer.toggleWeaponGrid();
	await expect(compAnalyzer.locators.categorizationToggle).not.toBeVisible();

	await compAnalyzer.toggleWeaponGrid();
	await expect(compAnalyzer.locators.categorizationToggle).toBeVisible();

	await compAnalyzer.selectCategorization("sub");
	await expect(page).toHaveURL(/categorization=sub/);

	await page.reload();

	await expect(compAnalyzer.categorizationRadio("sub")).toBeChecked();
})

analysis sections appear and can be collapsed

Renders/comp-analyzer

LOLogged out
Comp analyzer page
Act
  1. Open the comp analyzer page
    await compAnalyzer.goto();
Arrange
  1. damageCombos = damage combos
    const damageCombos = compAnalyzer.damageCombos;
Assert
  1. damageCombos.root is not visible
    await expect(damageCombos.root).not.toBeVisible();
  2. range visualization is not visible
    await expect(compAnalyzer.locators.rangeVisualization).not.toBeVisible();
Act
  1. 210 is a blaster, which has range data

    Select weapon 40
    await compAnalyzer.selectWeapon(40);
  2. Select weapon 210
    await compAnalyzer.selectWeapon(210);
Assert
  1. damageCombos.root is visible
    await expect(damageCombos.root).toBeVisible();
  2. range visualization is visible
    await expect(compAnalyzer.locators.rangeVisualization).toBeVisible();
  3. damageCombos.content is visible
    await expect(damageCombos.content).toBeVisible();
Act
  1. Toggle collapsed
    await damageCombos.toggleCollapsed();
Assert
  1. damageCombos.content is not visible
    await expect(damageCombos.content).not.toBeVisible();
Act
  1. Toggle collapsed
    await damageCombos.toggleCollapsed();
Assert
  1. damageCombos.content is visible
    await expect(damageCombos.content).toBeVisible();
Source
test("analysis sections appear and can be collapsed", async ({ page }) => {
	const compAnalyzer = new CompAnalyzerPage(page);
	await compAnalyzer.goto();

	const damageCombos = compAnalyzer.damageCombos;

	await expect(damageCombos.root).not.toBeVisible();
	await expect(compAnalyzer.locators.rangeVisualization).not.toBeVisible();

	// 210 is a blaster, which has range data
	await compAnalyzer.selectWeapon(40);
	await compAnalyzer.selectWeapon(210);

	await expect(damageCombos.root).toBeVisible();
	await expect(compAnalyzer.locators.rangeVisualization).toBeVisible();

	await expect(damageCombos.content).toBeVisible();

	await damageCombos.toggleCollapsed();
	await expect(damageCombos.content).not.toBeVisible();

	await damageCombos.toggleCollapsed();
	await expect(damageCombos.content).toBeVisible();
})

damage combo sliders and filtering work correctly

Renders/comp-analyzer

LOLogged out
Comp analyzer page
Act
  1. Open the comp analyzer page
    await compAnalyzer.goto();
  2. Splattershot Jr. has Splat Bomb sub

    Select weapon 10
    await compAnalyzer.selectWeapon(10);
  3. Select weapon 40
    await compAnalyzer.selectWeapon(40);
Arrange
  1. damageCombos = damage combos
    const damageCombos = compAnalyzer.damageCombos;
Assert
  1. damageCombos.root is visible
    await expect(damageCombos.root).toBeVisible();
Act
  1. All text contents → initialDamageValues
    const initialDamageValues =
    	await damageCombos.damageValues.allTextContents();
  2. Fill damageCombos.subDefenseSlider with “57”
    await damageCombos.subDefenseSlider.fill("57");
  3. All text contents → newDamageValues
    const newDamageValues = await damageCombos.damageValues.allTextContents();
Assert
  1. initialDamageValues.join(",") does not equal newDamageValues.join(",")
    expect(initialDamageValues.join(",")).not.toEqual(
    	newDamageValues.join(","),
    );
Act
  1. Fill damageCombos.subDefenseSlider with “0”
    await damageCombos.subDefenseSlider.fill("0");
  2. All text contents → initialInkTimes
    const initialInkTimes = await damageCombos.inkTimes.allTextContents();
  3. Fill damageCombos.inkResistanceSlider with “57”
    await damageCombos.inkResistanceSlider.fill("57");
  4. All text contents → newInkTimes
    const newInkTimes = await damageCombos.inkTimes.allTextContents();
Assert
  1. ink resistance makes ink times longer or reveals more ink combos

    If initialInkTimes.length > 0 || newInkTimes.length > 0
    if (initialInkTimes.length > 0 || newInkTimes.length > 0) {
    	const initialTotalFrames = initialInkTimes.reduce(
    		(sum, t) => sum + (Number.parseInt(t, 10) || 0),
    		0,
    	);
    	const newTotalFrames = newInkTimes.reduce(
    		(sum, t) => sum + (Number.parseInt(t, 10) || 0),
    		0,
    	);
    	expect(newTotalFrames).toBeGreaterThanOrEqual(initialTotalFrames);
    }
    1. initialTotalFrames = initialInkTimes.reduce( (sum, t) => sum + (Number.parseInt(t, 10) || 0), 0, )
      const initialTotalFrames = initialInkTimes.reduce(
      	(sum, t) => sum + (Number.parseInt(t, 10) || 0),
      	0,
      );
    2. newTotalFrames = newInkTimes.reduce( (sum, t) => sum + (Number.parseInt(t, 10) || 0), 0, )
      const newTotalFrames = newInkTimes.reduce(
      	(sum, t) => sum + (Number.parseInt(t, 10) || 0),
      	0,
      );
    3. newTotalFrames be greater than or equal initialTotalFrames
      expect(newTotalFrames).toBeGreaterThanOrEqual(initialTotalFrames);
Arrange
  1. firstDamageTypeLabel = damageCombos.damageTypeLabels.first()
    const firstDamageTypeLabel = damageCombos.damageTypeLabels.first();
Act
  1. Text content → damageTypeText
    const damageTypeText = await firstDamageTypeLabel.textContent();
Assert
  1. damageCombos.filteredItems count is 0
    await expect(damageCombos.filteredItems).toHaveCount(0);
Act
  1. Click firstDamageTypeLabel
    await firstDamageTypeLabel.click();
  2. Count → filteredCount
    const filteredCount = await damageCombos.filteredItems.count();
Assert
  1. filteredCount is more than 0
    expect(filteredCount).toBeGreaterThan(0);
  2. damageCombos.filteredItems.first() contains damageTypeText ?? ""
    await expect(damageCombos.filteredItems.first()).toContainText(
    	damageTypeText ?? "",
    );
Act
  1. Click damageCombos.filteredItems.first()
    await damageCombos.filteredItems.first().click();
Assert
  1. damageCombos.filteredItems count is filteredCount - 1
    await expect(damageCombos.filteredItems).toHaveCount(filteredCount - 1);
Source
test("damage combo sliders and filtering work correctly", async ({
	page,
}) => {
	const compAnalyzer = new CompAnalyzerPage(page);
	await compAnalyzer.goto();

	// Splattershot Jr. has Splat Bomb sub
	await compAnalyzer.selectWeapon(10);
	await compAnalyzer.selectWeapon(40);

	const damageCombos = compAnalyzer.damageCombos;
	await expect(damageCombos.root).toBeVisible();

	const initialDamageValues =
		await damageCombos.damageValues.allTextContents();

	await damageCombos.subDefenseSlider.fill("57");

	const newDamageValues = await damageCombos.damageValues.allTextContents();
	expect(initialDamageValues.join(",")).not.toEqual(
		newDamageValues.join(","),
	);

	await damageCombos.subDefenseSlider.fill("0");

	const initialInkTimes = await damageCombos.inkTimes.allTextContents();

	await damageCombos.inkResistanceSlider.fill("57");

	const newInkTimes = await damageCombos.inkTimes.allTextContents();

	// ink resistance makes ink times longer or reveals more ink combos
	if (initialInkTimes.length > 0 || newInkTimes.length > 0) {
		const initialTotalFrames = initialInkTimes.reduce(
			(sum, t) => sum + (Number.parseInt(t, 10) || 0),
			0,
		);
		const newTotalFrames = newInkTimes.reduce(
			(sum, t) => sum + (Number.parseInt(t, 10) || 0),
			0,
		);
		expect(newTotalFrames).toBeGreaterThanOrEqual(initialTotalFrames);
	}

	const firstDamageTypeLabel = damageCombos.damageTypeLabels.first();
	const damageTypeText = await firstDamageTypeLabel.textContent();

	await expect(damageCombos.filteredItems).toHaveCount(0);

	await firstDamageTypeLabel.click();

	const filteredCount = await damageCombos.filteredItems.count();
	expect(filteredCount).toBeGreaterThan(0);

	await expect(damageCombos.filteredItems.first()).toContainText(
		damageTypeText ?? "",
	);

	await damageCombos.filteredItems.first().click();
	await expect(damageCombos.filteredItems).toHaveCount(filteredCount - 1);
})