Skip to content

Commit ea457cb

Browse files
committed
Fixed UI tests and added a draft post test
1 parent a873a66 commit ea457cb

2 files changed

Lines changed: 70 additions & 7 deletions

File tree

e2e/features/ui/post.feature

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,32 @@ Feature: Post
33
Scenario: Admin can create a post
44
Given I go to the home page
55
And I sign in as "admin"
6-
And I type "Feature Request Example" as the title
6+
And I click enter your suggestion
77
And I type "This is just an example of a feature suggestion in fider" as the description
8-
And I click submit new post
8+
And I click submit your feedback
99
Then I should be on the show post page
10-
And I should see "Feature Request Example" as the post title
10+
And I should see "This is just an example of a feature suggestion in fider" as the post title
1111
And I should see 1 vote(s)
1212

1313
Scenario: Non-logged in user can view a post
1414
Given I go to the home page
1515
And I search for "Feature Request Example"
1616
And I click on the first post
1717
Then I should be on the show post page
18-
And I should see "Feature Request Example" as the post title
19-
And I should see 1 vote(s)
18+
And I should see "This is just an example of a feature suggestion in fider" as the post title
19+
And I should see 1 vote(s)
20+
21+
Scenario: Non-logged in user can draft a post and submit once signed up
22+
Given I go to the home page
23+
And I click enter your suggestion
24+
And I type "This is a draft post from a new user" as the description
25+
And I type my email address
26+
And I click continue with email
27+
Then I should be on the confirmation link page
28+
Given I click on the confirmation link
29+
Then I should be on the complete profile page
30+
Given I enter my name as "Matt"
31+
And I click submit
32+
Then I should be on the home page
33+
And I should see the new post modal
34+
And I should see "This is a draft post from a new user" as the draft post title

e2e/step_definitions/home.steps.ts

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Given, Then } from "@cucumber/cucumber"
22
import { FiderWorld } from "../world"
33
import expect from "expect"
4+
import { getLatestLinkSentTo } from "./fns"
45

56
Given("I go to the home page", async function (this: FiderWorld) {
67
await this.page.goto(`https://${this.tenantName}.dev.fider.io:3000/`)
@@ -27,6 +28,53 @@ Given("I type {string} as the description", async function (this: FiderWorld, de
2728
await this.page.type("#input-description", description)
2829
})
2930

30-
Given("I click submit new post", async function () {
31-
await this.page.click(".p-home__welcome-col .c-button--primary")
31+
Given("I click enter your suggestion", async function () {
32+
await this.page.click(".p-home__welcome-col .c-button--default")
33+
})
34+
35+
Given("I type my email address", async function (this: FiderWorld) {
36+
const userEmail = `$user-${this.tenantName}@fider.io`
37+
await this.page.type("#input-email", userEmail)
38+
})
39+
40+
Given("I click continue with email", async function () {
41+
await this.page.click(".c-signin-control button[type='submit']")
42+
})
43+
44+
Given("I click submit your feedback", async function () {
45+
await this.page.click(".c-share-feedback__content .c-button--primary")
46+
})
47+
48+
Given("I click on the confirmation link", async function (this: FiderWorld) {
49+
const userEmail = `$user-${this.tenantName}@fider.io`
50+
const activationLink = await getLatestLinkSentTo(userEmail)
51+
await this.page.goto(activationLink)
52+
})
53+
54+
Then("I should be on the complete profile page", async function (this: FiderWorld) {
55+
const container = await this.page.$$("#p-complete-profile")
56+
expect(container).toBeDefined()
57+
})
58+
59+
Then("I should see the new post modal", async function (this: FiderWorld) {
60+
const container = await this.page.$$(".c-share-feedback")
61+
expect(container).toBeDefined()
62+
})
63+
64+
Given("I enter my name as {string}", async function (this: FiderWorld, name: string) {
65+
await this.page.type("#input-name", name)
66+
})
67+
68+
Given("I click submit", async function () {
69+
await this.page.click("button[type='submit']")
70+
})
71+
72+
Then("I should be on the confirmation link page", async function (this: FiderWorld) {
73+
const userEmail = `$user-${this.tenantName}@fider.io`
74+
await expect(this.page.getByText(`We have just sent a confirmation link to ${userEmail}`)).toBeVisible()
75+
})
76+
77+
Then("I should see {string} as the draft post title", async function (this: FiderWorld, title: string) {
78+
const postTitle = await this.page.locator("#input-title").inputValue()
79+
expect(postTitle).toBe(title)
3280
})

0 commit comments

Comments
 (0)