Skip to content
Snippets Groups Projects
Select Git revision
  • backport/http_api
  • master default protected
  • backport/docs_ci
  • improve/V30RC02
  • improve/V30RC01
  • feature/http_api
  • feature/couchdb_update_commit
  • fix/tutorial_dynamic_model
  • v0.2.3 protected
  • v0.2.2 protected
  • v0.2.1 protected
  • v0.2.0 protected
  • v0.1.0 protected
13 results

test_config.default.ini

Blame
  • Code owners
    Assign users and groups as approvers for specific file changes. Learn more.
    ConfigurationMetadata.spec.ts 2.43 KiB
    /* Testing imports */
    import { createLocalVue, mount } from "@vue/test-utils";
    import { createTestingPinia } from "@pinia/testing";
    
    /* Vue i18n */
    import i18n, { def } from "@/plugins/vue-i18n";
    import { ProjectI18nMessages } from "@/modules/project/i18n/index";
    i18n.availableLocales.forEach((locale) => {
      i18n.setLocaleMessage(locale, def[locale]); // default locale messages
      i18n.mergeLocaleMessage(locale, ProjectI18nMessages[locale]); // append the locale messages for the component
    });
    
    /* Pinia */
    import { PiniaVuePlugin } from "pinia";
    
    /* Additional Dependencies */
    
    /* Tested Component */
    import ConfigurationMetadata from "./ConfigurationMetadata.vue";
    import type Vue from "vue";
    
    /* Import of relevant mockup data */
    import { testProjectState } from "@/data/mockup/testProject";
    import { getTestShibbolethUserState } from "@/data/mockup/testUser";
    
    /* Create a local Vue instance */
    const localVue = createLocalVue();
    localVue.use(PiniaVuePlugin);
    
    describe("ConfigurationMetadata.vue", () => {
      /* Describe Pre-initialization steps */
    
      /* Description of the test */
      test("Should enable buttons and update project name", async () => {
        /* Test Pre-initialization steps */
    
        /* Mount the Component */
        const wrapper = mount(ConfigurationMetadata as unknown as typeof Vue, {
          pinia: createTestingPinia({
            createSpy: vitest.fn,
            initialState: {
              project: testProjectState,
              user: getTestShibbolethUserState(),
            },
          }),
          i18n,
          localVue,
        });
    
        // Check initial state of buttons
        expect(
          (wrapper.get("#DeleteProjectBtn").element as HTMLButtonElement).disabled
        ).toBeFalsy(); // Delete button - active
        expect(
          (wrapper.get("#SubmitProjectBtn").element as HTMLButtonElement).disabled
        ).toBeTruthy(); // Submit button - disabled
    
        await wrapper.vm.$nextTick();
    
        // Find element (Project Name)
        const element = wrapper.get("#ProjectName");
        expect(element.exists()).toBeTruthy();
    
        // Change value of element
        await element.setValue("New Test Project");
        expect(wrapper.vm.$data.projectForUpdate.name).toBe("New Test Project");
    
        // Buttons should be enabled
        expect(
          (wrapper.get("#DeleteProjectBtn").element as HTMLButtonElement).disabled
        ).toBeFalsy(); // Delete button - active
        expect(
          (wrapper.get("#SubmitProjectBtn").element as HTMLButtonElement).disabled
        ).toBeFalsy(); // Submit button - active
      });
    });