Skip to content

Commit 07bb0c3

Browse files
Added Cypress E2E tests (#4759)
* added sample test * added workflow * added workflow - DDEV config * added workflow - DDEV config fix * cypress config * cypress test * config * test * test * tests * tests * tests * tests * tests * tests * tests * update * update * update * update * minor update * minor update * minor update * minor update * minor update * minor update * update * update * update * update * typo * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * update * workflow * workflow * workflow * workflow * workflow * workflow * workflow * .gitignore * .gitignore * test * test * revert test * workflow * added test * update * update * added pseudo test, ref #4741 * test apache/nginx - maybe useful to test .htaccess and nginx-config (?) --------- Co-authored-by: Colin Mollenhour <colin@mollenhour.com>
1 parent 099c66f commit 07bb0c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+1273
-12
lines changed

.cypress.config.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
module.exports = {
2-
e2e: {
3-
setupNodeEvents(on, config) {
4-
// implement node event listeners here
5-
},
6-
baseUrl: 'https://magento-lts.ddev.site'
7-
},
2+
e2e: {
3+
setupNodeEvents(on, config) {
4+
// implement node event listeners here
5+
},
6+
baseUrl: 'https://magento-lts.ddev.site',
7+
}
88
};

.github/labeler.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -934,4 +934,10 @@
934934
- any-glob-to-any-file: [
935935
.rector.php,
936936
.github/workflows/rector.yml
937-
]
937+
]
938+
939+
'cypress':
940+
- changed-files:
941+
- any-glob-to-any-file: [
942+
cypress/*
943+
]

.github/workflows/check-files.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ on:
3939
phpunit:
4040
description: "Count changed PHPUnit files"
4141
value: ${{ jobs.check.outputs.phpunit }}
42+
cypress:
43+
description: "Count changed Cypress files"
44+
value: ${{ jobs.check.outputs.cypress }}
4245
# Allow manually triggering the workflow.
4346
workflow_dispatch:
4447

@@ -59,6 +62,7 @@ jobs:
5962
phpstan: ${{ steps.changes-phpstan.outputs.phpstan }}
6063
phpunit-test: ${{ steps.changes-phpunit-test.outputs.phpunit-test }}
6164
phpunit: ${{ steps.changes-phpunit.outputs.phpunit }}
65+
cypress: ${{ steps.changes-cypress.outputs.cypress }}
6266

6367
steps:
6468
- name: Checkout code
@@ -194,3 +198,11 @@ jobs:
194198
count="$(grep -oE "**phpunit**" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
195199
echo "$count PHPUnit file(s) changed"
196200
echo "phpunit=$count" >> $GITHUB_OUTPUT
201+
202+
- name: Check if Cypress files changed
203+
id: changes-cypress
204+
if: steps.changed-files-specific.outputs.any_modified == 'true'
205+
run: |
206+
count="$(grep -oE "cypress/" <<< "${{ steps.changed-files-specific.outputs.all_modified_files }}" | wc -l)"
207+
echo "$count Cypress file(s) changed"
208+
echo "cypress=$count" >> $GITHUB_OUTPUT

.github/workflows/cypress.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Cypress
2+
3+
on:
4+
workflow_call:
5+
# Allow manually triggering the workflow.
6+
workflow_dispatch:
7+
8+
jobs:
9+
test:
10+
name: Cypress
11+
runs-on: [ubuntu-latest]
12+
strategy:
13+
matrix:
14+
webserver: ['apache-fpm', 'nginx-fpm']
15+
16+
steps:
17+
- uses: actions/checkout@v1
18+
- name: Setup DDEV
19+
uses: ddev/github-action-setup-ddev@v1
20+
with:
21+
autostart: false
22+
23+
# install DDEV configuration
24+
- run: ddev config --project-type=magento --php-version=8.1 --webserver-type=${{ matrix.webserver }}
25+
26+
# install composer dependencies
27+
- run: ddev composer install
28+
29+
# install openmage
30+
- run: ddev openmage-install -q
31+
32+
# install cypress-addon
33+
- run: ddev add-on get tyler36/ddev-cypress
34+
35+
# start ddev
36+
- run: ddev start
37+
38+
# run cypress
39+
- run: ddev cypress-run --config-file .cypress.config.js

.github/workflows/workflow.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,14 @@ jobs:
136136
needs.check.outputs.phpunit > 0 ||
137137
needs.check.outputs.workflow > 0
138138
uses: ./.github/workflows/phpunit.yml
139+
140+
cypress:
141+
name: Cypress E2E Tests
142+
needs: [check, php-cs-fixer]
143+
if: |
144+
needs.check.outputs.cypress > 0 ||
145+
needs.check.outputs.php > 0 ||
146+
needs.check.outputs.phtml > 0 ||
147+
needs.check.outputs.xml > 0 ||
148+
needs.check.outputs.workflow > 0
149+
uses: ./.github/workflows/cypress.yml

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,9 @@ app/etc/includes/ddev.xhgui.php
114114
# local development
115115
.localdev
116116

117+
# cypress
118+
cypress/screenshots/
119+
cypress/videos/
120+
117121
# rector
118122
.rector.result.cache

app/code/core/Mage/Adminhtml/Block/Widget/Container.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ public function getHeaderText()
253253
*/
254254
public function getHeaderCssClass()
255255
{
256-
return 'head-' . strtr($this->_controller, '_', '-');
256+
return 'icon-head head-' . strtr($this->_controller, '_', '-');
257257
}
258258

259259
/**

app/code/core/Mage/Sitemap/etc/system.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
<show_in_website>1</show_in_website>
4949
<show_in_store>1</show_in_store>
5050
<comment>Valid values range: from 0.0 to 1.0.</comment>
51-
<frontend_class>validate-number</frontend_class>
51+
<validate>required-entry validate-number validate-number-range number-range-0-1</validate>
5252
</priority>
5353
<lastmod translate="label">
5454
<label>Show lastmod</label>
@@ -85,7 +85,7 @@
8585
<show_in_website>1</show_in_website>
8686
<show_in_store>1</show_in_store>
8787
<comment>Valid values range: from 0.0 to 1.0.</comment>
88-
<frontend_class>validate-number</frontend_class>
88+
<validate>required-entry validate-number validate-number-range number-range-0-1</validate>
8989
</priority>
9090
<lastmod translate="label">
9191
<label>Show lastmod</label>
@@ -122,7 +122,7 @@
122122
<show_in_website>1</show_in_website>
123123
<show_in_store>1</show_in_store>
124124
<comment>Valid values range: from 0.0 to 1.0.</comment>
125-
<frontend_class>validate-number</frontend_class>
125+
<validate>required-entry validate-number validate-number-range number-range-0-1</validate>
126126
</priority>
127127
<lastmod translate="label">
128128
<label>Show lastmod</label>

app/design/adminhtml/default/default/template/system/config/tabs.phtml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
<?php $_iterator = 1; ?>
2929
<?php foreach ($_tab->getSections() as $_section): ?>
3030
<dd>
31-
<a href="<?php echo $_section->getUrl() ?>" class="<?php echo $_section->getClass() ?><?php if($_section->getId()==$this->getActiveSection()): ?> active<?php endif ?> <?php echo $_section->getIsLast()?'last':'' ?>">
31+
<a href="<?php echo $_section->getUrl() ?>" id="section-<?php echo $_section->getId() ?>" class="<?php echo $_section->getClass() ?><?php if($_section->getId()==$this->getActiveSection()): ?> active<?php endif ?> <?php echo $_section->getIsLast()?'last':'' ?>">
3232
<span <?php if($_tab->getId()==$this->getActiveTab()): ?>class="active"<?php endif ?>>
3333
<?php echo $_section->getLabel() ?>
3434
</span>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const route = cy.testRoutes.backend.catalog.categories
2+
3+
describe(`Checks admin system "${route.h3}"`, () => {
4+
beforeEach('Log in the user', () => {
5+
cy.adminLogIn();
6+
cy.adminGoToTestRoute(route);
7+
});
8+
9+
it(`tests classes and title`, () => {
10+
cy.adminTestRoute(route);
11+
});
12+
});

0 commit comments

Comments
 (0)