Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tests): Use new e2e testing lib for imports + move some system-e2e tests to apps #16387

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8cfd178
Update Playwright version
Aug 6, 2024
d24425e
Add utils to testing/e2e lib
Oct 14, 2024
979d24a
Add .gitignore and @nx/playwright
Oct 14, 2024
2881992
Add mockoon mocks and cleanup in libs/testing/e2e
Oct 15, 2024
d4eca4b
Merge branch 'main' into feat/use-new-e2e-test-lib-imports
Oct 22, 2024
42cf9de
Fix yarn file after merging main
Oct 22, 2024
e3def33
chore: nx format:write update dirty files
andes-it Oct 22, 2024
360d052
Update
Oct 23, 2024
6478106
Merge branch 'main' into feat/use-new-e2e-test-lib-imports
Oct 24, 2024
0f9fa6c
Debug next config
AndesKrrrrrrrrrrr Oct 24, 2024
07a2373
Disable tracing
AndesKrrrrrrrrrrr Oct 24, 2024
10b0174
Return _something_ on liveness
AndesKrrrrrrrrrrr Oct 24, 2024
d9351c1
Not output from proxies
AndesKrrrrrrrrrrr Oct 24, 2024
f30955f
Replace proxies
AndesKrrrrrrrrrrr Oct 24, 2024
40621b6
Debug & stuff in bootstrap
AndesKrrrrrrrrrrr Oct 24, 2024
2c9d5ed
Debug & linting in infra-express-server
AndesKrrrrrrrrrrr Oct 24, 2024
9df5a01
Fewer use
AndesKrrrrrrrrrrr Oct 24, 2024
3177c6f
Revert scripts
AndesKrrrrrrrrrrr Oct 24, 2024
c6d442d
Merge branch 'main' into fix/nextjs-crash-startup
AndesKrrrrrrrrrrr Oct 24, 2024
58f4025
Revert almost all to main
AndesKrrrrrrrrrrr Oct 24, 2024
ae84746
Only keep handler error handling
AndesKrrrrrrrrrrr Oct 24, 2024
5759714
Re-add removed comments
AndesKrrrrrrrrrrr Oct 24, 2024
1f6e4a5
Update libs/infra-next-server/src/lib/health.ts
AndesKrrrrrrrrrrr Oct 24, 2024
e7351c8
Add Application System and Endorsement System
Nov 1, 2024
f0926a1
Revert yarn version
Nov 1, 2024
9b560fe
Merge branch 'main' into feat/use-new-e2e-test-lib-imports
Nov 1, 2024
b41538e
Yarn fixes after merge
Nov 1, 2024
2a73e65
chore: nx format:write update dirty files
andes-it Nov 1, 2024
53b5678
Update
Nov 12, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -98,3 +98,8 @@ apps/**/index.html

.nx/
.zed/

