mirror of
https://github.com/datahub-project/datahub.git
synced 2025-10-27 17:02:03 +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 = () => {
|
||||
cy.visit('/')
|
||||
cy.waitTextPresent("Welcome back,")
|
||||
}
|
||||
cy.visit('/');
|
||||
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.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) => {
|
||||
cy.get('[id="posts-create-post"]').click({ force: true });
|
||||
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 clickOnMoreOption = () => {
|
||||
cy.get('[aria-label="more"]').first().click();
|
||||
}
|
||||
|
||||
const deleteFromPostDropdown = () => {
|
||||
cy.get('[aria-label="more"]').first().click()
|
||||
cy.clickOptionWithText("Delete");
|
||||
cy.clickOptionWithText("Yes");
|
||||
cy.reload()
|
||||
homePageRedirection();
|
||||
}
|
||||
|
||||
describe("Create announcement and link posts", () => {
|
||||
describe("create announcement and link post", () => {
|
||||
beforeEach(() => {
|
||||
cy.loginWithCredentials();
|
||||
cy.goToHomePagePostSettings();
|
||||
});
|
||||
|
||||
it("Create and Verify Announcement Post", () => {
|
||||
addAnnouncement();
|
||||
})
|
||||
it("create announcement post and verify", () => {
|
||||
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", () => {
|
||||
deleteFromPostDropdown();
|
||||
cy.ensureTextNotPresent("Test Announcement Title")
|
||||
})
|
||||
it("edit announced post and verify", () => {
|
||||
clickOnMoreOption()
|
||||
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", () => {
|
||||
addLink(title,url,imagesURL)
|
||||
})
|
||||
it("delete announced post and verify", () => {
|
||||
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