Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added to Verify Edit Post Steps #9683

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 68 additions & 48 deletions smoke-test/tests/cypress/cypress/e2e/settings/homePagePost.js
Original file line number Diff line number Diff line change
@@ -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 = () => {
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()
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();
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()
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();
cy.waitTextPresent(title)
};

const clickOnNewPost = () =>{
cy.get('[id="posts-create-post"]').click({ force: true });
}

const deleteFromPostDropdown = () => {
cy.get('[aria-label="more"]').first().click()
cy.clickOptionWithText("Delete");
cy.clickOptionWithText("Yes");
cy.reload()
homePageRedirection();
const clickOnMoreOption = () => {
cy.get('[aria-label="more"]').first().click();
}

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("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("Create and Verify Link Post", () => {
addLink(title,url,imagesURL)
})
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