# E2E outputs
test-results/
playwright-report/
tmp-sessions/
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const devConfig = {
production: false,
environment: 'local',
name: 'local',
baseApiUrl: 'http://localhost:4444',
baseApiUrl: `http://localhost:9456`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Resolve inconsistent port numbers in development configuration

There's an inconsistency in the development configuration where two different ports are used for baseApiUrl:

  • Root level uses port 9456
  • templateApi.baseApiUrl uses port 4444

This could lead to confusion and potential issues if different parts of the application expect different ports.

Consider using the same port or environment variables for consistency:

const devConfig = {
  // ...
-  baseApiUrl: `http://localhost:9456`,
+  baseApiUrl: process.env.DEV_API_URL ?? 'http://localhost:9456',
  // ...
  templateApi: {
    // ...
-    baseApiUrl: 'http://localhost:4444',
+    baseApiUrl: process.env.DEV_API_URL ?? 'http://localhost:9456',
    // ...
  }
}

Also applies to: 26-26

audit: {
defaultNamespace: '@island.is/applications',
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
import {
test as base,
expect,
Page,
disableI18n,
disablePreviousApplications,
disableObjectKey,
session,
} from '@island.is/testing/e2e'

const homeUrl = '/umsoknir/andlatstilkynningar'

const applicationTest = base.extend<{ applicationPage: Page }>({
applicationPage: async ({ browser }, use) => {
const applicationContext = await session({
browser,
homeUrl,
phoneNumber: '0102399',
idsLoginOn: true,
})

const applicationPage = await applicationContext.newPage()
await disableObjectKey(applicationPage, 'existingApplication')
await disablePreviousApplications(applicationPage)
await disableI18n(applicationPage)
await applicationPage.goto(homeUrl)
await expect(applicationPage).toBeApplication()
await use(applicationPage)

await applicationPage.close()
await applicationContext.close()
},
})

applicationTest.describe('Announcement of Death', () => {
applicationTest('test', async ({ applicationPage }) => {
const page = applicationPage
await expect(page).toBeApplication()

// Custom continue button
const submitButton = page.getByRole('button', { name: 'Halda áfram' })
const nextButton = page.getByTestId('proceed')

// Data Providers
await page.getByTestId('agree-to-data-providers').click()
await page.getByTestId('proceed').click()

// Accept handling the announcement
await page.locator('input[value=continue]').click()
await submitButton.click()

// Relations screen
// TODO improve selectability in this screen
await page.locator('text=Veldu tengsl').click()
await page.locator('div:text("Systir")').click()
await page.locator('input[name=applicantPhone]').fill('500-5000')
await page.locator('input[name=applicantEmail]').fill('e@mail.com')
await nextButton.click()

// Other wills and prenup screen
await page.locator('label[for=knowledgeOfOtherWills-1]').click()
await nextButton.click()

// Heirs -> add a new heir
await page.getByText('Bæta við erfingja').click()
await page.getByLabel('Kennitala').last().fill('010130-5069')
await page.getByLabel('Tengsl').last().click()
await page.locator('div:text("Systir")').last().click()
await expect(page.getByLabel('Nafn').last()).not.toBeEmpty()
await nextButton.click()

// Assets
const foreignAssets = page.getByLabel('Eignir erlendis')
await foreignAssets.check()
await foreignAssets.uncheck()
await nextButton.click()

// Recipients of documents
const dropdowns = page.getByLabel('Enginn viðtakandi') //locator('label[for=certificateOfDeathAnnouncement]')
for (const dropdown of await dropdowns.all()) {
await dropdown.click()
await dropdown.getByText('Gervimaður').first().click()
}
await nextButton.click()

// Overview screen
await page.getByLabel('Upplýsingar').fill('test test þæö')
await page
.getByRole('button', { name: 'Staðfesta andlátstilkynningu' })
.click()

// Confirmation screen
await expect(
page.getByRole('heading', { name: 'Tilkynning móttekin' }),
).toBeVisible()
})
})
119 changes: 119 additions & 0 deletions apps/application-system/form/e2e/acceptance/car-recycling.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { carRecyclingMessages } from '@island.is/application/templates/car-recycling'
import {
test as base,
expect,
Page,
disableI18n,
disablePreviousApplications,
session,
label,
helpers,
} from '@island.is/testing/e2e'
import { coreMessages } from '@island.is/application/core'

const homeUrl = '/umsoknir/skilavottord'

const applicationTest = base.extend<{ applicationPage: Page }>({
applicationPage: async ({ browser }, use) => {
const applicationContext = await session({
browser,
homeUrl,
phoneNumber: '0102989',
idsLoginOn: true,
})

const applicationPage = await applicationContext.newPage()
await disablePreviousApplications(applicationPage)
await disableI18n(applicationPage)
await applicationPage.goto(homeUrl)
await expect(applicationPage).toBeApplication()
await use(applicationPage)

await applicationPage.close()
await applicationContext.close()
},
})

applicationTest.describe('Car recycling', () => {
applicationTest(
'Should be able to create application',
async ({ applicationPage }) => {
const page = applicationPage
const { proceed } = helpers(page)

await applicationTest.step('Agree to data providers', async () => {
await expect(
page.getByRole('heading', {
name: label(carRecyclingMessages.pre.externalDataSubSection),
}),
).toBeVisible()
await page.getByTestId('agree-to-data-providers').click()

await page
.getByRole('button', {
name: label(coreMessages.buttonNext),
})
.click()
})

await applicationTest.step('Unregister for recycling', async () => {
await expect(
page.getByRole('heading', {
name: label(carRecyclingMessages.cars.sectionTitle),
}),
).toBeVisible()

await page
.getByRole('region', {
name: label(carRecyclingMessages.cars.sectionTitle),
})
.getByRole('button', {
name: label(carRecyclingMessages.cars.recycle),
})
.first()
.click()
await expect(
page.getByRole('heading', {
name: label(carRecyclingMessages.cars.selectedTitle),
}),
).toBeVisible()

const mileage = page.getByRole('textbox', {
name: label(carRecyclingMessages.cars.mileage),
})

await mileage.selectText()
await mileage.type('12345')

await proceed()
})

await applicationTest.step('Submit application', async () => {
await expect(
page
.locator('form')
.getByRole('paragraph')
.filter({
hasText: label(carRecyclingMessages.review.confirmSectionTitle),
}),
).toBeVisible()
await page
.getByRole('button', {
name: label(carRecyclingMessages.review.confirmSectionTitle),
})
.click()
})

await applicationTest.step(
'Check that conclusion screen header is visible and proceed to view the application',
async () => {
await expect(
page.getByRole('heading', {
name: label(carRecyclingMessages.conclusionScreen.title),
}),
).toBeVisible()
},
)
},
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import { m } from '@island.is/application/templates/criminal-record/messages'
import {
test as base,
expect,
Page,
disableI18n,
session,
label,
createApplication,
} from '@island.is/testing/e2e'

const homeUrl = '/umsoknir/sakavottord'

const applicationTest = base.extend<{ applicationPage: Page }>({
applicationPage: async ({ browser }, use) => {
const applicationContext = await session({
browser,
homeUrl,
phoneNumber: '0103019',
idsLoginOn: true,
})

const applicationPage = await applicationContext.newPage()
await disableI18n(applicationPage)
await applicationPage.goto(homeUrl)
await use(applicationPage)

await applicationPage.close()
await applicationContext.close()
},
})

applicationTest.describe('Criminal record application payment test', () => {
applicationTest(
'Should be able to proceed through payment',
async ({ applicationPage }) => {
const page = applicationPage

const buttonStaðfesta = label(m.confirm)
const buttonBætaViðKorti = 'Bæta við korti'
const buttonGreiða = 'Greiða'
const buttonTextSubmit3DData = 'Submit 3D data'
const textGervimaðurAfríka = 'Gervimaður Afríka'
const textGreiðslaTókst = 'Greiðsla tókst'
const textUmsóknStaðfest = label(m.successTitle)
const textAfgreidd = label(m.actionCardDone)

await applicationTest.step(
'Create and proceed with application',
async () => {
await createApplication(page)
await page.getByTestId('agree-to-data-providers').check()
await page.getByTestId('proceed').click()
await expect(page.getByText(textGervimaðurAfríka)).toBeVisible()
},
)

await applicationTest.step('Confirm application', async () => {
await page.getByRole('button', { name: buttonStaðfesta }).click()
await page.waitForURL('https://uat.arkid.is/quickpay/card')
})

await applicationTest.step('Add a card', async () => {
await page.getByRole('button', { name: buttonBætaViðKorti }).click()
await page.getByPlaceholder('Nafn korthafa').fill('Valitortestfyrirtgr')
await page.getByPlaceholder('Kortanúmer').fill('2223000010246699')
await page.getByPlaceholder('Öryggiskóði').fill('123')

const date = new Date()
const month = String(date.getMonth() + 1).padStart(2, '0')
const year = String(date.getFullYear()).slice(-2)
await page.getByPlaceholder('MM/ÁÁ').fill(`${month}${year}`)
})

await applicationTest.step('Complete payment', async () => {
await page.getByRole('button', { name: buttonGreiða }).click()
await page.getByRole('button', { name: buttonTextSubmit3DData }).click()
await page.getByText(textGreiðslaTókst).isVisible()
})

await applicationTest.step(
'Verify payment completion on screen and overview',
async () => {
await page
.getByRole('heading', {
name: textUmsóknStaðfest,
})
.isVisible()

await page.goto(`${homeUrl}`, { waitUntil: 'networkidle' })
await page.getByTestId('application-card').first().isVisible()
expect(await page.getByText(textAfgreidd).first().isVisible()).toBe(
true,
)
},
)
},
)
})
Loading
Loading