test(post): add Homepage Post smoke tests (#9620)

This commit is contained in:
Kunal-kankriya 2024-01-16 17:15:06 +05:30 committed by GitHub
parent d69ed9a321
commit dc253571ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 70 additions and 0 deletions

View File

@ -0,0 +1,65 @@
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,")
}
const addAnnouncement = () => {
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 deleteFromPostDropdown = () => {
cy.get('[aria-label="more"]').first().click()
cy.clickOptionWithText("Delete");
cy.clickOptionWithText("Yes");
cy.reload()
homePageRedirection();
}
describe("Create announcement and link posts", () => {
beforeEach(() => {
cy.loginWithCredentials();
cy.goToHomePagePostSettings();
});
it("Create and Verify Announcement Post", () => {
addAnnouncement();
})
it("Delete and Verify Announcement Post", () => {
deleteFromPostDropdown();
cy.ensureTextNotPresent("Test Announcement Title")
})
it("Create and Verify Link Post", () => {
addLink(title,url,imagesURL)
})
it("Delete and Verify Link Post", () => {
deleteFromPostDropdown();
cy.ensureTextNotPresent(title);
})
})

View File

@ -84,6 +84,11 @@ Cypress.Commands.add("goToOwnershipTypesSettings", () => {
cy.waitTextVisible("Manage Ownership");
});
Cypress.Commands.add("goToHomePagePostSettings", () => {
cy.visit("/settings/posts");
cy.waitTextVisible("Home Page Posts");
});
Cypress.Commands.add("goToAccessTokenSettings", () => {
cy.visit("/settings/tokens");
cy.waitTextVisible("Manage Access Tokens");