-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathEditorGutenbergTests.swift
88 lines (75 loc) · 3.23 KB
/
EditorGutenbergTests.swift
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
import UITestsFoundation
import XCTest
class EditorGutenbergTests: XCTestCase {
private var editorScreen: BlockEditorScreen!
override func setUpWithError() throws {
setUpTestSuite()
_ = try LoginFlow.loginIfNeeded(siteUrl: WPUITestCredentials.testWPcomSiteAddress, email: WPUITestCredentials.testWPcomUserEmail, password: WPUITestCredentials.testWPcomPassword)
editorScreen = try EditorFlow
.goToMySiteScreen()
.tabBar.gotoBlockEditorScreen()
.dismissNotificationAlertIfNeeded(.accept)
}
override func tearDownWithError() throws {
takeScreenshotOfFailedTest()
if editorScreen == nil {
BlockEditorScreen.closeEditorDiscardingChanges()
} else if TabNavComponent.isVisible() == false {
editorScreen.dismissBlocksPickerIfNeeded()
EditorFlow.returnToMainEditorScreen()
editorScreen.closeEditor()
}
try LoginFlow.logoutIfNeeded()
try super.tearDownWithError()
}
let title = "Rich post title"
let content = "Some text, and more text"
func testTextPostPublish() throws {
try editorScreen
.enterTextInTitle(text: title)
.addParagraphBlock(withText: content)
.verifyContentStructure(blocks: 1, words: content.components(separatedBy: " ").count, characters: content.count)
.publish()
.viewPublishedPost(withTitle: title)
.verifyEpilogueDisplays(postTitle: title, siteAddress: WPUITestCredentials.testWPcomSitePrimaryAddress)
.done()
}
func testBasicPostPublishWithCategoryAndTag() throws {
let category = getCategory()
let tag = getTag()
try editorScreen
.enterTextInTitle(text: title)
.addParagraphBlock(withText: content)
.addImage()
.verifyContentStructure(blocks: 2, words: content.components(separatedBy: " ").count, characters: content.count)
.openPostSettings()
.selectCategory(name: category)
.addTag(name: tag)
.closePostSettings()
try BlockEditorScreen().publish()
.viewPublishedPost(withTitle: title)
.verifyEpilogueDisplays(postTitle: title, siteAddress: WPUITestCredentials.testWPcomSitePrimaryAddress)
.done()
}
func testAddRemoveFeaturedImage() throws {
try editorScreen
.enterTextInTitle(text: title)
.addParagraphBlock(withText: content)
.verifyContentStructure(blocks: 1, words: content.components(separatedBy: " ").count, characters: content.count)
.openPostSettings()
.setFeaturedImage()
.verifyPostSettings(hasImage: true)
.removeFeatureImage()
.verifyPostSettings(hasImage: false)
.setFeaturedImage()
.verifyPostSettings(hasImage: true)
.closePostSettings()
}
func testAddGalleryBlock() throws {
try editorScreen
.enterTextInTitle(text: title)
.addParagraphBlock(withText: content)
.addImageGallery()
.verifyContentStructure(blocks: 5, words: content.components(separatedBy: " ").count, characters: content.count)
}
}