-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more tests and increase coverage
- Loading branch information
1 parent
a46c43c
commit 5b6c3b6
Showing
8 changed files
with
233 additions
and
16 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
23 changes: 23 additions & 0 deletions
23
.hass/config/www/home-assistant-secret-taps-configs/notifications-disabled.yaml
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,23 @@ | ||
enabled: true | ||
notification: false | ||
profiles: | ||
- user: Test | ||
secrets: | ||
- taps: | ||
- tap | ||
- double-tap | ||
- tap | ||
action: call-service | ||
service: input_boolean.toggle | ||
data: | ||
entity_id: input_boolean.my_switch | ||
- taps: | ||
- double-tap | ||
- tap | ||
- double-tap | ||
action: call-service | ||
service: input_boolean.toggle | ||
- taps: | ||
- double-tap | ||
- double-tap | ||
action: unknown-action |
23 changes: 23 additions & 0 deletions
23
.hass/config/www/home-assistant-secret-taps-configs/notifications-enabled.yaml
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,23 @@ | ||
enabled: true | ||
notification: true | ||
profiles: | ||
- user: Test | ||
secrets: | ||
- taps: | ||
- tap | ||
- double-tap | ||
- tap | ||
action: call-service | ||
service: input_boolean.toggle | ||
data: | ||
entity_id: input_boolean.my_switch | ||
- taps: | ||
- double-tap | ||
- tap | ||
- double-tap | ||
action: call-service | ||
service: input_boolean.toggle | ||
- taps: | ||
- double-tap | ||
- double-tap | ||
action: unknown-action |
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,144 @@ | ||
import { test, expect } from 'playwright-test-coverage'; | ||
import { CONFIG_FILES, SELECTORS } from './constants'; | ||
import { | ||
pageVisit, | ||
haConfigRequest, | ||
moveToHeader, | ||
tap, | ||
doubleTap | ||
} from './utilities'; | ||
|
||
const TOAST_FAILURE = 'Failed to call service input_boolean/toggle'; | ||
const VISIBILITY_OPTIONS = { timeout: 0 }; | ||
|
||
test.describe('Notifications disabled', () => { | ||
|
||
test.beforeAll(async () => { | ||
await haConfigRequest(CONFIG_FILES.NOTIFICATIONS_DISABLED); | ||
}); | ||
|
||
test('Successful action', async ({ page }) => { | ||
|
||
await pageVisit(page); | ||
|
||
await moveToHeader(page); | ||
await tap(page); | ||
await doubleTap(page); | ||
await tap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
const toast = page.locator(SELECTORS.TOAST); | ||
|
||
await expect(toast).not.toBeVisible(VISIBILITY_OPTIONS); | ||
|
||
await moveToHeader(page); | ||
await tap(page); | ||
await doubleTap(page); | ||
await tap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
await expect(toast).not.toBeVisible(VISIBILITY_OPTIONS); | ||
|
||
}); | ||
|
||
test('Unsuccessful action', async ({ page }) => { | ||
|
||
await pageVisit(page); | ||
|
||
await moveToHeader(page); | ||
await doubleTap(page); | ||
await tap(page); | ||
await doubleTap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
const toast = page.locator(SELECTORS.TOAST); | ||
|
||
await expect(toast).toBeVisible(); | ||
await expect(toast).toContainText(TOAST_FAILURE); | ||
|
||
}); | ||
|
||
test('Non-existent action', async ({ page }) => { | ||
|
||
await pageVisit(page); | ||
|
||
await moveToHeader(page); | ||
await doubleTap(page); | ||
await doubleTap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
await expect( | ||
page.locator(SELECTORS.TOAST) | ||
).not.toBeVisible(VISIBILITY_OPTIONS); | ||
|
||
}); | ||
|
||
}); | ||
|
||
test.describe('Notifications enabled', () => { | ||
|
||
test.beforeAll(async () => { | ||
await haConfigRequest(CONFIG_FILES.NOTIFICATIONS_ENABLED); | ||
}); | ||
|
||
test('Successful action', async ({ page }) => { | ||
|
||
await pageVisit(page); | ||
|
||
await moveToHeader(page); | ||
await tap(page); | ||
await doubleTap(page); | ||
await tap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
const toast = page.locator(SELECTORS.TOAST); | ||
|
||
await expect(toast).toBeVisible(); | ||
await expect(toast).toContainText('secret taps successfully executed!'); | ||
await expect(toast).not.toBeVisible(); | ||
|
||
await moveToHeader(page); | ||
await tap(page); | ||
await doubleTap(page); | ||
await tap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
await expect(toast).toBeVisible(); | ||
await expect(toast).toContainText('secret taps successfully executed!'); | ||
|
||
}); | ||
|
||
test('Unsuccessful action', async ({ page }) => { | ||
|
||
await pageVisit(page); | ||
|
||
await moveToHeader(page); | ||
await doubleTap(page); | ||
await tap(page); | ||
await doubleTap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
const toast = page.locator(SELECTORS.TOAST); | ||
|
||
await expect(toast).toBeVisible(); | ||
await expect(toast).toContainText(TOAST_FAILURE); | ||
|
||
}); | ||
|
||
test('Non-existent action', async ({ page }) => { | ||
|
||
await pageVisit(page); | ||
|
||
await moveToHeader(page); | ||
await doubleTap(page); | ||
await doubleTap(page); | ||
await page.waitForTimeout(1500); | ||
|
||
const toast = page.locator(SELECTORS.TOAST); | ||
|
||
await expect(toast).toBeVisible(); | ||
await expect(toast).toContainText('secret taps failed! Review your secret config!'); | ||
|
||
}); | ||
|
||
}); |
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