Skip to content

Commit c56fbbb

Browse files
committed
Make tests on all env
1 parent 35597c5 commit c56fbbb

File tree

5 files changed

+84
-20
lines changed

5 files changed

+84
-20
lines changed

.github/workflows/tests.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,30 @@ jobs:
2828
uses: actions/setup-node@v1
2929
- name: Install dependencies
3030
run: yarn --dev && yarn --cwd ./playground
31-
- name: Cypress run
31+
- name: Test develop no-reload
3232
uses: cypress-io/github-action@v2
3333
with:
3434
build: yarn playground:build
3535
start: yarn playground:start
3636
env: env=ci
37+
- name: Test develop admin watch
38+
uses: cypress-io/github-action@v2
39+
with:
40+
build: yarn playground:build
41+
start: yarn playground:dev
42+
env: env=watch
43+
- name: Test develop soft watch
44+
uses: cypress-io/github-action@v2
45+
with:
46+
build: yarn playground:build
47+
start: yarn playground:dev
48+
env: env=develop
49+
- name: Test production
50+
uses: cypress-io/github-action@v2
51+
with:
52+
build: yarn playground:build
53+
start: yarn playground:dev
54+
env: env=ci
3755
- uses: actions/upload-artifact@v1
3856
if: failure()
3957
with:

