running-tools

A collection of tools for runners and their coaches
git clone https://git.ashermorgan.net/running-tools/
Log | Files | Refs | README

commit 346ce417450319c09d36269aad7eb4f44975b084
parent b9cc28896bcd4de991568fcddc67f35859338766
Author: Asher Morgan <59518073+ashermorgan@users.noreply.github.com>
Date:   Sat, 31 May 2025 12:46:25 -0700

Update end-to-end tests

Diffstat:
Mtests/e2e/batch-calculator.spec.js | 6++++--
Mtests/e2e/cross-calculator.spec.js | 4+++-
Mtests/e2e/workout-calculator.spec.js | 9+++++++--
3 files changed, 14 insertions(+), 5 deletions(-)

diff --git a/tests/e2e/batch-calculator.spec.js b/tests/e2e/batch-calculator.spec.js @@ -2,7 +2,7 @@ import { test, expect } from '@playwright/test'; test('Batch calculator', async ({ page }) => { // Structure: - // - Test workout batch results, including modified prediction model + // - Test workout batch results, including modified prediction model and custom target names // - Test pace batch results, including modified default units // - Test race batch results, including modified Riegel exponent // - Reload page @@ -40,9 +40,10 @@ test('Batch calculator', async ({ page }) => { await expect(page.getByRole('row').nth(15).getByRole('cell')).toHaveCount(5); await expect(page.getByRole('row')).toHaveCount(16); - // Change prediction model + // Change prediction model and enable customized target names await page.getByText('Advanced Options').click(); await page.getByLabel('Prediction model').selectOption('Riegel\'s Model'); + await page.getByLabel('Target name customization').selectOption('Enabled'); // Assert workout results are correct await expect(page.getByRole('row').nth(0).getByRole('cell').nth(0)).toHaveText('2 mi'); @@ -160,6 +161,7 @@ test('Batch calculator', async ({ page }) => { // Assert workout results are correct (inputs and options not reset) await page.getByLabel('Calculator').selectOption('Workout Calculator'); + await expect(page.getByLabel('Target name customization')).toHaveValue("true"); await expect(page.getByRole('row').nth(0).getByRole('cell').nth(0)).toHaveText('2 mi'); await expect(page.getByRole('row').nth(0).getByRole('cell').nth(2)).toHaveText('800 m @ 5 km'); await expect(page.getByRole('row').nth(0).getByRole('cell')).toHaveCount(5); diff --git a/tests/e2e/cross-calculator.spec.js b/tests/e2e/cross-calculator.spec.js @@ -107,9 +107,10 @@ test('Cross-calculator', async ({ page }) => { await page.getByLabel('Input race duration minutes').fill('5'); await page.getByLabel('Input race duration seconds').fill('1'); - // Change prediction model + // Change prediction model and enable target name customization await page.getByText('Advanced Options').click(); await page.getByLabel('Prediction model').selectOption('V̇O₂ Max Model'); + await page.getByLabel('Target name customization').selectOption('Enabled'); // Change default units (should update on other calculators too) await page.getByLabel('Default units').selectOption('Kilometers'); @@ -145,6 +146,7 @@ test('Cross-calculator', async ({ page }) => { // Assert workout results are correct (new workout options loaded) await page.getByLabel('Calculator').selectOption('Workout Calculator'); + await expect(page.getByLabel('Target name customization')).toHaveValue("true"); await expect(page.getByRole('row').nth(0).getByRole('cell').nth(0)).toHaveText('2 mi'); await expect(page.getByRole('row').nth(0).getByRole('cell').nth(2)).toHaveText('800 m @ 5 km'); await expect(page.getByRole('row').nth(0).getByRole('cell')).toHaveCount(5); diff --git a/tests/e2e/workout-calculator.spec.js b/tests/e2e/workout-calculator.spec.js @@ -47,6 +47,7 @@ test('Workout Calculator', async ({ page }) => { // Edit default target set await page.getByRole('button', { name: 'Edit target set' }).click(); await page.getByLabel('Target set label').fill('Less-common Workout Targets'); + await expect(page.getByLabel('Custom target name')).toHaveCount(0); await page.getByLabel('Split distance value').nth(0).fill('401'); await page.getByLabel('Target distance value').nth(0).fill('2'); await page.getByRole('button', { name: 'Add distance target' }).click(); @@ -73,6 +74,9 @@ test('Workout Calculator', async ({ page }) => { await expect(page.getByRole('row').nth(7)).toHaveText('2 mi' + '10:30.00'); await expect(page.getByRole('row')).toHaveCount(8); + // Enable target name customization + await page.getByLabel('Target name customization').selectOption('Enabled'); + // Create custom target set await page.getByLabel('Selected target set').selectOption('[ Create New Target Set ]'); await expect(page.getByRole('row').nth(4)).toHaveText('There aren\'t any targets in this set yet.'); @@ -83,6 +87,7 @@ test('Workout Calculator', async ({ page }) => { await expect(page.getByLabel('Target set label')).toHaveValue('New target set'); await page.getByLabel('Target set label').fill('Workout Target Set #2'); await page.getByRole('button', { name: 'Add distance target' }).click(); + await page.getByLabel('Custom target name').last().fill('800m Interval'); await page.getByLabel('Split distance value').last().fill('800'); await page.getByLabel('Split distance unit').last().selectOption('Meters'); await page.getByLabel('Target distance value').last().fill('5'); @@ -95,7 +100,7 @@ test('Workout Calculator', async ({ page }) => { await page.getByRole('button', { name: 'Close' }).click(); // Assert workout splits are correct - await expect(page.getByRole('row').nth(1)).toHaveText('800 m @ 5 km' + '2:45.08'); + await expect(page.getByRole('row').nth(1)).toHaveText('800m Interval' + '2:45.08'); await expect(page.getByRole('row').nth(2)).toHaveText('1600 m @ 10 km' + '5:58.80'); await expect(page.getByRole('row')).toHaveCount(3); @@ -103,7 +108,7 @@ test('Workout Calculator', async ({ page }) => { await page.reload(); // Assert workout splits are correct (custom targets and model settings not reset) - await expect(page.getByRole('row').nth(1)).toHaveText('800 m @ 5 km' + '2:45.08'); + await expect(page.getByRole('row').nth(1)).toHaveText('800m Interval' + '2:45.08'); await expect(page.getByRole('row').nth(2)).toHaveText('1600 m @ 10 km' + '5:58.80'); await expect(page.getByRole('row')).toHaveCount(3);