mirror of
				https://github.com/datahub-project/datahub.git
				synced 2025-10-31 02:37:05 +00:00 
			
		
		
		
	tests(posts): Verify Edit Post Steps (#9683)
This commit is contained in:
		
							parent
							
								
									720296ea46
								
							
						
					
					
						commit
						fb6eafbaa0
					
				| @ -1,65 +1,85 @@ | |||||||
| const title = 'Test Link Title' |  | ||||||
| const url = 'https://www.example.com' |  | ||||||
| const imagesURL = 'https://www.example.com/images/example-image.jpg' |  | ||||||
| 
 |  | ||||||
| const homePageRedirection = () => { | const homePageRedirection = () => { | ||||||
|     cy.visit('/') |     cy.visit('/'); | ||||||
|     cy.waitTextPresent("Welcome back,") |     cy.waitTextPresent("Welcome back"); | ||||||
| } | }; | ||||||
| 
 | 
 | ||||||
| const addAnnouncement = () => { | const addOrEditAnnouncement = (text, title, description, testId) => { | ||||||
|  |     cy.waitTextPresent(text); | ||||||
|  |     cy.get('[data-testid="create-post-title"]').clear().type(title); | ||||||
|  |     cy.get('[id="description"]').clear().type(description); | ||||||
|  |     cy.get(`[data-testid="${testId}-post-button"]`).click({ force: true }); | ||||||
|  |     cy.reload(); | ||||||
|  |     homePageRedirection(); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const addOrEditLink = (text, title, url, imagesURL, testId) => { | ||||||
|  |     cy.waitTextPresent(text); | ||||||
|  |     cy.get('[data-testid="create-post-title"]').clear().type(title); | ||||||
|  |     cy.get('[data-testid="create-post-link"]').clear().type(url); | ||||||
|  |     cy.get('[data-testid="create-post-media-location"]').clear().type(imagesURL); | ||||||
|  |     cy.get(`[data-testid="${testId}-post-button"]`).click({ force: true }); | ||||||
|  |     cy.reload(); | ||||||
|  |     homePageRedirection(); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | const clickOnNewPost = () =>{ | ||||||
|     cy.get('[id="posts-create-post"]').click({ force: true }); |     cy.get('[id="posts-create-post"]').click({ force: true }); | ||||||
|     cy.waitTextPresent('Create new Post') |  | ||||||
|     cy.enterTextInTestId("create-post-title", "Test Announcement Title"); |  | ||||||
|     cy.get('[id="description"]').type("Add Description to post announcement") |  | ||||||
|     cy.get('[data-testid="create-post-button"]').click({ force: true }); |  | ||||||
|     cy.reload() |  | ||||||
|     homePageRedirection(); |  | ||||||
|     cy.waitTextPresent("Test Announcement Title"); |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const addLink = (title,url,imagesURL) => { | const clickOnMoreOption = () => { | ||||||
|     cy.get('[id="posts-create-post"]').click({ force: true }); |     cy.get('[aria-label="more"]').first().click(); | ||||||
|     cy.waitTextPresent('Create new Post') |  | ||||||
|     cy.clickOptionWithText('Link'); |  | ||||||
|     cy.enterTextInTestId('create-post-title', title); |  | ||||||
|     cy.enterTextInTestId('create-post-link', url); |  | ||||||
|     cy.enterTextInTestId('create-post-media-location', imagesURL) |  | ||||||
|     cy.get('[data-testid="create-post-button"]').click({ force: true }); |  | ||||||
|     cy.reload() |  | ||||||
|     homePageRedirection(); |  | ||||||
|     cy.waitTextPresent(title) |  | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| const deleteFromPostDropdown = () => { | describe("create announcement and link post", () => { | ||||||
|     cy.get('[aria-label="more"]').first().click() |  | ||||||
|     cy.clickOptionWithText("Delete"); |  | ||||||
|     cy.clickOptionWithText("Yes"); |  | ||||||
|     cy.reload() |  | ||||||
|     homePageRedirection(); |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| describe("Create announcement and link posts", () => { |  | ||||||
|     beforeEach(() => { |     beforeEach(() => { | ||||||
|         cy.loginWithCredentials(); |         cy.loginWithCredentials(); | ||||||
|         cy.goToHomePagePostSettings(); |         cy.goToHomePagePostSettings(); | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|     it("Create and Verify Announcement Post", () => { |     it("create announcement post and verify", () => { | ||||||
|         addAnnouncement(); |         clickOnNewPost() | ||||||
|     }) |         addOrEditAnnouncement("Create new Post", "Test Announcement Title", "Add Description to post announcement", "create"); | ||||||
|  |         cy.waitTextPresent("Test Announcement Title"); | ||||||
|  |     }); | ||||||
| 
 | 
 | ||||||
|     it("Delete and Verify Announcement Post", () => { |     it("edit announced post and verify", () => { | ||||||
|         deleteFromPostDropdown(); |         clickOnMoreOption() | ||||||
|         cy.ensureTextNotPresent("Test Announcement Title") |         cy.clickOptionWithText("Edit"); | ||||||
|     }) |         addOrEditAnnouncement("Edit Post", "Test Announcement Title Edited", "Decription Edited", "update"); | ||||||
|  |         cy.waitTextPresent("Test Announcement Title Edited"); | ||||||
|  |     }); | ||||||
| 
 | 
 | ||||||
|     it("Create and Verify Link Post", () => { |     it("delete announced post and verify", () => { | ||||||
|         addLink(title,url,imagesURL) |         clickOnMoreOption() | ||||||
|     }) |         cy.clickOptionWithText("Delete"); | ||||||
|  |         cy.clickOptionWithText("Yes"); | ||||||
|  |         cy.reload(); | ||||||
|  |         homePageRedirection(); | ||||||
|  |         cy.ensureTextNotPresent("Test Announcement Title Edited"); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("create link post and verify", () => { | ||||||
|  |         clickOnNewPost() | ||||||
|  |         cy.waitTextPresent('Create new Post'); | ||||||
|  |         cy.contains('label', 'Link').click(); | ||||||
|  |         addOrEditLink("Create new Post", "Test Link Title", 'https://www.example.com', 'https://www.example.com/images/example-image.jpg', "create"); | ||||||
|  |         cy.waitTextPresent("Test Link Title"); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("edit linked post and verify", () => { | ||||||
|  |         clickOnMoreOption() | ||||||
|  |         cy.clickOptionWithText("Edit"); | ||||||
|  |         addOrEditLink("Edit Post", "Test Link Edited Title", 'https://www.updatedexample.com', 'https://www.updatedexample.com/images/example-image.jpg', "update"); | ||||||
|  |         cy.waitTextPresent("Test Link Edited Title"); | ||||||
|  |     }); | ||||||
|  | 
 | ||||||
|  |     it("delete linked post and verify", () => { | ||||||
|  |         clickOnMoreOption() | ||||||
|  |         cy.clickOptionWithText("Delete"); | ||||||
|  |         cy.clickOptionWithText("Yes"); | ||||||
|  |         cy.reload(); | ||||||
|  |         homePageRedirection(); | ||||||
|  |         cy.ensureTextNotPresent("Test Link Edited Title"); | ||||||
|  |     }); | ||||||
|  | }); | ||||||
| 
 | 
 | ||||||
|     it("Delete and Verify Link Post", () => { |  | ||||||
|         deleteFromPostDropdown(); |  | ||||||
|         cy.ensureTextNotPresent(title); |  | ||||||
|     }) |  | ||||||
| }) |  | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Kunal-kankriya
						Kunal-kankriya