-
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.
OY-4713 Lisätty end-to-end Playwright -testi
- Loading branch information
Showing
4 changed files
with
128 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { defineConfig } from '@playwright/test'; | ||
export default defineConfig({ | ||
use: { | ||
// All requests we send go to this API endpoint. | ||
baseURL: 'https://maksut-local.test:9000', | ||
/* | ||
extraHTTPHeaders: { | ||
// We set this header per GitHub guidelines. | ||
'Accept': 'application/vnd.github.v3+json', | ||
// Add authorization token to all requests. | ||
// Assuming personal access token available in the environment. | ||
'Authorization': `token ${process.env.API_TOKEN}`, | ||
}, | ||
*/ | ||
} | ||
}); |
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,69 @@ | ||
import { test, Page, expect, chromium } from '@playwright/test'; | ||
import { v4 as uuid } from 'uuid'; | ||
|
||
test.describe.configure({ mode: 'serial' }) | ||
|
||
let userPage: Page | ||
let apiPage: Page | ||
|
||
test.beforeAll(async () => { | ||
const browser = await chromium.launch({ headless: false, args: ['--disable-web-security'] }) | ||
const context = await browser.newContext({ ignoreHTTPSErrors: true }); | ||
userPage = await context.newPage(); | ||
apiPage = await context.newPage(); | ||
|
||
// kirjaudutaan ataruna sisään apiin | ||
await apiPage.goto( | ||
'/maksut/auth/cas?ticket=abc' | ||
); | ||
|
||
/* | ||
await page.route( | ||
'**!/lomake-editori/api/tarjonta/haku/1.2.246.562.29.00000000000000009710', | ||
async (route) => { | ||
await route.fulfill({ | ||
json: { yhteishaku: true, 'kohdejoukko-uri': 'haunkohdejoukko_11#1' }, | ||
}) | ||
} | ||
) | ||
*/ | ||
|
||
}) | ||
|
||
test.afterAll(async ({ request }) => { | ||
await userPage.close() | ||
}) | ||
|
||
test('Paytrail maksuflow', async ( { request } ) => { | ||
// luodaan ataruna uusi lasku | ||
await userPage.bringToFront() | ||
const newInvoice = await userPage.context().request.post(`/maksut/api/lasku-tutu`, { | ||
data: { | ||
"application-key": `${uuid()}`, | ||
"first-name": "test1", | ||
"last-name": "test1", | ||
"email": "[email protected]", | ||
"amount": "256", | ||
"due-date": "2030-03-03", | ||
"index": 1 | ||
} | ||
}); | ||
expect(newInvoice.ok()).toBeTruthy(); | ||
const json = await newInvoice.json() | ||
|
||
// mennään käyttäjänä maksusivulle | ||
await userPage.goto( | ||
`/maksut/?secret=${json.secret}&locale=fi` | ||
); | ||
|
||
// käynnistetään käyttäjänä maksuflow | ||
await userPage.getByRole('link', { name: 'Siirry maksamaan' }).click(); | ||
|
||
// maksetaan käyttäjänä | ||
await userPage.getByRole('img', { name: 'OP', exact: true }).click(); | ||
await userPage.getByRole('button', { name: 'OP', exact: true}).click(); | ||
|
||
// varmistetaan että ollaan käyttäjänä palattu maksuihin tehdyn maksun sivulle | ||
await expect(userPage).toHaveURL(`/maksut/?secret=${json.secret}&locale=fi`, { timeout: 20000 }); | ||
await expect(userPage.getByText("Maksettu", { exact: true })).toBeVisible(); | ||
}) |