Skip to content

Commit

Permalink
Merge brtanch 'gha-warnings' of 'https://github.com/evamillan/grimoir…
Browse files Browse the repository at this point in the history
  • Loading branch information
sduenas authored Sep 18, 2024
2 parents d07cc1e + 4a3c1a4 commit 887c62c
Show file tree
Hide file tree
Showing 13 changed files with 130 additions and 113 deletions.
3 changes: 2 additions & 1 deletion ui/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ module.exports = {
"^vuetify/labs/VConfirmEdit":
"<rootDir>/node_modules/vuetify/lib/labs/VConfirmEdit/index.mjs",
"^vuetify/styles": "<rootDir>/node_modules/vuetify/lib/styles/main.css",
"^@storybook/vue3/preview" : "<rootDir>/node_modules/@storybook/vue3/dist/entry-preview.js",
"^@storybook/vue3/preview":
"<rootDir>/node_modules/@storybook/vue3/dist/entry-preview.js",
},
setupFiles: ["./tests/setup.js"],
};
5 changes: 2 additions & 3 deletions ui/src/components/GenericModal.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const Default = () => ({
action: null,
actionButtonLabel: null,
actionButtonColor: null,
dismissButtonLabel: "Close"
dismissButtonLabel: "Close",
}),
});

Expand All @@ -47,7 +47,6 @@ export const DestructiveAction = () => ({
action: () => {},
actionButtonLabel: "Delete",
actionButtonColor: "error",
dismissButtonLabel: "Cancel"
dismissButtonLabel: "Cancel",
}),
});