cypress.env.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@
1212
"adminUrl": "http://localhost:8000/admin/auth/login",
1313
"host": "http://localhost:7700"
1414
},
15+
"develop": {
16+
"adminUrl": "http://localhost:1337/admin/auth/login",
17+
"host": "http://localhost:7700"
18+
},
1519
"ci": {
1620
"adminUrl": "http://localhost:1337/admin/auth/login",
1721
"host": "http://meilisearch:7700"

cypress/integration/ui_spec.js

Lines changed: 55 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,22 @@ const removeTutorial = () => {
1313
cy.get('.videosContent').siblings('.openBtn').click()
1414
}
1515

16-
const clickAndCheckRowContent = (rowNumber, contains) => {
17-
const row = `.collections tbody tr:nth-child(${rowNumber})`
16+
const clickCollection = ({ rowNb }) => {
17+
const row = `.collections tbody tr:nth-child(${rowNb})`
1818
cy.get(`${row} input[type="checkbox"]`).click()
1919
removeNotifications()
20+
}
21+
22+
const checkCollectionContent = ({ rowNb, contains }) => {
23+
const row = `.collections tbody tr:nth-child(${rowNb})`
2024
contains.map(content => cy.get(`${row}`).contains(content))
2125
}
2226

27+
const clickAndCheckRowContent = ({ rowNb, contains }) => {
28+
clickCollection({ rowNb })
29+
checkCollectionContent({ rowNb, contains })
30+
}
31+
2332
const removeNotifications = () => {
2433
cy.wait(1000)
2534
cy.get('.notification-enter-done > div > div > div:last-child').click({
@@ -80,32 +89,59 @@ describe('Strapi Login flow', () => {
8089
})
8190

8291
it('Add Collections to MeiliSearch', () => {
83-
clickAndCheckRowContent(1, ['Indexed In MeiliSearch', 'Reload needed'])
84-
clickAndCheckRowContent(2, ['Indexed In MeiliSearch', 'Reload needed'])
85-
clickAndCheckRowContent(3, ['Indexed In MeiliSearch', 'Reload needed'])
92+
clickAndCheckRowContent({
93+
rowNb: 1,
94+
contains: ['Indexed In MeiliSearch', 'Reload needed']
95+
})
96+
clickAndCheckRowContent({
97+
rowNb: 2,
98+
contains: ['Indexed In MeiliSearch', 'Reload needed']
99+
})
100+
clickAndCheckRowContent({
101+
rowNb: 3,
102+
contains: ['Indexed In MeiliSearch', 'Reload needed']
103+
})
86104
})
87105

88106
it('Reload Server', () => {
89107
const row = '.reload_button'
90108
cy.get(`${row}`).click()
91-
if (env === 'watch') {
92-
cy.wait(4000)
93-
cy.visit(adminUrl, { timeout: 4000 })
94-
cy.url().should('match', /login/)
95-
cy.get('form', { timeout: 10000 }).should('be.visible')
96-
cy.get('input[name="email"]').type(email).should('have.value', email)
97-
cy.get('input[name="password"]').type(password).should('have.value', password)
98-
cy.get('button[type="submit"]').click()
99-
cy.contains('MeiliSearch', { timeout: 10000 }).click()
100-
cy.url().should('include', '/plugins/meilisearch')
109+
cy.wait(4000)
110+
if (env === 'develop' || env === 'watch') {
111+
removeTutorial()
112+
}
113+
})
114+
115+
it('Check for successfull hooks in develop mode', () => {
116+
if (env === 'develop' || env === 'watch') {
117+
checkCollectionContent({ rowNb: 1, contains: ['Indexed In MeiliSearch', 'Active'] })
118+
checkCollectionContent({ rowNb: 2, contains: ['Indexed In MeiliSearch', 'Active'] })
119+
checkCollectionContent({ rowNb: 3, contains: ['Indexed In MeiliSearch', 'Active'] })
120+
} else {
121+
checkCollectionContent({ rowNb: 1, contains: ['Indexed In MeiliSearch', 'Reload needed'] })
122+
checkCollectionContent({ rowNb: 2, contains: ['Indexed In MeiliSearch', 'Reload needed'] })
123+
checkCollectionContent({ rowNb: 3, contains: ['Indexed In MeiliSearch', 'Reload needed'] })
101124
}
102-
removeTutorial()
103125
})
104126

105127
it('Remove Collections from MeiliSearch', () => {
106-
clickAndCheckRowContent(1, ['Not in MeiliSearch'])
107-
clickAndCheckRowContent(2, ['Not in MeiliSearch'])
108-
clickAndCheckRowContent(3, ['Not in MeiliSearch'])
128+
clickAndCheckRowContent({
129+
rowNb: 1,
130+
contains: ['Not in MeiliSearch']
131+
})
132+
clickAndCheckRowContent({
133+
rowNb: 2,
134+
contains: ['Not in MeiliSearch']
135+
})
136+
clickAndCheckRowContent({
137+
rowNb: 3,
138+
contains: ['Not in MeiliSearch']
139+
})
140+
if (env === 'develop' || env === 'watch') {
141+
checkCollectionContent({ rowNb: 1, contains: ['Not in MeiliSearch', 'Reload needed'] })
142+
checkCollectionContent({ rowNb: 2, contains: ['Not in MeiliSearch', 'Reload needed'] })
143+
checkCollectionContent({ rowNb: 3, contains: ['Not in MeiliSearch', 'Reload needed'] })
144+
}
109145
})
110146

111147
it('Change Host to wrong host', () => {

package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,17 @@
66
"style": "eslint --ext .js .",
77
"style:fix": "eslint --ext .js . --fix",
88
"playground:dev": "yarn --cwd ./playground && yarn --cwd ./playground develop",
9+
"playground:soft_dev": "yarn --cwd ./playground && yarn --cwd ./playground soft_dev",
910
"playground:build": "yarn --cwd ./playground build",
1011
"playground:start": "yarn --cwd ./playground start",
12+
"playground:production": "NODE_ENV=production yarn --cwd ./playground start",
1113
"cy:install": "node ./node_modules/cypress/bin/cypress install",
1214
"cy:open": "cypress open --env env=watch",
1315
"cy:run": "cypress run --env env=watch",
1416
"test:watch": "start-server-and-test playground:dev http://localhost:8000 'cypress open --env env=watch'",
17+
"test:admindev": "start-server-and-test playground:dev http://localhost:1337 'cypress run --env env=watch'",
18+
"test:dev": "start-server-and-test playground:soft_dev http://localhost:1337 'cypress run --env env=develop'",
19+
"test:production": "start-server-and-test playground:production http://localhost:1337 'cypress run --env env=test'",
1520
"pretest": "yarn playground:build",
1621
"test": "start-server-and-test playground:start http://localhost:1337 'cypress run --env env=test'"
1722
},

playground/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"description": "A Strapi application",
66
"scripts": {
77
"develop": "strapi develop --watch-admin",
8+
"soft": "strapi develop",
89
"start": "strapi start",
910
"build": "strapi build",
1011
"strapi": "strapi"

0 commit comments

Comments
 (0)