Skip to content

Commit

Permalink
Set gray icons for archived tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Mathieu2301 committed Jul 25, 2023
1 parent 186a48a commit 0007ce2
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/notion/NotionDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export type IconColor = (
| 'yellow'
| 'red'
| 'pink'
| 'gray'
| 'lightgray'
);

export type Icon = `${IconName}_${IconColor}`;
Expand Down Expand Up @@ -219,6 +219,10 @@ export default class NotionDatabase<RequiredProps extends RequiredProperties> {
results: data.results.map((row: {
id: string,
object: 'page',
icon: {
type: 'external',
external: { url: IconUrl },
},
url: string,
}) => ({
...row,
Expand Down
5 changes: 5 additions & 0 deletions src/notion/agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { generateCodeSnippet, type Stack } from '../vitest/agent';
import { getIconUrl, type Icon } from './NotionDatabase';
import {
statusIconsUrls,
archivedStatusIconsUrls,
type TestStatus,
type TestPage,
type NewTestPage,
Expand Down Expand Up @@ -276,6 +277,10 @@ export async function updateNotionTestsDB(files?: File[]) {
properties: {
archived: { checkbox: true },
},
icon: (
archivedStatusIconsUrls[page.properties.status.status.name as TestStatus]
?? archivedStatusIconsUrls.UNKNOWN
),
});

stats.archived.push(page.url);
Expand Down
12 changes: 11 additions & 1 deletion src/notion/databases/TestsDatabase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ export const statusIconsUrls: { [status in TestStatus]: Icon } = {
SKIP: 'playback-pause_blue',
TODO: 'code_pink',
ONLY: 'checkmark_blue',
RUN: 'playback-play_gray',
RUN: 'playback-play_lightgray',
UNKNOWN: 'question-mark_yellow',
};

export const archivedStatusIconsUrls: { [status in TestStatus]: Icon } = {
PASS: 'checkmark_lightgray',
FAIL: 'clear_lightgray',
SKIP: 'playback-pause_lightgray',
TODO: 'code_lightgray',
ONLY: 'checkmark_lightgray',
RUN: 'playback-play_lightgray',
UNKNOWN: 'question-mark_lightgray',
};

const requiredProps = {
name: { name: { EN: 'Name', FR: 'Nom' }, type: 'title' },
project: { name: { EN: 'Project', FR: 'Projet' }, type: 'select' },
Expand Down

0 comments on commit 0007ce2

Please sign in to comment.