Skip to content
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
12 changes: 6 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- run: pnpm prisma generate
- run: pnpm lint

build:
Expand All @@ -41,7 +41,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- run: pnpm prisma generate
- run: pnpm build

test:
Expand Down Expand Up @@ -76,8 +76,8 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- run: pnpm pnpx prisma db push
- run: pnpm prisma generate
- run: pnpm prisma db push
- run: docker exec -i mariadb mysql -utest -ptest arena < seed.sql
- run: pnpm test:coverage
- uses: codecov/codecov-action@v5
Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
node-version: ${{ matrix.node-version }}
cache: 'pnpm'
- run: pnpm install --frozen-lockfile
- run: pnpm pnpx prisma generate
- run: pnpm prisma generate
- env:
BRANCH: ${{ github.ref == 'refs/heads/master' && 'master' || 'dev' }}
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }}
Expand All @@ -133,7 +133,7 @@ jobs:
password: ${{ secrets.REGISTRY_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v6
with:
with:
push: true
tags: |
${{ secrets.REGISTRY_URL }}/uttarena/api:${{ github.ref == 'refs/heads/master' && 'master' || 'dev' }}
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@

COPY --chown=node:node ./ ./

RUN pnpm pnpx prisma generate
RUN pnpm prisma generate
RUN pnpm build

# Prunes devDependencies
RUN pnpm install --production --ignore-scripts --prefer-offline

CMD pnpm start
CMD pnpm start

Check warning on line 25 in Dockerfile

View workflow job for this annotation

GitHub Actions / deploy

JSON arguments recommended for ENTRYPOINT/CMD to prevent unintended behavior related to OS signals

JSONArgsRecommended: JSON arguments recommended for CMD to prevent unintended behavior related to OS signals More info: https://docs.docker.com/go/dockerfile/rule/json-args-recommended/
6 changes: 3 additions & 3 deletions assets/email/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
<meta name="x-apple-disable-message-reformatting" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta content="telephone=no" name="format-detection" />
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Lexend&display=swap" rel="stylesheet">
<link href="https://fonts.googleapis.com/css2?family=Montserrat&display=swap" rel="stylesheet" />
<link href="https://fonts.googleapis.com/css2?family=Lexend&display=swap" rel="stylesheet" />
<title>UTT Arena {{& year}} - {{& title.topic}}</title>
</head>

Expand Down Expand Up @@ -306,7 +306,7 @@
<td style="text-align: center">
<a
target="_blank"
href="https://discord.gg/WhxZwKU"
href="https://discord.gg/tkRrVZYXmT"
style="
font-size: 14px;
-webkit-text-size-adjust: none;
Expand Down
2 changes: 1 addition & 1 deletion src/controllers/admin/badges/generateBadges.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ const getCommisionPermission = (commissionRole: string, commissionId: string) =>
};

const getCommissionName = (commissionRole: string, commissionId: string, commissionName: string) => {
if (commissionId === 'coord' && commissionRole === 'respo') return 'Présidente';
if (commissionId === 'coord' && commissionRole === 'respo') return 'Président';

if (commissionRole === 'respo') return `Respo ${commissionName}`;
return commissionName;
Expand Down
13 changes: 8 additions & 5 deletions src/operations/item.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import database from '../services/database';
import { Item, ItemCategory, RawItem, Team, TransactionState, User, UserType } from '../types';
import { Item, ItemCategory, RawItem, Team, TransactionState, User } from '../types';
import { isPartnerSchool } from '../utils/helpers';
import { checkForExpiredCarts } from './carts';
import { fetchTournament } from './tournament';
Expand Down Expand Up @@ -73,10 +73,13 @@ export const fetchUserItems = async (team?: Team, user?: User) => {
items.find((element) => element.id === 'discount-switch-ssbu').left = -1;
}

if (!user || user.type !== UserType.player || !team || team.tournamentId === 'ssbu') {
// Remove rents
items = items.filter((element) => element.category !== ItemCategory.rent);
}
// if (
// (!user || user.type === UserType.spectator || !team || team.tournamentId === 'ssbu') &&
// !user.permissions.includes(Permission.orga)
// ) {
// // Remove rents
// items = items.filter((element) => element.category !== ItemCategory.rent);
// }

const ffsu = team?.tournamentId ? (await fetchTournament(team?.tournamentId)).ffsu : false;

Expand Down
2 changes: 1 addition & 1 deletion src/services/email/templates/accountValidation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const generateAccountValidationEmail = (user: Omit<RawUser, 'permissions'
},
{
name: 'Rejoindre le serveur Discord',
location: 'https://discord.gg/WhxZwKU',
location: 'https://discord.gg/tkRrVZYXmT',
},
],
],
Expand Down
2 changes: 1 addition & 1 deletion src/services/email/templates/joinDiscord.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export const generateJoinDiscordEmail = (user: Omit<RawUser, 'permissions'>) =>
'Sur ce serveur, tu pourras également y discuter avec les autres joueurs, ou poser des questions aux organisateurs de ton tournoi.',
{
name: 'Rejoindre le serveur Discord',
location: 'https://discord.gg/WhxZwKU',
location: 'https://discord.gg/tkRrVZYXmT',
},
],
},
Expand Down
4 changes: 2 additions & 2 deletions src/services/email/templates/lastYearAnnounce.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export const generateLastYearPublicAnnounce = (email: string) =>
components: [
"Pour s'inscrire, ça se passe sur le site !",
{
name: "Inscris toi à l'UTT Arena 2024 !",
name: "Inscris toi à l'UTT Arena 2025 !",
location: `https://arena.utt.fr/`,
},
`_Si le bouton ne marche pas, tu peux utiliser ce lien:_\n_https://arena.utt.fr/_`,
Expand All @@ -45,7 +45,7 @@ export const generateLastYearPublicAnnounce = (email: string) =>
},
{
name: 'Rejoindre le serveur Discord',
location: 'https://discord.gg/WhxZwKU',
location: 'https://discord.gg/tkRrVZYXmT',
},
],
],
Expand Down
2 changes: 1 addition & 1 deletion src/services/email/templates/minor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export const generateMinorEmail = (user: Omit<RawUser, 'permissions'>) =>
"Tu nous as indiqué que tu seras mineur à la date de l'UTT Arena. N'oublie pas de préparer *ton autorisation parentale, et une photocopie de ta pièce d'identité, et de celle de ton responsable légal* !",
"La vérification se fera à l'entrée de l'UTT Arena, n'hésite pas à envoyer à l'avance ces documents par mail à arena@utt.fr pour simplifier la procédure à l'entrée.",
{
location: 'https://arena.utt.fr/uploads/files/Autorisation_parentale_-_UTT_Arena_2024.pdf',
location: 'https://arena.utt.fr/uploads/files/Autorisation_parentale_-_UTT_Arena_2025.pdf',
name: "Télécharger l'autorisation parentale",
},
],
Expand Down
4 changes: 2 additions & 2 deletions src/services/email/templates/orderConfirmation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const generateOrderConfirmationEmail = (cart: DetailedCart) =>
highlight: "Bienvenue à l'UTT Arena&nbsp;🔥&nbsp;!",
},
reason:
"Tu as reçu cet email car tu es inscrit à l'UTT Arena 2024. Si ce n'est pas le cas, contacte-nous et change le mot de passe de ta boîte mail.",
"Tu as reçu cet email car tu es inscrit à l'UTT Arena 2025. Si ce n'est pas le cas, contacte-nous et change le mot de passe de ta boîte mail.",
receiver: cart.user.email,
sections: [
{
Expand Down Expand Up @@ -82,7 +82,7 @@ export const generateOrderConfirmationEmail = (cart: DetailedCart) =>
],
{
name: 'Rejoindre le serveur Discord',
location: 'https://discord.gg/WhxZwKU',
location: 'https://discord.gg/tkRrVZYXmT',
},
],
},
Expand Down
3 changes: 2 additions & 1 deletion src/utils/badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,8 @@ export const generateBadge = async (badges: Badge[]) => {

// Place the text containing the name is the bottom middle in bold and in uppercase
// Define a text format
const color: PDFKit.Mixins.ColorValue = badges[index].type === 'fullaccess' ? [239, 220, 235] : [23, 18, 74];
// const color: PDFKit.Mixins.ColorValue = badges[index].type === 'fullaccess' ? [239, 220, 235] : [23, 18, 74];
const color: PDFKit.Mixins.ColorValue = [255, 255, 255];

const textFormat = document.font(fontFamily).fill(color).fontSize(fontSize);

Expand Down
24 changes: 12 additions & 12 deletions tests/items/getItems.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,25 +80,25 @@ describe('GET /items', () => {
display: true,
},
});
// without the "discount-switch-ssbu" item and the "ticket-player-ssbu", the "pc" (in rent category) and the 'ticket-player' item
expect(response.body).to.have.lengthOf(items.length - 4);
// without the "discount-switch-ssbu" item and the "ticket-player-ssbu" and the 'ticket-player' item
expect(response.body).to.have.lengthOf(items.length - 3);
expect(response.body).not.to.have.deep.members([items[0]]);
});

