-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #603 from alicolville/if-statement-tweaks
If statement tweaks
- Loading branch information
Showing
129 changed files
with
932 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import type { Page, Locator } from '@playwright/test'; | ||
import { expect } from '@playwright/test'; | ||
/** | ||
* This class is used by other tests to simulate Weight Tracker [wt] actions | ||
*/ | ||
|
||
export class WeightTracker { | ||
|
||
constructor(public readonly page: Page) { | ||
} | ||
|
||
async goto() { | ||
await this.page.goto('http://localhost/weight-tracker/'); | ||
} | ||
|
||
async weight_set_defaults(){ | ||
await this.goto(); | ||
await this.weight_clear_all(); | ||
await this.weight_add( '01/01/2019', '200' ); | ||
} | ||
|
||
async weight_add( date, weight){ | ||
await this.goto(); | ||
await this.page.getByTestId('wt-tab-add-edit').click(); | ||
await this.page.getByTestId('we-ls-date').fill(date); | ||
await this.page.getByTestId('wt-tab-add-edit').click(); | ||
await this.page.getByTestId('ws-form-weight').fill(weight); | ||
await this.page.getByRole('button', { name: 'Save Entry' }).click(); | ||
} | ||
|
||
async weight_clear_all(){ | ||
await this.goto(); | ||
await this.page.getByTestId('wt-tab-settings').click(); | ||
await this.page.getByLabel('The button below allows you').selectOption('yes'); | ||
await this.page.getByRole('button', { name: 'Delete' }).click(); | ||
await expect(this.page.locator('#wp--skip-link--target')).toContainText('Your data has successfully been deleted.'); | ||
} | ||
|
||
async target_set(target){ | ||
await this.goto(); | ||
await this.page.getByRole('link', { name: 'Adjust' }).click(); | ||
await this.page.getByTestId('ws-form-target').click(); | ||
await this.page.getByTestId('ws-form-target').fill( target); | ||
await this.page.getByRole('button', { name: 'Set Target' }).click(); | ||
} | ||
|
||
async target_clear(){ | ||
await this.goto(); | ||
await this.page.getByTestId('wt-tab-settings').click(); | ||
|
||
const visible = await this.page.getByRole('button', { name: 'Clear Target' }).isVisible(); | ||
|
||
if (visible) { | ||
this.page.on('dialog', dialog => dialog.accept()); | ||
await this.page.getByRole('button', { name: 'Clear Target' }).click(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { test as base, expect } from '@playwright/test'; | ||
import { WeightTracker } from './weight-tracker'; | ||
|
||
|
||
const test = base.extend<{ weightTracker: WeightTracker }>({ | ||
weightTracker: async ({ page }, use) => { | ||
|
||
// Clear all weight entries and add a start weight. | ||
const weightTracker = new WeightTracker(page); | ||
|
||
await weightTracker.weight_set_defaults(); | ||
await use(weightTracker); | ||
}, | ||
}); | ||
|
||
test.describe.configure( { mode: 'serial' } ); | ||
|
||
test('wt-if difference from start', async ({ weightTracker, page }) => { | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: no'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: no'); | ||
await expect(page.locator('.less-than')).toContainText('less than: no'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: no'); | ||
await expect(page.locator('.equals')).toContainText('equals: no'); | ||
|
||
await weightTracker.weight_add( '11/01/2024', '213' ); | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: no'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: no'); | ||
await expect(page.locator('.less-than')).toContainText('less than: yes'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: yes'); | ||
await expect(page.locator('.equals')).toContainText('equals: no'); | ||
|
||
await weightTracker.weight_add( '11/01/2024', '214' ); | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: no'); | ||
|
||
await weightTracker.weight_add( '11/02/2024', '250' ); | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: no'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: no'); | ||
await expect(page.locator('.less-than')).toContainText('less than: no'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: no'); | ||
await expect(page.locator('.equals')).toContainText('equals: yes'); | ||
|
||
await weightTracker.weight_add( '11/03/2024', '280' ); | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: no'); | ||
|
||
await weightTracker.weight_add( '11/04/2024', '281' ); | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: yes'); | ||
|
||
await weightTracker.weight_add( '11/04/2024', '290' ); | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: yes'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: yes'); | ||
await expect(page.locator('.less-than')).toContainText('less than: no'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: no'); | ||
await expect(page.locator('.equals')).toContainText('equals: no'); | ||
|
||
await weightTracker.weight_add( '11/04/2024', '289' ); | ||
|
||
await page.goto('http://localhost/if-statements/difference-from-start/'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: no'); | ||
|
||
await weightTracker.weight_set_defaults(); | ||
|
||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { test as base, expect } from '@playwright/test'; | ||
import { WeightTracker } from './weight-tracker'; | ||
|
||
|
||
const test = base.extend<{ weightTracker: WeightTracker }>({ | ||
weightTracker: async ({ page }, use) => { | ||
|
||
// Clear all weight entries and add a start weight. | ||
const weightTracker = new WeightTracker(page); | ||
|
||
await weightTracker.weight_set_defaults(); | ||
await use(weightTracker); | ||
}, | ||
}); | ||
|
||
test('basic tests', async ({ weightTracker, page }) => { | ||
|
||
await page.goto('http://localhost/if-statements/number-of-days/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: no'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: no'); | ||
await expect(page.locator('.less-than')).toContainText('less than: yes'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: yes'); | ||
await expect(page.locator('.equals')).toContainText('equals: no'); | ||
|
||
await weightTracker.weight_add( '11/01/2019', '300' ); | ||
|
||
await page.goto('http://localhost/if-statements/number-of-days/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: no'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: no'); | ||
await expect(page.locator('.less-than')).toContainText('less than: yes'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: yes'); | ||
await expect(page.locator('.equals')).toContainText('equals: yes'); | ||
|
||
await weightTracker.weight_add( '16/01/2019', '200' ); | ||
|
||
await page.goto('http://localhost/if-statements/number-of-days/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: yes'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: yes'); | ||
await expect(page.locator('.less-than')).toContainText('less than: yes'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: yes'); | ||
await expect(page.locator('.equals')).toContainText('equals: no'); | ||
|
||
await weightTracker.weight_add( '26/01/2019', '200' ); | ||
|
||
await page.goto('http://localhost/if-statements/number-of-days/'); | ||
await expect(page.locator('.greater-than')).toContainText('greater than: yes'); | ||
await expect(page.locator('.greater-than-or-equal-to')).toContainText('greater than or equal to: yes'); | ||
await expect(page.locator('.less-than')).toContainText('less than: no'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: yes'); | ||
await expect(page.locator('.equals')).toContainText('equals: no'); | ||
|
||
await weightTracker.weight_add( '26/02/2019', '200' ); | ||
|
||
await page.goto('http://localhost/if-statements/number-of-days/'); | ||
await expect(page.locator('.less-than-or-equal-to')).toContainText('less than or equal to: no'); | ||
|
||
await weightTracker.weight_set_defaults(); | ||
|
||
}); |
Oops, something went wrong.