4 changes: 1 addition & 3 deletions ui/src/components/Identity.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
:variant="isMain ? 'tonal' : 'outlined'"
>
<span class="clip mr-1">{{ uuid }}</span>
<span v-if="isMain" class="d-sr-only">
Main identity
</span>
<span v-if="isMain" class="d-sr-only"> Main identity </span>
<v-tooltip open-delay="100" location="bottom">
<template v-slot:activator="{ props }">
<v-btn
Expand Down
9 changes: 4 additions & 5 deletions ui/src/components/IndividualsTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ export const Default = () => ({
results.data.individuals.entities.filter((individual) =>
individual.profile.name
.toUpperCase()
.includes(filters.term.toUpperCase()),
.includes(filters.term.toUpperCase())
);
results.data.individuals.pageInfo.totalResults =
results.data.individuals.entities.length;
Expand Down Expand Up @@ -442,7 +442,7 @@ export const Expandable = () => ({
results.data.individuals.entities.filter((individual) =>
individual.profile.name
.toUpperCase()
.includes(filters.term.toUpperCase()),
.includes(filters.term.toUpperCase())
);
results.data.individuals.pageInfo.totalResults =
results.data.individuals.entities.length;
Expand Down Expand Up @@ -500,7 +500,7 @@ export const Outlined = () => ({
results.data.individuals.entities.filter((individual) =>
individual.profile.name
.toUpperCase()
.includes(filters.term.toUpperCase()),
.includes(filters.term.toUpperCase())
);
results.data.individuals.pageInfo.totalResults =
results.data.individuals.entities.length;
Expand Down Expand Up @@ -558,7 +558,7 @@ export const HiddenHeader = () => ({
results.data.individuals.entities.filter((individual) =>
individual.profile.name
.toUpperCase()
.includes(filters.term.toUpperCase()),
.includes(filters.term.toUpperCase())
);
results.data.individuals.pageInfo.totalResults =
results.data.individuals.entities.length;
Expand Down Expand Up @@ -640,4 +640,3 @@ export const OnError = () => ({
isExpandable: false,
}),
});

2 changes: 1 addition & 1 deletion ui/src/components/JobsTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ export const OnError = () => ({
template: JobsTableTemplate,
methods: {
getJobs() {
throw new Error("Test error message")
throw new Error("Test error message");
},
},
data: () => ({
Expand Down
4 changes: 2 additions & 2 deletions ui/src/components/OrganizationSelector.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export const Default = () => ({
const results = JSON.parse(JSON.stringify(this.organizations));
if (filters.term) {
results.entities = results.entities.filter((organization) =>
organization.name.toUpperCase().includes(filters.term.toUpperCase()),
organization.name.toUpperCase().includes(filters.term.toUpperCase())
);
}
return results;
Expand Down Expand Up @@ -79,7 +79,7 @@ export const SelectedOrganization = () => ({
const results = JSON.parse(JSON.stringify(this.organizations));
if (filters.term) {
results.entities = results.entities.filter((organization) =>
organization.name.toUpperCase().includes(filters.term.toUpperCase()),
organization.name.toUpperCase().includes(filters.term.toUpperCase())
);
}
return results;
Expand Down
22 changes: 9 additions & 13 deletions ui/src/components/OrganizationsTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ export const Organizations = () => ({
if (filters.term) {
results.data.organizations.entities =
results.data.organizations.entities.filter((organization) =>
organization.name
.toUpperCase()
.includes(filters.term.toUpperCase()),
organization.name.toUpperCase().includes(filters.term.toUpperCase())
);
results.data.organizations.pageInfo.totalResults =
results.data.organizations.entities.length;
Expand All @@ -55,7 +53,7 @@ export const Organizations = () => ({
},
addDomain(domain, organization) {
const index = this.query[0].data.organizations.entities.findIndex(
(entity) => entity.name === organization,
(entity) => entity.name === organization
);
this.query[0].data.organizations.entities[index].domains.push({
domain: domain,
Expand All @@ -65,14 +63,14 @@ export const Organizations = () => ({
deleteDomain(domain) {
this.query[0].data.organizations.entities.find((entity) => {
const index = entity.domains.findIndex(
(item) => item.domain === domain,
(item) => item.domain === domain
);
entity.domains.splice(index, 1);
});
},
deleteOrganization(name) {
const index = this.query[0].data.organizations.entities.findIndex(
(entity) => entity.name === name,
(entity) => entity.name === name
);
this.query[0].data.organizations.entities.splice(index, 1);
},
Expand Down Expand Up @@ -170,9 +168,7 @@ export const Groups = () => ({
if (filters.term) {
results.data.organizations.entities =
results.data.organizations.entities.filter((organization) =>
organization.name
.toUpperCase()
.includes(filters.term.toUpperCase()),
organization.name.toUpperCase().includes(filters.term.toUpperCase())
);
results.data.organizations.pageInfo.totalResults =
results.data.organizations.entities.length;
Expand All @@ -193,7 +189,7 @@ export const Groups = () => ({
},
addDomain(domain, organization) {
const index = this.query[0].data.organizations.entities.findIndex(
(entity) => entity.name === organization,
(entity) => entity.name === organization
);
this.query[0].data.organizations.entities[index].domains.push({
domain: domain,
Expand All @@ -203,14 +199,14 @@ export const Groups = () => ({
deleteDomain(domain) {
this.query[0].data.organizations.entities.find((entity) => {
const index = entity.domains.findIndex(
(item) => item.domain === domain,
(item) => item.domain === domain
);
entity.domains.splice(index, 1);
});
},
deleteOrganization(name) {
const index = this.query[0].data.organizations.entities.findIndex(
(entity) => entity.name === name,
(entity) => entity.name === name
);
this.query[0].data.organizations.entities.splice(index, 1);
},
Expand Down Expand Up @@ -306,7 +302,7 @@ export const OnError = () => ({
components: { OrganizationsTable },
template: OrganizationsTableTemplate,
methods: {
getOrganizations(page, items, filters) {
getOrganizations() {
throw new Error("Test error message");
},
enroll() {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/TasksTable.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export const Default = () => ({
deleteTask(id) {
this.tasks.data.scheduledTasks.entities =
this.tasks.data.scheduledTasks.entities.filter(
(task) => task.id !== id,
(task) => task.id !== id
);
return {
data: {
Expand Down
2 changes: 1 addition & 1 deletion ui/src/components/WorkSpace.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ export const DragAndDrop = () => ({
results.data.individuals.entities.filter((individual) =>
individual.profile.name
.toUpperCase()
.includes(filters.term.toUpperCase()),
.includes(filters.term.toUpperCase())
);
results.data.individuals.pageInfo.totalResults =
results.data.individuals.entities.length;
Expand Down
6 changes: 1 addition & 5 deletions ui/src/components/WorkSpace.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,7 @@
/>
</li>
</ul>
<v-row
v-else
dense
class="align-center justify-center drag-zone"
>
<v-row v-else dense class="align-center justify-center drag-zone">
<v-icon color="rgba(0,0,0,0.38)" left> mdi-lightbulb-on-outline </v-icon>
<p class="mb-0 ml-2 text-medium-emphasis">
<span>
Expand Down
43 changes: 22 additions & 21 deletions ui/tests/unit/individual.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,52 +14,53 @@ describe("Individual", () => {
email: "johndoe@example.com",
isBot: false,
gender: null,
country: null
country: null,
},
identities: [
{
name: "John Doe",
source: "github",
uuid: "4c8620c3d43e2873dd9d9a8748e0afadeef9d53a",
username: "johndoe",
email: "johndoe@example.com"
email: "johndoe@example.com",
},
{
source: "github",
uuid: "9a6e9ca58185a7f5579bca8ab434cb58cfc79f15",
username: "johndoe"
username: "johndoe",
},
{
source: "github",
uuid: "5579bca8ab4349a6e9ca58185a7fcb58cfc79f15",
username: "johndoe",
email: "johndoe@example.com"
email: "johndoe@example.com",
},
{
source: "git",
email: "johndoe@example.com",
uuid: "f0422fed699c5a1096808272ae51c69f37f7dd29"
email: "johndoe@example.com",
uuid: "f0422fed699c5a1096808272ae51c69f37f7dd29",
},
],
enrollments: [],
matchRecommendationSet: []
}
matchRecommendationSet: [],
},
];

const mountFunction = () => mount(VApp, {
slots: {
default: h(Individual),
},
global: {
mocks: {
$apollo: () => {},
$store: { getters: { workspace: [] }},
$route: { params: "bcde123456"}
const mountFunction = () =>
mount(VApp, {
slots: {
default: h(Individual),
},
plugins: [vuetify],
stubs: ["routerLink"],
},
});
global: {
mocks: {
$apollo: () => {},
$store: { getters: { workspace: [] } },
$route: { params: "bcde123456" },
},
plugins: [vuetify],
stubs: ["routerLink"],
},
});

test("Renders link to GitHub profile", async () => {
const wrapper = mountFunction();
Expand Down
43 changes: 27 additions & 16 deletions ui/tests/unit/storybook.spec.js
Original file line number Diff line number Diff line change
@@ -1,26 +1,31 @@
import path from 'path';
import * as glob from 'glob';
import path from "path";
import * as glob from "glob";
import errorMessages from "@/plugins/errors";
import vuetify from "@/plugins/vuetify";
import dateFormatter from "@/plugins/dateFormatter";
import { describe, test, expect } from '@jest/globals';
import { render } from '@testing-library/vue';
import { composeStories } from '@storybook/vue3';
import { store } from '@/store';
import { describe, test, expect } from "@jest/globals";
import { render } from "@testing-library/vue";
import { composeStories } from "@storybook/vue3";
import { store } from "@/store";

const compose = (entry) => {
try {
return composeStories(entry);
} catch (e) {
throw new Error(
`There was an issue composing stories for the module: ${JSON.stringify(entry)}, ${e}`,
`There was an issue composing stories for the module: ${JSON.stringify(
entry
)}, ${e}`
);
}
};

function getAllStoryFiles() {
const storyFiles = glob.sync(
path.join(__dirname, '../../src/components/*.{stories,story}.{js,jsx,mjs,ts,tsx}'),
path.join(
__dirname,
"../../src/components/*.{stories,story}.{js,jsx,mjs,ts,tsx}"
)
);

return storyFiles.map((filePath) => {
Expand All @@ -30,19 +35,22 @@ function getAllStoryFiles() {
}

const options = {
suite: 'Storybook Tests',
suite: "Storybook Tests",
storyKindRegex: /^.*?DontTest$/,
storyNameRegex: /UNSET/,
snapshotsDirName: '__snapshots__',
snapshotExtension: '.storyshot',
snapshotsDirName: "__snapshots__",
snapshotExtension: ".storyshot",
};

describe(options.suite, () => {
getAllStoryFiles().forEach(({ storyFile, componentName }) => {
const meta = storyFile.default;
const title = meta.title || componentName;

if (options.storyKindRegex.test(title) || meta.parameters?.storyshots?.disable) {
if (
options.storyKindRegex.test(title) ||
meta.parameters?.storyshots?.disable
) {
// Skip component tests if they are disabled
return;
}
Expand All @@ -52,12 +60,15 @@ describe(options.suite, () => {
.map(([name, story]) => ({ name, story }))
.filter(({ name, story }) => {
// Implements a filtering mechanism to avoid running stories that are disabled via parameters or that match a specific regex mirroring the default behavior of Storyshots.
return !options.storyNameRegex.test(name) && !story.parameters.storyshots?.disable;
return (
!options.storyNameRegex.test(name) &&
!story.parameters.storyshots?.disable
);
});

if (stories.length <= 0) {
throw new Error(
`No stories found for this module: ${title}. Make sure there is at least one valid story for this module, without a disable parameter, or add parameters.storyshots.disable in the default export of this file.`,
`No stories found for this module: ${title}. Make sure there is at least one valid story for this module, without a disable parameter, or add parameters.storyshots.disable in the default export of this file.`
);
}

Expand All @@ -68,9 +79,9 @@ describe(options.suite, () => {
const mounted = render(story(), {
global: {
plugins: [errorMessages, vuetify, store, dateFormatter],
stubs: ['router-link']
stubs: ["router-link"],
},
container: null
container: null,
});
// Ensures a consistent snapshot by waiting for the component to render by adding a delay of 1 ms before taking the snapshot.
await new Promise((resolve) => setTimeout(resolve, 1));
Expand Down
Loading

0 comments on commit 887c62c

Please sign in to comment.