generated from NHSDigital/nhs-notify-repository-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
6da76a8
commit 6e01108
Showing
3 changed files
with
122 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Locator, type Page } from '@playwright/test'; | ||
import { TemplateMgmtBasePage } from './template-mgmt-base-page'; | ||
|
||
export class TemplateMgmtDeletePage extends TemplateMgmtBasePage { | ||
readonly goBackButton: Locator; | ||
|
||
readonly confirmButton: Locator; | ||
|
||
constructor(page: Page) { | ||
super(page); | ||
|
||
this.goBackButton = page.getByText('No, go back'); | ||
this.confirmButton = page.getByText('Yes, delete template'); | ||
} | ||
|
||
async loadPage(templateId: string) { | ||
await this.navigateTo(`/templates/delete-template/${templateId}`); | ||
} | ||
} |
100 changes: 100 additions & 0 deletions
100
tests/test-team/template-mgmt-component-tests/template-mgmt-delete-page.component.ts
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,100 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { TemplateMgmtDeletePage } from '../pages/template-mgmt-delete-page'; | ||
import { | ||
assertFooterLinks, | ||
assertGoBackLinkNotPresent, | ||
assertLoginLink, | ||
assertNotifyBannerLink, | ||
assertSkipToMainContent, | ||
} from './template-mgmt-common.steps'; | ||
import { TemplateStorageHelper } from '../helpers/template-storage-helper'; | ||
import { TemplateFactory } from '../helpers/template-factory'; | ||
|
||
const templates = { | ||
goBack: { | ||
...TemplateFactory.createEmailTemplate('delete-page-go-back'), | ||
name: 'delete-page-go-back-name', | ||
message: 'delete-page-go-back-message', | ||
subject: 'template-subject', | ||
}, | ||
confirm: { | ||
...TemplateFactory.createEmailTemplate('delete-page-confirm'), | ||
name: 'delete-page-confirm-name', | ||
message: 'delete-page-confirm-message', | ||
subject: 'template-subject', | ||
}, | ||
}; | ||
|
||
const extraTemplateIds: string[] = []; | ||
|
||
test.describe('Delete Template Page', () => { | ||
const templateStorageHelper = new TemplateStorageHelper( | ||
Object.values(templates) | ||
); | ||
|
||
test.beforeAll(async () => { | ||
await templateStorageHelper.seedTemplateData(); | ||
}); | ||
|
||
test.afterAll(async () => { | ||
await templateStorageHelper.deleteTemplateData(extraTemplateIds); | ||
}); | ||
|
||
test('should land on "Delete Template" page when navigating to "/delete-template" url', async ({ | ||
page, | ||
baseURL, | ||
}) => { | ||
const deleteTemplatePage = new TemplateMgmtDeletePage(page); | ||
|
||
await deleteTemplatePage.loadPage(templates.goBack.id); | ||
|
||
await expect(page).toHaveURL( | ||
`${baseURL}/templates/delete-template/${templates.goBack.id}` | ||
); | ||
await expect(deleteTemplatePage.pageHeader).toHaveText( | ||
`Are you sure you want to delete the template '${templates.goBack.name}'?` | ||
); | ||
}); | ||
|
||
test('common page tests', async ({ page, baseURL }) => { | ||
const props = { | ||
page: new TemplateMgmtDeletePage(page), | ||
id: templates.goBack.id, | ||
baseURL, | ||
}; | ||
|
||
await assertSkipToMainContent(props); | ||
await assertNotifyBannerLink(props); | ||
await assertFooterLinks(props); | ||
await assertLoginLink(props); | ||
await assertGoBackLinkNotPresent(props); | ||
}); | ||
|
||
test('should go back to manage-templates page with template still visible when "no" button selected', async ({ | ||
page, | ||
}) => { | ||
const deleteTemplatePage = new TemplateMgmtDeletePage(page); | ||
|
||
await deleteTemplatePage.loadPage(templates.goBack.id); | ||
|
||
await deleteTemplatePage.goBackButton.click(); | ||
|
||
await expect(page).toHaveURL('/templates/manage-templates'); | ||
|
||
await expect(page.getByText(templates.goBack.name)).toBeVisible(); | ||
}); | ||
|
||
test('should go back to manage-templates page with template no longer visible when "yes" button selected', async ({ | ||
page, | ||
}) => { | ||
const deleteTemplatePage = new TemplateMgmtDeletePage(page); | ||
|
||
await deleteTemplatePage.loadPage(templates.confirm.id); | ||
|
||
await deleteTemplatePage.confirmButton.click(); | ||
|
||
await expect(page).toHaveURL('/templates/manage-templates'); | ||
|
||
await expect(page.getByText(templates.confirm.name)).not.toBeVisible(); | ||
}); | ||
}); |
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