it('should return 200 with an array of items', async () => {
const items = await database.item.findMany();
const response = await request(app).get('/items').expect(200);

// without the "discount-switch-ssbu" item and the "ticket-player-ssbu" and the "pc" (in rent category)
expect(response.body).to.have.lengthOf(items.length - 3);
// without the "discount-switch-ssbu" item and the "ticket-player-ssbu"
expect(response.body).to.have.lengthOf(items.length - 2);
});

it('should return 200 with an array of items with the "discount-switch-ssbu" item', async () => {
const items = await database.item.findMany();
const response = await request(app).get('/items').set('Authorization', `Bearer ${captainToken}`).expect(200);

// with the "discount-switch-ssbu" item but without the legacy "ticket-player" and without "pc" (in rent category)
expect(response.body).to.have.lengthOf(items.length - 2);
// with the "discount-switch-ssbu" item but without the legacy "ticket-player"
expect(response.body).to.have.lengthOf(items.length - 1);
});

it(`should return 200 with an array of items with the "discount-switch-ssbu" and a quantity of -1 item because user has a pending cart containing it`, async () => {
Expand All @@ -109,8 +109,8 @@ describe('GET /items', () => {
const items = await database.item.findMany();
const response = await request(app).get('/items').set('Authorization', `Bearer ${thirdCaptainToken}`).expect(200);

// without the legacy "ticket-player" and without "pc" (in rent category)
expect(response.body).to.have.lengthOf(items.length - 2);
// without the legacy "ticket-player"
expect(response.body).to.have.lengthOf(items.length - 1);
expect(response.body.find((item: Item) => item.id === 'discount-switch-ssbu').left).to.be.equal(-1);
});

Expand All @@ -122,8 +122,8 @@ describe('GET /items', () => {
const items = await database.item.findMany();
const response = await request(app).get('/items').set('Authorization', `Bearer ${thirdCaptainToken}`).expect(200);

// without the "discount-switch-ssbu" item and the legacy "ticket-player" and without "pc" (in rent category)
expect(response.body).to.have.lengthOf(items.length - 3);
// without the "discount-switch-ssbu" item and the legacy "ticket-player"
expect(response.body).to.have.lengthOf(items.length - 2);
});

describe('should return 200 with an array of items with the "discount-switch-ssbu" item because user has a cart containing it, but it was not paid nor it is pending', () => {
Expand All @@ -137,8 +137,8 @@ describe('GET /items', () => {
.set('Authorization', `Bearer ${thirdCaptainToken}`)
.expect(200);

// with the "discount-switch-ssbu" item but without the legacy "ticket-player" and without "pc" (in rent category)
expect(response.body).to.have.lengthOf(items.length - 2);
// with the "discount-switch-ssbu" item but without the legacy "ticket-player"
expect(response.body).to.have.lengthOf(items.length - 1);
});
}
});
Expand Down
21 changes: 0 additions & 21 deletions tests/users/createCart.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -479,27 +479,6 @@ describe('POST /users/current/carts', () => {
);
});

it('should error as spectator cannot rent a pc', async () => {
const spectator = await createFakeUser({ type: UserType.spectator });
const specToken = generateToken(spectator);

return request(app)
.post(`/users/current/carts`)
.set('Authorization', `Bearer ${specToken}`)
.send({
tickets: {
userIds: [],
},
supplements: [
{
itemId: 'pc',
quantity: 1,
},
],
})
.expect(404, { error: Error.ItemNotFound });
});

it('should sucessfully create a cart with a rental pc', async () => {
const userToken = generateToken(notValidUserWithSwitchDiscount);

Expand Down