001_robots_txt.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /// <reference types="Cypress" />
  2. context('Module robots.txt', () => {
  3. it('should reset', () => {
  4. cy.installCMS();
  5. });
  6. it('should render edit form', () => {
  7. cy.loginCMS();
  8. cy.visitCMS('/cp/settings/robots-txt/');
  9. cy.get('.data-form.settings-robots-txt textarea[name=content]').should('exist');
  10. cy.get('.data-form.settings-robots-txt textarea[name=content]').should('have.value', 'User-agent: *\nDisallow: /\n');
  11. cy.logoutCMS();
  12. });
  13. it('should render result file', () => {
  14. cy.request({
  15. url: cy.getBaseUrl() + '/robots.txt',
  16. followRedirect: false
  17. }).then((response) => {
  18. expect(response.status).to.eq(200);
  19. expect(response.body).to.eq('User-agent: *\r\nDisallow: /\r\n');
  20. });
  21. });
  22. it('should change file content', () => {
  23. cy.loginCMS();
  24. cy.visitCMS('/cp/settings/robots-txt/');
  25. cy.get('.data-form.settings-robots-txt textarea[name=content]').clear().type('Some file content');
  26. cy.get('#add-edit-button').click();
  27. cy.actionWait();
  28. cy.visitCMS('/cp/settings/robots-txt/');
  29. cy.get('.data-form.settings-robots-txt textarea[name=content]').should('have.value', 'Some file content');
  30. cy.request({
  31. url: cy.getBaseUrl() + '/robots.txt',
  32. followRedirect: false
  33. }).then((response) => {
  34. expect(response.status).to.eq(200);
  35. expect(response.body).to.eq('Some file content');
  36. });
  37. cy.visitCMS('/cp/settings/robots-txt/');
  38. cy.get('.data-form.settings-robots-txt textarea[name=content]').clear().type('User-agent: *\nDisallow: /\n');
  39. cy.get('#add-edit-button').click();
  40. cy.actionWait();
  41. cy.visitCMS('/cp/settings/robots-txt/');
  42. cy.get('.data-form.settings-robots-txt textarea[name=content]').should('have.value', 'User-agent: *\nDisallow: /\n');
  43. cy.request({
  44. url: cy.getBaseUrl() + '/robots.txt',
  45. followRedirect: false
  46. }).then((response) => {
  47. expect(response.status).to.eq(200);
  48. expect(response.body).to.eq('User-agent: *\r\nDisallow: /\r\n');
  49. });
  50. cy.logoutCMS();
  51. });
  52. });