* Added E2E tests for #12585. * Added a check to ensure no error message when preview works.
This commit is contained in:
parent
530bd4fcb7
commit
db7120ffae
5 changed files with 130 additions and 17 deletions
|
|
@ -310,6 +310,7 @@ export class ArticleForm extends Component {
|
|||
className="crayons-article-form"
|
||||
onSubmit={this.onSubmit}
|
||||
onInput={this.toggleEdit}
|
||||
data-testid="article-form"
|
||||
>
|
||||
<Header
|
||||
onPreview={this.fetchPreview}
|
||||
|
|
|
|||
5
cypress/fixtures/users/articleEditorV1User.json
Normal file
5
cypress/fixtures/users/articleEditorV1User.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"username": "article_editor_v1_user",
|
||||
"email": "article-editor-v1-user@forem.local",
|
||||
"password": "password"
|
||||
}
|
||||
5
cypress/fixtures/users/articleEditorV2User.json
Normal file
5
cypress/fixtures/users/articleEditorV2User.json
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"username": "article_editor_v2_user",
|
||||
"email": "article-editor-v2-user@forem.local",
|
||||
"password": "password"
|
||||
}
|
||||
75
cypress/integration/publishingFlows/previewArticle.js
Normal file
75
cypress/integration/publishingFlows/previewArticle.js
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
describe('Article Editor', () => {
|
||||
describe('v1 Editor', () => {
|
||||
beforeEach(() => {
|
||||
cy.testSetup();
|
||||
cy.fixture('users/articleEditorV1User.json').as('user');
|
||||
|
||||
cy.get('@user').then((user) => {
|
||||
cy.loginUser(user).then(() => {
|
||||
cy.visit('/new');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should preview blank content of an article', () => {
|
||||
cy.findByTestId('article-form').as('articleForm');
|
||||
|
||||
cy.get('@articleForm')
|
||||
.findByText(/^Preview$/i)
|
||||
.click();
|
||||
cy.findByTestId('error-message').should('not.exist');
|
||||
});
|
||||
|
||||
it(`should show error if the article content can't be previewed`, () => {
|
||||
cy.findByTestId('article-form').as('articleForm');
|
||||
|
||||
// Cause an error by having a non tag liquid tag without a tag name in the article body.
|
||||
cy.get('@articleForm')
|
||||
.findByLabelText('Post Content')
|
||||
.type('{%tag %}', { parseSpecialCharSequences: false });
|
||||
|
||||
cy.get('@articleForm')
|
||||
.findByText(/^Preview$/i)
|
||||
.click();
|
||||
|
||||
cy.findByTestId('error-message').should('be.visible');
|
||||
});
|
||||
});
|
||||
|
||||
describe('v2 Editor', () => {
|
||||
beforeEach(() => {
|
||||
cy.testSetup();
|
||||
cy.fixture('users/articleEditorV2User.json').as('user');
|
||||
|
||||
cy.get('@user').then((user) => {
|
||||
cy.loginUser(user).then(() => {
|
||||
cy.visit('/new');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('should preview blank content of an article', () => {
|
||||
cy.findByTestId('article-form').as('articleForm');
|
||||
|
||||
cy.get('@articleForm')
|
||||
.findByText(/^Preview$/i)
|
||||
.click();
|
||||
cy.findByTestId('error-message').should('not.exist');
|
||||
});
|
||||
|
||||
it(`should show error if the article content can't be previewed`, () => {
|
||||
cy.findByTestId('article-form').as('articleForm');
|
||||
|
||||
// Cause an error by having a non tag liquid tag without a tag name in the article body.
|
||||
cy.get('@articleForm')
|
||||
.findByLabelText('Post Content')
|
||||
.type('{%tag %}', { parseSpecialCharSequences: false });
|
||||
|
||||
cy.get('@articleForm')
|
||||
.findByText(/^Preview$/i)
|
||||
.click();
|
||||
|
||||
cy.findByTestId('error-message').should('be.visible');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -12,23 +12,6 @@ seeder = Seeder.new
|
|||
SiteConfig.public = true
|
||||
SiteConfig.waiting_on_first_user = false
|
||||
|
||||
seeder.create_if_none(Organization) do
|
||||
3.times do
|
||||
Organization.create!(
|
||||
name: Faker::TvShows::SiliconValley.company,
|
||||
summary: Faker::Company.bs,
|
||||
remote_profile_image_url: logo = Faker::Company.logo,
|
||||
nav_image: logo,
|
||||
url: Faker::Internet.url,
|
||||
slug: "org#{rand(10_000)}",
|
||||
github_username: "org#{rand(10_000)}",
|
||||
twitter_username: "org#{rand(10_000)}",
|
||||
bg_color_hex: Faker::Color.hex_color,
|
||||
text_color_hex: Faker::Color.hex_color,
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
||||
# NOTE: @citizen428 For the time being we want all current DEV profile fields.
|
||||
|
|
@ -84,3 +67,47 @@ seeder.create_if_doesnt_exist(User, "email", "change-password-user@forem.com") d
|
|||
end
|
||||
|
||||
##############################################################################
|
||||
|
||||
seeder.create_if_doesnt_exist(User, "email", "article-editor-v1-user@forem.com") do
|
||||
User.create!(
|
||||
name: "Article Editor v1 User",
|
||||
email: "article-editor-v1-user@forem.local",
|
||||
username: "article_editor_v1_user",
|
||||
summary: Faker::Lorem.paragraph_by_chars(number: 199, supplemental: false),
|
||||
profile_image: File.open(Rails.root.join("app/assets/images/#{rand(1..40)}.png")),
|
||||
website_url: Faker::Internet.url,
|
||||
email_comment_notifications: false,
|
||||
email_follower_notifications: false,
|
||||
confirmed_at: Time.current,
|
||||
password: "password",
|
||||
password_confirmation: "password",
|
||||
saw_onboarding: true,
|
||||
checked_code_of_conduct: true,
|
||||
checked_terms_and_conditions: true,
|
||||
editor_version: "v1",
|
||||
)
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
||||
seeder.create_if_doesnt_exist(User, "email", "article-editor-v2-user@forem.com") do
|
||||
User.create!(
|
||||
name: "Article Editor v2 User",
|
||||
email: "article-editor-v2-user@forem.local",
|
||||
username: "article_editor_v2_user",
|
||||
summary: Faker::Lorem.paragraph_by_chars(number: 199, supplemental: false),
|
||||
profile_image: File.open(Rails.root.join("app/assets/images/#{rand(1..40)}.png")),
|
||||
website_url: Faker::Internet.url,
|
||||
email_comment_notifications: false,
|
||||
email_follower_notifications: false,
|
||||
confirmed_at: Time.current,
|
||||
password: "password",
|
||||
password_confirmation: "password",
|
||||
saw_onboarding: true,
|
||||
checked_code_of_conduct: true,
|
||||
checked_terms_and_conditions: true,
|
||||
editor_version: "v2",
|
||||
)
|
||||
end
|
||||
|
||||
##############################################################################
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue