From a065571e8bea9fd7e7cecd84f8f390710193ac50 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Sat, 4 Apr 2020 22:53:22 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 3 --- .../src/views/adm-global-select-templates.vue | 22 +++++++++------ ayanova/src/views/adm-global-settings.vue | 6 ++++- .../tests/e2e/specs/select-list-templates.js | 27 +++++++++++++++++++ 4 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 ayanova/tests/e2e/specs/select-list-templates.js diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index bf25b144..c317919a 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -51,9 +51,6 @@ CURRENT TODOs todo: add tests for the following: - - customize form form - - NOTE: All cypress tests run serially anyway, so it's perfectly ok to customize the widget form, go see if it worked, then come back and reverse it without affecting the other tests - - so do a real customization and with the conditional data-cy attribute possibility there's no reason not to put that attribute anywhere desired like on every clickable element tested etc - picklist editor form todo: Customer login should have help links go to a special customer end user section in the manual, but they can still view the rest of the manual becuase maybe they will buy it diff --git a/ayanova/src/views/adm-global-select-templates.vue b/ayanova/src/views/adm-global-select-templates.vue index bb7f2415..8ebcc644 100644 --- a/ayanova/src/views/adm-global-select-templates.vue +++ b/ayanova/src/views/adm-global-select-templates.vue @@ -24,6 +24,8 @@ item-value="id" :label="$ay.t('PickListTemplates')" @input="templateSelected" + :data-cy="!!$ay.dev ? 'SelectTemplate' : false" + :disabled="formState.dirty" > @@ -143,6 +145,7 @@ export default { workingArray: [], fieldKeys: [], templateId: 0, + lastFetchedTemplateId: 0, formState: { ready: false, dirty: false, @@ -226,14 +229,17 @@ export default { }); }, templateSelected: function() { - if (this.formState.dirty) { - window.$gz.dialog.confirmLeaveUnsaved().then(dialogResult => { - if (dialogResult != true) { - return; - } - }); + let vm = this; + if (vm.lastFetchedTemplateId == vm.templateId) { + return; //no change + } + vm.workingArray = []; + if (!vm.templateId || vm.templateId == 0) { + vm.lastFetchedTemplateId = 0; + return; + } else { + vm.getDataFromApi(); } - this.getDataFromApi(); }, getDataFromApi() { let vm = this; @@ -241,7 +247,7 @@ export default { if (!vm.templateId || vm.templateId == 0) { return; } - + vm.lastFetchedTemplateId = vm.templateId; window.$gz.form.deleteAllErrorBoxErrors(vm); //get available fields diff --git a/ayanova/src/views/adm-global-settings.vue b/ayanova/src/views/adm-global-settings.vue index 57cab0f0..d294ad15 100644 --- a/ayanova/src/views/adm-global-settings.vue +++ b/ayanova/src/views/adm-global-settings.vue @@ -2,7 +2,11 @@ {{ $ay.t("UserInterfaceSettings") }} - + {{ $ay.t("PickListTemplates") }} diff --git a/ayanova/tests/e2e/specs/select-list-templates.js b/ayanova/tests/e2e/specs/select-list-templates.js new file mode 100644 index 00000000..4c4dcedb --- /dev/null +++ b/ayanova/tests/e2e/specs/select-list-templates.js @@ -0,0 +1,27 @@ +// https://docs.cypress.io/api/introduction/api.html + +describe("PICK LIST TEMPLATE", () => { + it("Successfully changes pick list template", () => { + cy.visit("/login"); + + cy.get("input[name=username]") + .clear() + .type(Cypress.env("adminusername")); + + // {enter} causes the form to submit + cy.get("input[name=password]") + .clear() + .type(`${Cypress.env("adminpassword")}{enter}`); + cy.url().should("include", "/home-dashboard"); + + cy.visit("/adm-global-settings"); + cy.url().should("include", "/adm-global-settings"); + cy.get("[data-cy=picklisttemplates]").click(); + cy.url().should("include", "/adm-global-select-templates"); + cy.get("[data-cy=SelectTemplate]").type("u{tab}", { + force: true + }); + + //----------------- + }); +});