Update E2E workflow to use environment variables from config.env in test.e2e.yaml

This commit is contained in:
Simon Larsen 2024-04-26 18:46:10 +01:00
parent eaeb40ec49
commit 818f8cc421
No known key found for this signature in database
GPG Key ID: AB45983AA9C81CDE
9 changed files with 85 additions and 4 deletions

View File

@ -20,3 +20,9 @@ export const REGISTERED_USER_EMAIL: string =
env('E2E_TEST_REGISTERED_USER_EMAIL') || '';
export const REGISTERED_USER_PASSWORD: string =
env('E2E_TEST_REGISTERED_USER_PASSWORD') || '';
export const STATUS_PAGE_URL: URL | null = env(
'E2E_TEST_REGISTERED_USER_PASSWORD'
)
? URL.fromString(env('E2E_TEST_REGISTERED_USER_PASSWORD'))
: null;

View File

@ -0,0 +1,48 @@
import { test, expect, Page } from '@playwright/test';
import {
BASE_URL,
IS_USER_REGISTERED,
REGISTERED_USER_EMAIL,
REGISTERED_USER_PASSWORD,
} from '../../Config';
import URL from 'Common/Types/API/URL';
test.describe('Login', () => {
test('should be able to login', async ({ page }: {page: Page}) => {
if (!IS_USER_REGISTERED) {
// pass this test if the user is not registered
return;
}
// go to login page
await page.goto(
URL.fromString(BASE_URL.toString())
.addRoute('/accounts/')
.toString()
);
await page.locator('input[type="email"]').click();
await page
.locator('input[type="email"]')
.fill(REGISTERED_USER_EMAIL.toString());
await page.locator('input[type="email"]').press('Tab');
await page
.locator('input[type="password"]')
.fill(REGISTERED_USER_PASSWORD.toString());
await page.locator('input[type="password"]').press('Enter');
// wait for navigation with base url
await page.waitForURL(
URL.fromString(BASE_URL.toString())
.addRoute('/dashboard/welcome')
.toString()
);
expect(page.url()).toBe(
URL.fromString(BASE_URL.toString())
.addRoute('/dashboard/welcome')
.toString()
);
await page.getByTestId('create-new-project-button').click();
});
});

View File

@ -0,0 +1,18 @@
import { Page, test } from '@playwright/test';
import { STATUS_PAGE_URL } from '../../Config';
import URL from 'Common/Types/API/URL';
test.describe('Basic Status Page', () => {
test('should be able to load status page properly', async ({ page }: {page: Page}) => {
if (!STATUS_PAGE_URL) {
// pass this test if the user is not registered
return;
}
// go to login page
await page.goto(URL.fromString(STATUS_PAGE_URL.toString()).toString());
// check if data-testid is present with status-page-overview
await page.waitForSelector('[data-testid="status-page-overview"]'); // page loaded properly.
});
});

View File

@ -36,7 +36,7 @@ spec:
kubectl delete pod $pod -n $namespace
fi
done
restartPolicy: OnFailure
---

View File

@ -12,7 +12,7 @@ metadata:
app.kubernetes.io/managed-by: Helm
date: "{{ now | unixEpoch }}"
spec:
schedule: "*/5 * * * *" # At every 30 minute.
schedule: "*/30 * * * *" # At every 30 minute.
activeDeadlineSeconds: 3600 # 1 hour
jobTemplate:
spec:
@ -30,6 +30,8 @@ spec:
value: {{ $.Values.cronJobs.e2e.registeredUserEmail | quote }}
- name: E2E_TEST_REGISERED_USER_PASSWORD
value: {{ $.Values.cronJobs.e2e.registeredUserPassword | quote }}
- name: E2E_TEST_STATUS_PAGE_URL
value: {{ $.Values.cronJobs.e2e.statusPageUrl | quote }}
restartPolicy: Never
{{- end }}

View File

@ -204,4 +204,6 @@ cronJobs:
isUserRegistered: false
registeredUserEmail:
registeredUserPassword:
# This is the URL of the status page you want to test. This is used to check if the status page is up and running.
statusPageUrl:

View File

@ -729,7 +729,7 @@ const Overview: FunctionComponent<PageComponentProps> = (
{error ? <ErrorMessage error={error} /> : <></>}
{!isLoading && !error ? (
<div>
<div data-testid="status-page-overview">
{/* Overview Page Description */}
{statusPage && statusPage.overviewPageDescription && (
<div

View File

@ -197,6 +197,7 @@ LOG_LEVEL=ERROR
E2E_TEST_IS_USER_REGISTERED=false
E2E_TEST_USER_EMAIL=
E2E_TEST_USER_PASSWORD=
# If you want to run the E2E tests on a status page, then you need to fill in the URL.
E2E_TEST_STATUS_PAGE_URL=

View File

@ -342,6 +342,10 @@ services:
network_mode: host # This is needed to access the host network,
environment:
<<: *common-variables
E2E_TEST_IS_USER_REGISTERED: ${E2E_TEST_IS_USER_REGISTERED}
E2E_TEST_REGISERED_USER_EMAIL: ${E2E_TEST_REGISERED_USER_EMAIL}
E2E_TEST_REGISERED_USER_PASSWORD: ${E2E_TEST_REGISERED_USER_PASSWORD}
E2E_TEST_STATUS_PAGE_URL: ${E2E_TEST_STATUS_PAGE_URL}
logging:
driver: "local"
options: