Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/e2e-tests-conversion-to-…
Browse files Browse the repository at this point in the history
…playwright' into feature/e2e-tests-conversion-to-playwright

# Conflicts:
#	tests/Dfe.EarlyYearsQualification.E2ETests/playwright/tests/shared/processLogic.ts
  • Loading branch information
ThomasWhittington committed Jan 6, 2025
2 parents 1ef0f3f + 7ba56a4 commit b49f2e8
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/actions/run-playwright-e2e-tests/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ runs:
working-directory: ./tests/Dfe.EarlyYearsQualification.E2ETests/playwright
env:
CI: true
run: WEBAPP_URL="${{ inputs.webapp_url }}" AUTH_SECRET=${{ inputs.auth_secret }} DOMAIN="127.0.0.1" npx playwright test
run: WEBAPP_URL="http://localhost:3000" AUTH_SECRET=${{ inputs.auth_secret }} DOMAIN="localhost" npx playwright test
- uses: actions/upload-artifact@v4
if: ${{ !cancelled() }}
with:
Expand Down
6 changes: 3 additions & 3 deletions tests/Dfe.EarlyYearsQualification.E2ETests/playwright/.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
WEBAPP_URL={URL OF THE HOME PAGE}
AUTH_SECRET={PASSWORD FOR ENVIRONMENT}
DOMAIN={DOMAIN FOR COOKIE TO BE ADDED TO (when local: localhost)}
WEBAPP_URL='http://localhost:3000'
AUTH_SECRET=ABC
DOMAIN=localhost
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ import {defineConfig, devices} from '@playwright/test';
*/
require('dotenv').config();

const baseUrl = 'http://localhost:5025'

export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
Expand All @@ -30,14 +28,13 @@ export default defineConfig({
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: baseUrl,
baseURL: process.env.WEBAPP_URL,

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',

ignoreHTTPSErrors: true,
},
testMatch: '**/back-button.spec.ts',
/* Configure projects for major browsers */
projects: [
{
Expand Down Expand Up @@ -79,8 +76,8 @@ export default defineConfig({

/* Run your local dev server before starting the tests */
webServer: {
command: 'cd ../../../src/Dfe.EarlyYearsQualification.Web && dotnet run --project ./Dfe.EarlyYearsQualification.Web.csproj --UseMockContentful=true',
url: baseUrl,
command:`cd ../../../src/Dfe.EarlyYearsQualification.Web && dotnet run --urls "${process.env.WEBAPP_URL}" --project ./Dfe.EarlyYearsQualification.Web.csproj --UseMockContentful=true --ServiceAccess:Keys:0="${process.env.AUTH_SECRET}"`,
url: process.env.WEBAPP_URL,
reuseExistingServer: !process.env.CI,
},
});
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,15 @@ export async function authorise(context: BrowserContext) {
export async function startJourney(page: Page, context: BrowserContext) {
await authorise(context);
await page.goto("/", {waitUntil: 'domcontentloaded'});
console.log(await page.title());
console.log(await page.innerHTML('body'));
await context.addCookies([
{
name: 'auth-secret',
value: process.env.AUTH_SECRET,
path: '/',
domain: process.env.DOMAIN
}
]);
await page.goto("/", { waitUntil: 'domcontentloaded'});
await page.waitForFunction(() => document.title === "Start - Check an Early Years qualification")
//expect(await page.title()).toBe("Start - Check an Early Years qualification");
await expect(page.locator("#start-now-button")).toBeVisible();
Expand Down Expand Up @@ -62,6 +69,19 @@ export function checkHeaderValue(response: APIResponse, headerName: string, head

export function checkHeaderExists(response: APIResponse, headerName: string, shouldExist: boolean) {
expect(response.headers()[headerName]).toBeUndefined();
import {BrowserContext, Page, expect, APIResponse} from "@playwright/test";
export const cookiePreferencesCookieName = "cookies_preferences_set";
export const journeyCookieName = 'user_journey';

export async function authorise(context: BrowserContext) {
await setCookie(context, process.env.AUTH_SECRET, 'auth-secret');
}
export function checkText(page: any, locator: string, expectedText: string, contain: boolean = false) {
if (contain) {
expect(page.locator(locator)).toContainText(expectedText);
} else {
expect(page.locator(locator)).toHaveText(expectedText);
}
}

export async function whereWasTheQualificationAwarded(page: any, location: string) {
Expand Down

0 comments on commit b49f2e8

Please sign in to comment.