Skip to content

Commit 684a07e

Browse files
committed
Added environment file, fixtures and first test
1 parent 629e981 commit 684a07e

File tree

9 files changed

+128
-90
lines changed

9 files changed

+128
-90
lines changed

playwright/.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
# Change the URL to your running lowcoder instance
12
LOWCODER_BASE_URL=http://lowcoder.internal:3000

playwright/data/local/test-data.json

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"users": {
3+
"admin": {
4+
"credentials": {
5+
"username": "admin1@admin.com",
6+
"password": "admin1234"
7+
}
8+
}
9+
}
10+
}

playwright/fixtures.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

playwright/pages/login-page.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export class LoginPage {
1010
private readonly signUpLink: Locator;
1111

1212
constructor(public readonly page: Page) {
13+
this.page = page;
1314
this.emailInput = this.page.getByPlaceholder(/^Please enter your email$/);
1415
this.passwordInput = this.page.getByPlaceholder(/^Please enter your password$/);
1516
this.confirmPasswordInput = this.page.getByPlaceholder(/^Please Confirm Password$/);
@@ -19,6 +20,27 @@ export class LoginPage {
1920
this.signUpLink = this.page.getByRole('link', { name: 'Sign Up' });
2021
}
2122

23+
24+
/*
25+
26+
test('test', async ({ page }) => {
27+
await page.goto('http://localhost:3000/');
28+
await page.goto('http://localhost:3000/apps');
29+
await page.goto('http://localhost:3000/user/auth/login');
30+
await page.getByPlaceholder('Please enter your email').click();
31+
await page.getByPlaceholder('Please enter your email').fill('admin@admin.com');
32+
await page.getByRole('button', { name: 'Continue' }).click();
33+
await page.getByPlaceholder('Please enter your password').click();
34+
await page.getByPlaceholder('Please enter your password').fill('admin1234');
35+
await page.getByRole('button', { name: 'Sign In' }).click();
36+
await page.getByTitle('admin@admin.com', { exact: true }).click();
37+
await page.getByText('admin@admin.com', { exact: true }).click();
38+
await page.getByText('My Profile').click();
39+
});
40+
41+
*/
42+
43+
2244
async loadPage() {
2345
await this.page.goto('/user/auth/login');
2446
}

playwright/pages/signup-page.ts

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { type Page, type Locator, expect } from '@playwright/test';
2+
3+
export class SignUpPage {
4+
private txtEmail: Locator;
5+
private txtPassword: Locator;
6+
private txtConfirmPassword: Locator;
7+
private btnSignUp: Locator;
8+
9+
constructor(public page: Page) {
10+
this.page = page;
11+
this.txtEmail = this.page.getByPlaceholder(/^Please enter your email$/);
12+
this.txtPassword = this.page.getByPlaceholder(/^Please Enter Password$/);
13+
this.txtConfirmPassword = this.page.getByPlaceholder(/^Please Confirm Password$/);
14+
this.btnSignUp = this.page.getByRole('button', { name: 'Sign Up' });
15+
}
16+
17+
async Load() {
18+
await this.page.goto('/user/auth/register');
19+
}
20+
21+
async SignUp(username: string, password: string, repeatPassword: string) {
22+
/** Check that input descriptions are present and visible */
23+
await expect(this.page.locator('div').filter({ hasText: /^Sign Up$/ }), 'page header "Sign Up" is displayed').toBeVisible();
24+
await expect(this.page.getByText('Email:'), '"email" text input is displayed').toBeVisible();
25+
await expect(this.page.getByText('Password', { exact: true }), '"password" text input is displayed').toBeVisible();
26+
await expect(this.page.getByText('Confirm Password'), '"confirm password" text input is displayed').toBeVisible();
27+
await expect(this.page.getByText('I Have Read and Agree to the'), 'agree to ToS checkbox is displayed').toBeVisible();
28+
29+
// TODO: uncomment and add testId once it's added in frontend
30+
// await expect(this.page.getByTestId(''), 'agree to ToS checkbox is checked').toBeChecked();
31+
32+
/** Fill inputs and clicn sign up */
33+
await this.txtEmail.click();
34+
await this.txtEmail.fill(username);
35+
await this.txtPassword.click();
36+
await this.txtPassword.fill(password);
37+
await this.txtConfirmPassword.click();
38+
await this.txtConfirmPassword.fill(repeatPassword);
39+
await this.btnSignUp.click();
40+
}
41+
42+
async AssertWorkspaceCreated() {
43+
/** Acceptance criteria:
44+
* - new workspace opens walkthrough demo
45+
* - new workspace has no applications created yet
46+
*/
47+
await expect(this.page.getByText('Create App'), 'walkthrough demo title is displayed').toBeVisible();
48+
await expect(this.page.getByText('Welcome! Click \'App\' and'), 'walkthrough demo description is displayed').toBeVisible();
49+
await expect(this.page.getByLabel('Skip'), 'walkthrough demo "Skip" option is displayed').toBeVisible();
50+
await expect(this.page.getByText('You don\'t have any apps yet.'), 'workspace information about no apps is displayed').toBeVisible();
51+
52+
/**
53+
* Acceptance criteria:
54+
* - 'Query Library' link in left side menu is visible
55+
* - 'Data Sources' link in left side menu is visible
56+
* - 'Settings' link in left side menu is visible
57+
* - 'Trash' link in left side menu is visible
58+
*/
59+
await expect(this.page.getByText('Query Library'), 'Left menu "Query Library" is displayed').toBeVisible();
60+
await expect(this.page.getByText('Data Sources'), 'Left menu "Data Sources" is displayed').toBeVisible();
61+
await expect(this.page.getByText('Settings'), 'Left menu "Settings" is displayed').toBeVisible();
62+
await expect(this.page.getByText('Trash'), 'Left menu "Thrash" is displayed').toBeVisible();
63+
}
64+
65+
}

playwright/playwright.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,23 @@ export default defineConfig({
3737

3838
/* Configure projects for major browsers */
3939
projects: [
40+
/**
4041
{
4142
name: 'chromium',
4243
use: { ...devices['Desktop Chrome'] },
4344
},
4445
46+
**/
4547
{
4648
name: 'firefox',
4749
use: { ...devices['Desktop Firefox'] },
4850
},
49-
51+
/**
5052
{
5153
name: 'webkit',
5254
use: { ...devices['Desktop Safari'] },
5355
},
54-
56+
**/
5557
/* Test against mobile viewports. */
5658
// {
5759
// name: 'Mobile Chrome',

playwright/tests/01-signup-login-logout.spec.ts

Lines changed: 0 additions & 80 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { test, expect } from '../utils/fixtures';
2+
import testData from '../data/local/test-data.json';
3+
4+
test('TC01 - Sign up ( Admin )', async ({ signUpPage, page }) => {
5+
await signUpPage.SignUp(testData.users.admin.credentials.username, testData.users.admin.credentials.password, testData.users.admin.credentials.password);
6+
await signUpPage.AssertWorkspaceCreated();
7+
});

playwright/utils/fixtures.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { test as base } from '@playwright/test';
2+
import { SignUpPage } from '../pages/signup-page';
3+
4+
type LowcoderFixtures = {
5+
signUpPage: SignUpPage;
6+
};
7+
8+
export const test = base.extend<LowcoderFixtures>({
9+
signUpPage: async ({ page }, use) => {
10+
11+
// Set up the fixture.
12+
const signUpPage = new SignUpPage(page);
13+
await signUpPage.Load();
14+
15+
// Use the fixture value in the test.
16+
await use(signUpPage);
17+
},
18+
});
19+
export { expect } from '@playwright/test';

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy