|
| 1 | +import { test, expect } from '@playwright/test'; |
| 2 | +import { |
| 3 | + createAuthHelper, |
| 4 | + TestUser, |
| 5 | + testUsers, |
| 6 | +} from 'helpers/auth/cognito-auth-helper'; |
| 7 | +import { RoutingConfigStorageHelper } from 'helpers/db/routing-config-storage-helper'; |
| 8 | +import { RoutingConfigFactory } from 'helpers/factories/routing-config-factory'; |
| 9 | +import { |
| 10 | + assertFooterLinks, |
| 11 | + assertHeaderLogoLink, |
| 12 | + assertSignOutLink, |
| 13 | + assertSkipToMainContent, |
| 14 | +} from 'helpers/template-mgmt-common.steps'; |
| 15 | +import { RoutingMoveToProductionPage } from 'pages/routing/move-to-production-page'; |
| 16 | + |
| 17 | +const storageHelper = new RoutingConfigStorageHelper(); |
| 18 | + |
| 19 | +let user: TestUser; |
| 20 | + |
| 21 | +test.beforeAll(async () => { |
| 22 | + const authHelper = createAuthHelper(); |
| 23 | + user = await authHelper.getTestUser(testUsers.User1.userId); |
| 24 | +}); |
| 25 | + |
| 26 | +test.afterAll(async () => { |
| 27 | + await storageHelper.deleteSeeded(); |
| 28 | +}); |
| 29 | + |
| 30 | +test.describe('Create Message Plan Page', () => { |
| 31 | + test('common page tests', async ({ page, baseURL }) => { |
| 32 | + const routingConfig = |
| 33 | + RoutingConfigFactory.create(user).withTemplates('NHSAPP'); |
| 34 | + |
| 35 | + await storageHelper.seed([routingConfig.dbEntry]); |
| 36 | + |
| 37 | + const props = { |
| 38 | + page: new RoutingMoveToProductionPage(page), |
| 39 | + id: routingConfig.dbEntry.id, |
| 40 | + baseURL, |
| 41 | + }; |
| 42 | + |
| 43 | + await assertSkipToMainContent(props); |
| 44 | + await assertHeaderLogoLink(props); |
| 45 | + await assertFooterLinks(props); |
| 46 | + await assertSignOutLink(props); |
| 47 | + }); |
| 48 | + |
| 49 | + test('moves the message plan to production and redirects to list page', async ({ |
| 50 | + baseURL, |
| 51 | + page, |
| 52 | + }) => { |
| 53 | + const routingConfig = |
| 54 | + RoutingConfigFactory.create(user).withTemplates('NHSAPP'); |
| 55 | + |
| 56 | + storageHelper.seed([routingConfig.dbEntry]); |
| 57 | + |
| 58 | + const moveToProductionPage = new RoutingMoveToProductionPage(page); |
| 59 | + |
| 60 | + await moveToProductionPage.loadPage(routingConfig.dbEntry.id); |
| 61 | + |
| 62 | + await expect(page).toHaveURL( |
| 63 | + `${baseURL}/templates/message-plans/move-to-production/${routingConfig.dbEntry.id}` |
| 64 | + ); |
| 65 | + |
| 66 | + await moveToProductionPage.submitButton.click(); |
| 67 | + |
| 68 | + await expect(page).toHaveURL(`${baseURL}/templates/message-plans`); |
| 69 | + // TODO: CCM-11496 - assert status |
| 70 | + }); |
| 71 | + |
| 72 | + test('links to preview page for the message plan', async ({ |
| 73 | + baseURL, |
| 74 | + page, |
| 75 | + }) => { |
| 76 | + const routingConfig = |
| 77 | + RoutingConfigFactory.create(user).withTemplates('NHSAPP'); |
| 78 | + |
| 79 | + storageHelper.seed([routingConfig.dbEntry]); |
| 80 | + |
| 81 | + const moveToProductionPage = new RoutingMoveToProductionPage(page); |
| 82 | + |
| 83 | + await moveToProductionPage.loadPage(routingConfig.dbEntry.id); |
| 84 | + |
| 85 | + await expect(page).toHaveURL( |
| 86 | + `${baseURL}/templates/message-plans/move-to-production/${routingConfig.dbEntry.id}` |
| 87 | + ); |
| 88 | + |
| 89 | + await moveToProductionPage.previewLink.click(); |
| 90 | + |
| 91 | + await expect(page).toHaveURL( |
| 92 | + `${baseURL}/templates/message-plans/preview-message-plan/${routingConfig.dbEntry.id}` |
| 93 | + ); |
| 94 | + }); |
| 95 | + |
| 96 | + test('cancel button links to the message plan list page', async ({ |
| 97 | + baseURL, |
| 98 | + page, |
| 99 | + }) => { |
| 100 | + const routingConfig = |
| 101 | + RoutingConfigFactory.create(user).withTemplates('NHSAPP'); |
| 102 | + |
| 103 | + storageHelper.seed([routingConfig.dbEntry]); |
| 104 | + |
| 105 | + const moveToProductionPage = new RoutingMoveToProductionPage(page); |
| 106 | + |
| 107 | + await moveToProductionPage.loadPage(routingConfig.dbEntry.id); |
| 108 | + |
| 109 | + await expect(page).toHaveURL( |
| 110 | + `${baseURL}/templates/message-plans/move-to-production/${routingConfig.dbEntry.id}` |
| 111 | + ); |
| 112 | + |
| 113 | + await moveToProductionPage.cancelLink.click(); |
| 114 | + |
| 115 | + await expect(page).toHaveURL(`${baseURL}/templates/message-plans`); |
| 116 | + }); |
| 117 | +}); |
0 commit comments