Skip to content

Commit 5eadd65

Browse files
authored
chore: convert tests to TS (#113)
1 parent 7fd7a19 commit 5eadd65

File tree

14 files changed

+452
-332
lines changed

14 files changed

+452
-332
lines changed

.github/workflows/codecov.yml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
name: CodeCov Coverage
2+
3+
on:
4+
push:
5+
branches: [ master ]
6+
pull_request:
7+
branches: [ master ]
8+
9+
jobs:
10+
coverage:
11+
runs-on: ubuntu-latest
12+
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
17+
strategy:
18+
matrix:
19+
node-version: [22.x]
20+
21+
steps:
22+
- uses: actions/[email protected]
23+
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/[email protected]
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: 'yarn'
29+
30+
- name: Install dependencies
31+
run: yarn install --frozen-lockfile
32+
33+
- name: Run tests with coverage
34+
run: yarn test:coverage
35+
36+
- name: Upload coverage to Codecov
37+
uses: codecov/[email protected]
38+
with:
39+
token: ${{ secrets.CODECOV_TOKEN }}
40+
files: ./coverage/lcov.info
41+
flags: unittests
42+
name: codecov-umbrella
43+
fail_ci_if_error: false
44+
verbose: true

cypress.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { defineConfig } from 'cypress'
33
export default defineConfig({
44
video: false,
55
e2e: {
6-
// We've imported your old cypress plugins here.
7-
// You may want to clean this up later by importing these.
86
setupNodeEvents(on, config) {
9-
return require('./cypress/plugins/index.js')(on, config)
7+
// No plugins needed for now
8+
return config;
109
},
10+
baseUrl: 'http://localhost:3000',
11+
supportFile: 'cypress/support/e2e.ts',
12+
specPattern: 'cypress/e2e/**/*.cy.ts'
1113
},
1214
})

cypress/e2e/basic_tests.cy.js renamed to cypress/e2e/basic_tests.cy.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,18 @@ describe("Integration Tests", () => {
1313
cy.contains("GET STARTED").click();
1414

1515
// show default docs page
16-
cy.contains("Install and Quick start");
17-
cy.contains("Coloring");
18-
cy.contains("Sort and Filter");
19-
cy.contains("Alignment");
16+
const expectedTexts: string[] = [
17+
"Install and Quick start",
18+
"Coloring",
19+
"Sort and Filter",
20+
"Alignment",
21+
"Installation",
22+
"Basic Example"
23+
];
2024

21-
cy.contains("Installation");
22-
cy.contains("Basic Example");
25+
expectedTexts.forEach((text: string) => {
26+
cy.contains(text);
27+
});
2328
});
2429

2530
it("Docs Pages Works: Quick Start", () => {
@@ -31,4 +36,4 @@ describe("Integration Tests", () => {
3136

3237
cy.contains("Detailed usage");
3338
});
34-
});
39+
});

cypress/e2e/image_tests.cy.js renamed to cypress/e2e/image_tests.cy.ts

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
1+
interface Page {
2+
url: string;
3+
name: string;
4+
}
5+
6+
interface Interception {
7+
response?: {
8+
statusCode: number;
9+
};
10+
request: {
11+
url: string;
12+
};
13+
}
14+
115
describe("Documentation Page Images", () => {
2-
const pages = [
16+
const pages: Page[] = [
317
{ url: "/docs", name: "Install and Quick start" },
418
{ url: "/docs/doc-table-instance-creation", name: "Create Table Instance" },
519
{ url: "/docs/doc-adding-rows", name: "Adding Rows" },
@@ -28,7 +42,7 @@ describe("Documentation Page Images", () => {
2842
cy.intercept('GET', '/img/**/*').as('imageRequest');
2943
});
3044

31-
pages.forEach(page => {
45+
pages.forEach((page: Page) => {
3246
it(`should load all images properly on ${page.name} page`, () => {
3347
let imageRequestCount = 0;
3448

@@ -51,7 +65,7 @@ describe("Documentation Page Images", () => {
5165
cy.get('img', { timeout: 10000 }).should('exist');
5266

5367
// Get all images and verify their loading
54-
cy.get('img').then($images => {
68+
cy.get('img').then(($images) => {
5569
// Verify each image
5670
cy.wrap($images).each(($img, index) => {
5771
// Create a unique alias for this image
@@ -60,9 +74,10 @@ describe("Documentation Page Images", () => {
6074

6175
// Wait for the image to be loaded
6276
cy.get(`@${imgId}`).should(($img) => {
63-
expect($img[0].complete).to.be.true;
64-
expect($img[0].naturalWidth).to.be.greaterThan(0);
65-
expect($img[0].naturalHeight).to.be.greaterThan(0);
77+
const img = $img[0] as HTMLImageElement;
78+
expect(img.complete).to.be.true;
79+
expect(img.naturalWidth).to.be.greaterThan(0);
80+
expect(img.naturalHeight).to.be.greaterThan(0);
6681
});
6782

6883
// Verify src attribute
@@ -73,9 +88,10 @@ describe("Documentation Page Images", () => {
7388
});
7489

7590
// Verify all image requests were successful
76-
cy.get('@imageRequestCounter.all').then((interceptions) => {
77-
if (interceptions.length > 0) {
78-
interceptions.forEach((interception) => {
91+
cy.get('@imageRequestCounter.all').then((interceptions: unknown) => {
92+
const interceptArray = interceptions as Interception[];
93+
if (interceptArray.length > 0) {
94+
interceptArray.forEach((interception) => {
7995
if (interception.response) {
8096
expect([200, 304]).to.include(interception.response.statusCode);
8197
} else {
@@ -120,8 +136,9 @@ describe("Documentation Page Images", () => {
120136
cy.wrap($img).as(imgId);
121137

122138
cy.get(`@${imgId}`).then(($img) => {
123-
const naturalWidth = $img[0].naturalWidth;
124-
const naturalHeight = $img[0].naturalHeight;
139+
const img = $img[0] as HTMLImageElement;
140+
const naturalWidth = img.naturalWidth;
141+
const naturalHeight = img.naturalHeight;
125142

126143
// Images should have reasonable dimensions
127144
expect(naturalWidth).to.be.within(50, 2000);

cypress/e2e/link_tests.cy.js renamed to cypress/e2e/link_tests.cy.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
interface SidebarLink {
2+
text: string;
3+
url: string;
4+
}
5+
16
describe("Link Tests", () => {
27
beforeEach(() => {
38
cy.visit("http://localhost:3000");
@@ -62,7 +67,7 @@ describe("Link Tests", () => {
6267

6368
it("should have working sidebar navigation links", () => {
6469
// Test all sidebar links
65-
const sidebarLinks = [
70+
const sidebarLinks: SidebarLink[] = [
6671
{ text: "Install and Quick start", url: "/docs" },
6772
{ text: "Create Table Instance", url: "/docs/doc-table-instance-creation" },
6873
{ text: "Adding Rows", url: "/docs/doc-adding-rows" },
@@ -83,7 +88,7 @@ describe("Link Tests", () => {
8388
{ text: "Quick Start", url: "/docs/doc-cli-install-quick-start" }
8489
];
8590

86-
sidebarLinks.forEach(link => {
91+
sidebarLinks.forEach((link: SidebarLink) => {
8792
cy.contains(link.text).click();
8893
cy.url().should("include", link.url);
8994
// Verify page content is loaded

cypress/e2e/page_tests.cy.js

Lines changed: 0 additions & 134 deletions
This file was deleted.

0 commit comments

Comments
 (0)