Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test(seed): add yes we hack organization #552

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions e2e/cypress/support/step_definitions/general.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,10 @@ Then("je ne vois pas {string} dans le tableau", function (text: string) {
cy.get(table_scope).contains(text).should("not.exist");
});

Then("je vois {int} lignes dans le tableau", function (count: number) {
cy.get(table_scope).find("tbody > tr").should("have.length", count);
});

Then(
"je vois {string} dans le tableau {string}",
function (text: string, context: string) {
Expand Down
36 changes: 36 additions & 0 deletions e2e/features/organizations/yes_we_hack_domain_verification.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#language: fr
Fonctionnalité: Page organisation - domaine à vérifier

Contexte:
Soit une base de données nourrie au grain
Quand je navigue sur la page
* je vois "Bonjour Hyyypertool !"
* je clique sur le bouton "AgentConnect"

Scénario:
Quand je clique sur "Domaines à verifier"
Alors je suis redirigé sur "/organizations/domains"
* je vois "Liste des domaines à vérifier"

Soit le tableau sous le title "Liste des domaines à vérifier"
* je vois 2 lignes dans le tableau
* je vois la ligne de table "81403721400016"
* sur la même ligne je vois "Yes we hack"

Quand sur la même ligne je clique sur "➡️"
Alors je vois "A propos de « Yes we hack »"
* je vois "Dénomination : Yes we hack"

Soit le tableau sous le title "Domaines de l'organisation"
* je vois la ligne "yeswehack.com" dans le tableau
* sur la même ligne je vois "❓"

Quand j'ouvre le menu déroulant sur la même ligne
Et je clique sur "✅ Domaine autorisé"
Alors je vois la ligne "yeswehack.com" dans le tableau
Et sur la même ligne je vois "✅"

Quand je clique sur "Domaines à verifier"
Et je clique sur "Rafraichir"
Soit le tableau sous le title "Liste des domaines à vérifier"
Alors je vois 1 lignes dans le tableau
8 changes: 8 additions & 0 deletions packages/~/infra/moncomptepro/database/src/seed/insert.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import type { MCP_Moderation } from "@~/moncomptepro.lib/moncomptepro.d";
import consola from "consola";
import type { MonComptePro_PgDatabase } from "../index";
import { schema } from "../index";
import { insert_commune_de_pompierre } from "./organizations/commune_de_pompierre";
import { insert_yes_we_hack } from "./organizations/yes_we_hack";

//

Expand Down Expand Up @@ -54,6 +56,12 @@ export async function insert_database(db: MonComptePro_PgDatabase) {
);
const sak = await insert_sak(db);
consola.verbose(`🌱 INSERT organization ${sak.cached_nom_complet}`);
const yes_we_hack = await insert_yes_we_hack(db);
consola.verbose(`🌱 INSERT organization yes_we_hack (id: ${yes_we_hack})`);
const commune_de_pompierre = await insert_commune_de_pompierre(db);
consola.verbose(
`🌱 INSERT organization commune_de_pompierre (id: ${commune_de_pompierre})`,
);

//

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//

import { schema, type MonComptePro_PgDatabase } from "../..";

export async function insert_commune_de_pompierre(pg: MonComptePro_PgDatabase) {
const [{ id: organization_id }] = await pg
.insert(schema.organizations)
.values({
cached_activite_principale: "84.11Z",
cached_adresse: "6 rue du chevalier de la barre, 88300 Pompierre",
cached_categorie_juridique: "7210",
cached_code_officiel_geographique: null,
cached_code_postal: "88300",
cached_enseigne: "Mairie",
cached_est_active: true,
cached_est_diffusible: true,
cached_etat_administratif: "A",
cached_libelle_activite_principale:
"84.11Z - Administration publique générale",
cached_libelle_categorie_juridique: "Commune et commune nouvelle",
cached_libelle_tranche_effectif: "1 ou 2 salariés, en 2019",
cached_libelle: "Commune de pompierre - Mairie",
cached_nom_complet: "Commune de pompierre",
cached_statut_diffusion: "O",
cached_tranche_effectifs_unite_legale: "02",
cached_tranche_effectifs: "01",
created_at: "2022-04-11 15:31:44.199+00",
organization_info_fetched_at: "2022-08-08 17:36:27.443+00",
siret: "21880352600019",
updated_at: "2022-04-11 15:31:44.199+00",
})
.returning({ id: schema.organizations.id });

await pg.insert(schema.email_domains).values({
organization_id,
domain: "9online.fr",
verification_type: null,
can_be_suggested: true,
verified_at: null,
created_at: "2022-04-11 15:31:44.199+00",
updated_at: "2022-04-11 15:31:44.199+00",
});

return organization_id;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//

import { schema, type MonComptePro_PgDatabase } from "../..";

export async function insert_yes_we_hack(pg: MonComptePro_PgDatabase) {
const [{ id: organization_id }] = await pg
.insert(schema.organizations)
.values({
cached_activite_principale: "62.09Z",
cached_adresse: "14 rue charles v, 75004 Paris",
cached_categorie_juridique: "5710",
cached_code_officiel_geographique: "75104",
cached_code_postal: "75004",
cached_enseigne: "",
cached_est_active: true,
cached_est_diffusible: true,
cached_etat_administratif: "A",
cached_libelle_activite_principale:
"62.09Z - Autres activités informatiques",
cached_libelle_categorie_juridique: "SAS, société par actions simplifiée",
cached_libelle_tranche_effectif: "20 à 49 salariés, en 2021",
cached_libelle: "Yes we hack",
cached_nom_complet: "Yes we hack",
cached_statut_diffusion: "O",
cached_tranche_effectifs_unite_legale: "21",
cached_tranche_effectifs: "12",
created_at: "2023-12-19 10:02:33.274+00",
organization_info_fetched_at: "2024-09-24 09:15:41.308+00",
siret: "81403721400016",
updated_at: "2024-09-24 09:15:41.308+00",
})
.returning({ id: schema.organizations.id });

await pg.insert(schema.email_domains).values({
organization_id,
domain: "yeswehack.com",
verification_type: null,
can_be_suggested: true,
verified_at: "2024-03-26 05:37:24.197+00",
created_at: "2023-12-19 10:02:33.274+00",
updated_at: "2024-03-26 05:37:24.197+00",
});

return organization_id;
}
7 changes: 4 additions & 3 deletions packages/~/organizations/api/src/domaines/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { query_schema, usePageRequestContext } from "./context";
//
export async function Page() {
const {
var: { hx_domains_query_props },
var: { $describedby, hx_domains_query_props },
} = usePageRequestContext();

return (
Expand All @@ -26,7 +26,7 @@ export async function Page() {
`visibilitychange[document.visibilityState === 'visible'] from:document`,
].join(", ")}
>
<h1>Liste des domaines à vérifier</h1>
<h1 id={$describedby}>Liste des domaines à vérifier</h1>
<Filter />
<Table />
</main>
Expand Down Expand Up @@ -68,6 +68,7 @@ async function Table() {
const {
req,
var: {
$describedby,
$table,
hx_domains_query_props,
query_unverified_domains,
Expand All @@ -88,7 +89,7 @@ async function Table() {

return (
<div class="fr-table [&>table]:table" id={$table}>
<table>
<table aria-describedby={$describedby}>
<thead>
<tr>
<th></th>
Expand Down
5 changes: 3 additions & 2 deletions packages/~/organizations/api/src/domaines/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ export const query_schema = Pagination_Schema.merge(Search_Schema);

export interface ContextVariablesType extends Env {
Variables: {
query_unverified_domains: typeof get_unverified_domains;
$table: string;
$describedby: string;
$search: string;
$table: string;
hx_domains_query_props: Record<"hx-get", string>;
query_unverified_domains: typeof get_unverified_domains;
};
}

Expand Down
4 changes: 3 additions & 1 deletion packages/~/organizations/api/src/domaines/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { Page } from "./Page";

//

const $describedby = hyper_ref();
const $table = hyper_ref();
const $search = hyper_ref();

Expand All @@ -28,8 +29,8 @@ export default new Hono().use("/", jsxRenderer(Main_Layout)).get(
const hx_domains_query_props = {
...(await hx_urls.organizations.domains.$get({ query: {} })),
"hx-include": hx_include([
$table,
$search,
$table,
query_schema.keyof().enum.page,
]),
"hx-replace-url": true,
Expand All @@ -38,6 +39,7 @@ export default new Hono().use("/", jsxRenderer(Main_Layout)).get(
};

return {
$describedby,
$search,
$table,
hx_domains_query_props,
Expand Down