Skip to content

Commit 38c1e5a

Browse files
author
Jarosław Żołnowski
committed
feat(test): add playwright configuration and e2e tests (#4)
- add tests for index, test-component, and test-directive - add prettier as dev-dependency, reorder imports, restructure gitignore - add a separate section for idea and playwright files and folders - fix ASP.NET error when running the app - add npm-check to the devDeps - fix lint issues
1 parent 4a9f427 commit 38c1e5a

File tree

12 files changed

+3193
-32
lines changed

12 files changed

+3193
-32
lines changed

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ bld/
3535

3636
# Visual Studio 2015/2017 cache/options directory
3737
.vs/
38-
.idea
38+
3939
# Uncomment if you have tasks that create the project's static files in wwwroot
4040
#wwwroot/
4141

42+
# WebStorm cache/options directory
43+
.idea
44+
4245
# Visual Studio 2017 auto generated files
4346
Generated\ Files/
4447

@@ -121,6 +124,10 @@ ipch/
121124

122125
# Visual Studio Trace Files
123126
*.e2e
127+
# Playwright e2e tests
128+
/test-results/
129+
/playwright-report/
130+
/playwright/.cache/
124131

125132
# TFS 2012 Local Workspace
126133
$tf/

Views/Landing/Index.cshtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
@Scripts.Render("~/bundles/scripts")
2020
</head>
2121
<body ng-app="app">
22-
<h1>XLTS for AngularJS with .NET Framework</h1>
22+
<h1 data-testid="title">XLTS for AngularJS with .NET Framework</h1>
2323
<test-directive></test-directive>
2424
<test-component></test-component>
2525
</body>

WebApp/Components/test.component.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
angular.module('app').component('testComponent', {
22
controllerAs: 'vm',
33
controller: TestComponent,
4-
template: '<div class="test-component">AngularJS Version: {{vm.version}}</div>',
4+
template: '<div data-testid="angularjs-version" class="test-component">AngularJS Version: {{vm.version}}</div>',
55
bindings: {},
66
});
77

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<div class="test-directive">jQuery Version: {{ vm.version }}</div>
1+
<div data-testid="jquery-version" class="test-directive">jQuery Version: {{ vm.version }}</div>

angularjs-asp-net48-mvc5.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,9 +148,9 @@
148148
<WebProjectProperties>
149149
<UseIIS>True</UseIIS>
150150
<AutoAssignPort>True</AutoAssignPort>
151-
<DevelopmentServerPort>50582</DevelopmentServerPort>
151+
<DevelopmentServerPort>0</DevelopmentServerPort>
152152
<DevelopmentServerVPath>/</DevelopmentServerVPath>
153-
<IISUrl>http://localhost:50582/</IISUrl>
153+
<IISUrl>http://localhost:51267/</IISUrl>
154154
<NTLMAuthentication>False</NTLMAuthentication>
155155
<UseCustomServer>False</UseCustomServer>
156156
<CustomServerUrl>

e2e/pages/index-page.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class IndexPage {
2+
page;
3+
title;
4+
5+
constructor(page) {
6+
this.page = page;
7+
this.title = page.getByTestId('title');
8+
}
9+
}

e2e/pages/test-component-page.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class TestComponentPage {
2+
page;
3+
angularjsVersion;
4+
5+
constructor(page) {
6+
this.page = page;
7+
this.angularjsVersion = page.getByTestId('angularjs-version');
8+
}
9+
}

e2e/pages/test-directive-page.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export class TestDirectivePage {
2+
page;
3+
jqueryVersion;
4+
5+
constructor(page) {
6+
this.page = page;
7+
this.jqueryVersion = page.getByTestId('jquery-version');
8+
}
9+
}

e2e/tests/app.e2e.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { expect, test } from '@playwright/test';
2+
import { IndexPage } from '../pages/index-page';
3+
import { TestComponentPage } from '../pages/test-component-page';
4+
import { TestDirectivePage } from '../pages/test-directive-page';
5+
6+
test.describe('angularjs-asp-net48-mvc5 app', () => {
7+
8+
test.beforeEach(async ({ page }) => {
9+
await page.goto('');
10+
});
11+
12+
test('Index', async ({ page }) => {
13+
const indexPage = new IndexPage(page);
14+
15+
await expect(indexPage.title).toHaveText('XLTS for AngularJS with .NET Framework');
16+
});
17+
18+
test('TestComponent', async ({ page }) => {
19+
const testComponentPage = new TestComponentPage(page);
20+
21+
await expect(testComponentPage.angularjsVersion).toHaveText('AngularJS Version: 1.8.2');
22+
});
23+
24+
test('TestDirective', async ({ page }) => {
25+
const testDirective = new TestDirectivePage(page);
26+
27+
await expect(testDirective.jqueryVersion).toHaveText('jQuery Version: 3.6.0');
28+
});
29+
});

0 commit comments

Comments
 (0)