Skip to content

Commit c46bcfb

Browse files
Fix the failing e2e test and added an additional step (#153)
* Fixed the failing e2e test and added an additional step * Add a local e2e test job * Remove test file
1 parent f5ae7e9 commit c46bcfb

File tree

4 files changed

+54
-13
lines changed

4 files changed

+54
-13
lines changed

.circleci/config.yml

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ jobs:
2222
root: *workspace
2323
paths:
2424
- .
25-
test_lint:
25+
lint:
2626
docker:
2727
- image: *build_image
2828
working_directory: *workspace
@@ -89,6 +89,29 @@ jobs:
8989
command: npm run e2e
9090
- store_artifacts:
9191
path: /home/circleci/project/.screenshots
92+
e2e_local:
93+
docker:
94+
- image: cimg/node:14.14-browsers
95+
working_directory: *workspace
96+
steps:
97+
- attach_workspace:
98+
at: *workspace
99+
- run:
100+
name: Serve site locally
101+
command: npx serve out -p 3000
102+
background: true
103+
# wait for the server to start responding.
104+
- run:
105+
name: Wait for server to connect
106+
shell: /bin/sh
107+
command: wget --spider --retry-connrefused --waitretry=1 --read-timeout=20 --timeout=15 -t 20 http://localhost:3000
108+
- run:
109+
name: Running landing page e2e test against local build
110+
environment:
111+
COMMIT_DEV_HOST: http://localhost:3000
112+
command: npm run e2e
113+
- store_artifacts:
114+
path: /home/circleci/project/.screenshots
92115

93116
workflows:
94117
version: 2
@@ -101,14 +124,18 @@ workflows:
101124
ignore:
102125
- main
103126
- launch
104-
- test_lint:
127+
- lint:
105128
requires:
106129
- checkout_code
107130
- build:
108131
name: build_feature
109132
helix_host: ''
110133
requires:
111134
- checkout_code
135+
- e2e_local:
136+
context: test-envs
137+
requires:
138+
- build_feature
112139

113140
main:
114141
jobs:
@@ -117,10 +144,6 @@ workflows:
117144
branches:
118145
only:
119146
- main
120-
- e2e:
121-
context: test-envs
122-
requires:
123-
- checkout_code
124147
- build:
125148
name: build_staging
126149
helix_host: https://api-public.commit-staging.dev/email/apply
@@ -131,6 +154,10 @@ workflows:
131154
bucket: commit-staging.dev
132155
requires:
133156
- build_staging
157+
- e2e:
158+
context: test-envs
159+
requires:
160+
- deploy_staging
134161
- build:
135162
name: build_production
136163
helix_host: https://api-public.commit.dev/email/apply
@@ -160,10 +187,6 @@ workflows:
160187
branches:
161188
only:
162189
- launch
163-
- e2e:
164-
context: test-envs
165-
requires:
166-
- checkout_code
167190
- build:
168191
name: build_feature
169192
helix_host: https://api-public.commit-staging.dev/email/apply
@@ -174,3 +197,7 @@ workflows:
174197
bucket: launch.commit-staging.dev
175198
requires:
176199
- build_feature
200+
- e2e:
201+
context: test-envs
202+
requires:
203+
- deploy_staging

components/form/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ const Form = () => {
123123
/>
124124
<Button
125125
{...{
126-
'data-test-id': 'button',
126+
'data-test-id': 'submitApplicationButton',
127127
onClick,
128128
}}
129129
>

pages/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const Home = () => (
3434
Commit is designing the future of work and we're putting Engineers
3535
at the center.
3636
</Text>
37-
<ApplyLink>Apply to Join Us</ApplyLink>
37+
<ApplyLink data-test-id='applyButton'>Apply to Join Us</ApplyLink>
3838
</div>
3939
<div className={styles.heroSvg}>
4040
<BracketSvg />

tests/index.e2e.js

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import puppeteer from 'puppeteer'
2+
23
import { config, PageObjectModel } from '../helpers/e2e'
34

45
class LandingPage extends PageObjectModel {
56
async checkApplyButtonExists() {
67
const buttonText = await this.getTextBySelector({
7-
selector: '[data-test-id="button"]',
8+
selector: '[data-test-id="applyButton"]',
89
})
910
await expect(buttonText).toBeTruthy()
1011
}
@@ -33,4 +34,17 @@ describe('LandingPage', () => {
3334
filename: `${filenamePrefix}_00_landing_page_button`,
3435
})
3536
})
37+
38+
it('it goes to the apply page on click of apply button', async () => {
39+
await landingPage.clickSelector({
40+
selector: '[data-test-id="applyButton"]',
41+
})
42+
const buttonText = await landingPage.getTextBySelector({
43+
selector: '[data-test-id="submitApplicationButton"]',
44+
})
45+
expect(buttonText).toBeTruthy()
46+
await landingPage.saveScreenshot({
47+
filename: `${filenamePrefix}_00_landing_page_navigate_to_apply_page`,
48+
})
49+
})
3650
})

0 commit comments

Comments
 (0)