您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. const getLogin = () => cy.get("#login");
  2. const getLowercase = () => cy.get("#options #lowercase__btn");
  3. const getUppercase = () => cy.get("#options #uppercase__btn");
  4. const getNumbers = () => cy.get("#options #numbers__btn");
  5. const getSymbols = () => cy.get("#options #symbols__btn");
  6. const getLength = () => cy.get("#options #passwordLength");
  7. const getCounter = () => cy.get("#options #passwordCounter");
  8. function editSettings() {
  9. getLogin()
  10. .clear()
  11. .type("New login");
  12. getLowercase()
  13. .click()
  14. .should("not.be.checked");
  15. getUppercase()
  16. .click()
  17. .should("not.be.checked");
  18. getNumbers()
  19. .click()
  20. .should("not.be.checked");
  21. getSymbols()
  22. .click()
  23. .should("not.be.checked");
  24. getLength()
  25. .clear()
  26. .type("5");
  27. getCounter()
  28. .clear()
  29. .type("2");
  30. }
  31. function checkSettingsEdited() {
  32. getLogin().should("have.value", "New login");
  33. getLowercase().should("not.be.checked");
  34. getUppercase().should("not.be.checked");
  35. getNumbers().should("not.be.checked");
  36. getSymbols().should("not.be.checked");
  37. getLength().should("have.value", "5");
  38. getCounter().should("have.value", "2");
  39. }
  40. describe("Settings", function() {
  41. it("should start with default values", () => {
  42. cy.visit("/#/settings");
  43. cy.wait(500);
  44. getLogin().should("have.value", "");
  45. getLowercase().should("be.checked");
  46. getUppercase().should("be.checked");
  47. getNumbers().should("be.checked");
  48. getSymbols().should("be.checked");
  49. getLength().should("have.value", "16");
  50. getCounter().should("have.value", "1");
  51. });
  52. it("should redirect to the home page when saving", () => {
  53. cy.visit("/#/settings");
  54. cy.wait(500);
  55. cy.get("#btn-submit-settings").click();
  56. cy.location().should(location => {
  57. expect(location.pathname).to.eq("/");
  58. });
  59. });
  60. it("should pass on the settings to the password generator page after save", () => {
  61. cy.visit("/#/settings");
  62. cy.wait(500);
  63. editSettings();
  64. cy.get("#btn-submit-settings").click();
  65. checkSettingsEdited();
  66. });
  67. it("should still show the saved settings when going back to the settings page", () => {
  68. cy.visit("/#/settings");
  69. cy.wait(500);
  70. editSettings();
  71. cy.get("#btn-submit-settings").click();
  72. cy.visit("/#/settings");
  73. cy.wait(500);
  74. checkSettingsEdited();
  75. });
  76. });