Skip to content

Commit

Permalink
Add support for validating tags
Browse files Browse the repository at this point in the history
  • Loading branch information
Nick-Lucas committed Nov 7, 2021
1 parent bad7ff4 commit 09283e1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
16 changes: 16 additions & 0 deletions packages/giterm-e2e/GuiValidator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const REPO_STATUS = '[data-testid="StatusBar_Status"]'
const BRANCH_STATUS = '[data-testid="StatusBar_Branch"]'
const SHOW_REMOTE_SELECTOR = '[data-testid="StatusBar_ShowRemote"]'

const TAGS_OUTER = '[data-testid="tags"]'
const TAG_ROW = `[data-testid="tag"]`
const TAG_ROW_BY_NAME = (name: string) => `[data-tagid="${name}"]`
const BRANCHES_OUTER = '[data-testid="branches"]'
const BRANCH_ROW = `[data-testid="branch"]`
const BRANCH_ROW_BY_NAME = (name: string) => `[data-branchid="${name}"]`
Expand Down Expand Up @@ -52,6 +55,7 @@ interface CheckScreen {
remote?: RemoteBranchInfo
}
branches: Omit<RefBranch, 'type'>[]
tags: Omit<RefTag, 'type'>[]
commits: number
commitChecks: {
index: number
Expand Down Expand Up @@ -107,6 +111,7 @@ export class GuiValidator {
await this.status(expected.status)
await this.currentBranch(expected.currentBranch.name)
await this.branches(expected.branches)
await this.tags(expected.tags)

await this.commits(expected.commits)
for (const commit of expected.commitChecks) {
Expand Down Expand Up @@ -142,6 +147,17 @@ export class GuiValidator {
}
}

tags = async (tags: Omit<RefTag, 'type'>[]) => {
const tagsSection = await this.exists(TAGS_OUTER)

const tagRows = await tagsSection.$$(TAG_ROW)
expect(tagRows.length).toBe(tags.length)

for (const tag of tags) {
await this.exists(TAG_ROW_BY_NAME(tag.name), tagsSection)
}
}

commits = async (count: number) => {
const commits = await this.wd.$$(COMMIT_ROW)
expect(commits.length).toBe(count)
Expand Down
4 changes: 4 additions & 0 deletions packages/giterm-e2e/giterm.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ describe('giterm', () => {
},
},
branches: [],
tags: [],
commits: 0,
commitChecks: [],
})
Expand All @@ -94,6 +95,7 @@ describe('giterm', () => {
},
},
branches: [],
tags: [],
commits: 0,
commitChecks: [],
})
Expand All @@ -119,6 +121,7 @@ describe('giterm', () => {
name: branchName,
},
],
tags: [],
commits: 1,
commitChecks: [
{
Expand Down Expand Up @@ -169,6 +172,7 @@ describe('giterm', () => {
},
},
],
tags: [],
commits: 1,
commitChecks: [
{
Expand Down
8 changes: 6 additions & 2 deletions packages/giterm/app/renderer/components/sidebar/Tags.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,15 @@ export function Tags() {
}, [tags])

return (
<Section title="TAGS" initialOpenState={false} icon={<Tag size={15} />}>
<Section
data-testid="tags"
title="TAGS"
initialOpenState={false}
icon={<Tag size={15} />}>
{tags.map((tag, index) => {
return (
<RightClickArea key={tag.id} menuItems={menuItems[index]}>
<List.Row>
<List.Row data-testid="tag" data-tagid={tag.name}>
<List.Label>{tag.name}</List.Label>
</List.Row>
</RightClickArea>
Expand Down

0 comments on commit 09283e1

Please sign in to comment.